I am struggling with exporting a tex document (see below) which uses the exam class to markdown. Somehow the exam class breaks the default settings of pandoc. In particular the command pandoc -i mytest.tex -o mytest.md
produces a document with empty content for the question parts.
Edit: I am aware of this old issue of pandoc https://github.com/jgm/pandoc/issues/4023 and included the proposed workaround. However, it does not apply to blanks and multiple choice questions.
Do you have any idea on how to use pandoc or pandoc-filters in a way that pandoc can handle the question parts and create a markdown document which contains the question parts and the solutions of the tex document?
Here is the sample tex-document
\documentclass[answers]{exam}
\usepackage{minted}
\let\oldpart\part
\renewcommand{\part}[1][]{\oldpart[#1]{}}
\begin{document}
\begin{questions}
\question Exercise 1
\begin{parts}
\part[1] This fills in the \fillin[blanks]
\end{parts}
\question Exercise 2
\begin{parts}
\part[2] Please tick the \textbf{right} statements
\begin{checkboxes}
\CorrectChoice This is correct.
\choice The correct answer is not this answer.
\choice This is the wrong answer.
\CorrectChoice This is right.
\end{checkboxes}
\end{parts}
\end{questions}
\end{document}
I created a follow-up question to this original question here
Pandoc doesn't know about the exam
class and the commands that are defined within. A good method is therefore to provide pandoc with some pseudo-definitions, which just enough info to make it work. In this case, it's seems to be enough to provide a redefinition of \part
and to treat checkboxes as list items:
% ignore \part
\renewcommand{\part}[0][1]{}
% Treat checkboxes like an itemized list
\newenvironment{checkboxes}{\begin{itemize}}{\end{itemize}}
\renewcommand{\CorrectChoice}{\item ☒ }
\renewcommand{\choice}{\item ☐ }
You can put that into a separate file as not to interfere with the actual LaTeX, and pass it to pandoc as the first file:
pandoc redefine-part.tex mytest.tex -o test.md
With that, the generated Markdown becomes
::: questions
Exercise 1
::: parts
This fills in the
:::
Exercise 2
::: parts
Please tick the **right** statements
- [x] This is correct.
- [ ] The correct answer is not this answer.
- [ ] This is the wrong answer.
- [x] This is right.
:::
:::
Nota bene: -i
does not stand for input
and probably doesn't do what you think.