def load(): """ Adds two dummy formats to the formatter, `pdf` and `dvi`. Hooks `pdf_bypass` to after `post_status` in the [process_list](%/Modules/process_list.html) to ensure that arguments from the command line and from the template file are both loaded. The bypass function checks to see if either PDF or DVI formats have been requested. Loads the following [options](%/Modules/options.html): - `recomps -r` The number of LaTeX recompilations :return: plugin signature """ parser_composer.add_format( name='pdf', extensions=['pdf'], description='PDF export support', format={} ) parser_composer.add_format( name='dvi', extensions=['dvi'], description='DVI export support', format={} ) process_list.run_after('post_status', pdf_bypass) options.add_option('recomps', '-r', 'The number of LaTeX recompilations', config.recomps, int) return signature
def load(): """ Loads the following [option](%/Modules/options.html): - `htmltemplate -htt` Specify an HTML template file Loads the HTML format. The template file is used as a wrapper for converted content. """ options.add_option( 'htmltemplate', '-htt', 'Specify an HTML template file', os.path.abspath(os.path.dirname(__file__) + '/../templates/exam.html'), str ) parser_composer.add_format( name='html', extensions=['html'], description=signature[2], composer_preprocessor=composer_preprocessor, composer_postprocessor=composer_postprocessor, left_paren='<div', right_paren='</div>', # Use an OrderedDict to preserve token order format=collections.OrderedDict([ ('comment', ['<!--', (), '-->', '.']), ('questions', ['<div class="questions">', (), '</div>', '.']), ('$$', [' $$', (), '$$ ', '.']), ('$', [' $', (), '$ ', '.']), ('title', ['<div class="title">', (), '</div>', '.']), ('solution', ['<div class="solution">', (), '</div>', '.']), ('img', ['<img alt="Embedded Image" src="data:image/png;base64,', (), '">', '.']), ('choice', ['<div class="choice">', (), '</div>', '.']), ('correctchoice', ['<div class="correctchoice">', (), '</div>', '.']), ('tolerance', [' tolerance ', (), '.']), ('verbatim', ['<pre class="verb-block">', (), '</pre>', '.']), ('true', ['<div class=True>True</div>', '.']), ('false', ['<div class=False>False</div>', '.']), ('h3', ['<h3>', (), '</h3>', '.']), ('h2', ['<h2>', (), '</h2>', '.']), ('h1', ['<h1>', (), '</h1>', '.']), ('list', ['<ul>', (), '</ul>', '.']), ('listitem', ['<li>', (), '</li>']), ('hr', ['<hr />', '.']), ('center', ['<div class="center">', (), '</div>', '.']), ('emphasis3', ['<i><b>', (), '</b></i>', '.']), ('emphasis2', ['<br /><b>', (), '</b>', '.']), ('emphasis1', ['<i>', (), '</i>', '.']), ('verbython', ['<pre class="verb-python">', (), '</pre>', '.']), ('verbhtml', ['<div></div>', (), '<div></div>', '.']), ('verbblock', ['<pre class="verb-block">', (), '</pre>', '.']), ('verbquote', ['<div class="verb-quote">', (), '</div>', '.']), ('verbexpr', ['<pre class="verb-expr">', (), '</pre>', '.']), ('newline', ['<br />', '.']) ]) ) return signature
def load(): """ Loads the tex formatter. """ parser_composer.add_format( name="tex", extensions=["tex", "LaTeX", "latex"], description=signature[2], parser_preprocessor=parser_preprocessor, parser_postprocessor=parser_postprocessor, composer_preprocessor=composer_preprocessor, composer_postprocessor=composer_postprocessor, left_paren="{", right_paren="}", # Use an OrderedDict to preserve token order format=collections.OrderedDict( [ ("comment", ["%", (), "\n"]), ("commentblock", ["\\begin{comment}", (), "\\end{comment}", "."]), ("$$", ["$$", (), "$$", "."]), ("$", ["$", (), "$", "."]), ("questions", ["\\begin{questions}", (), "\\end{questions}", "."]), ("solution", ["\\begin{solution}", (), "\\end{solution}", "."]), ("img", ["\\includegraphics[width= \linewidth]{", (), "}", "."]), ("choices", ["\\begin{choices}", (), "\\end{choices}", "."]), ("choice", ["\\choice ", (), r"(\\choice)|(\\CorrectChoice)"]), ("correctchoice", ["\\CorrectChoice ", (), r"(\\choice)|(\\CorrectChoice)"]), ("verbatim", ["\\begin{verbatim}", (), "\\end{verbatim}", "."]), ("verbython", ["\\begin{verbatim}", (), "\\end{verbatim}", "."]), ("verbhtml", ["\\begin{verbatim}\\end{verbatim}", "."]), ("verbblock", ["\\begin{verbatim}", (), "\\end{verbatim}", "."]), ("newpage", ["\\clearpage", "."]), ("h3", ["\\textbf{", (), "} \\\\", "."]), ("h2", ["\\subsection*{", (), "}", "."]), ("h1", ["\\section*{", (), "}", "."]), ("list", [" \\begin{description} ", (), " \\end{description} ", "."]), ("listitem", ["\item ", (), "\n"]), ("newline", ["\\\\", "."]), ("center", ["\\begin{center}", (), "\\end{center}", "."]), ("question", ["\\titled", (), end]), ("multichoice", [["title"], (), ["choices"], (), "$"]), ("shortanswer", [["title"], (), ["solution"], (), "$"]), ("truefalse", [["title"], (), ["choices"], "$"]), ("essay", [["title"], (), "$"]), ("title", ["question{", (), "}", "."]), ("center", ["\\begin{center}", (), "\\end{center}", "."]), ("emphasis2", ["\\textbf{", (), "}", "."]), ("emphasis1", ["\\textit{", (), "}", "."]), ("unknown", ["\\", (), "\\s+"]), ] ), ) return signature
def load(): """ Loads the following [option](%/Modules/options.html): - `htmltemplate -htt` Specify an HTML template file Loads the HTML format. The template file is used as a wrapper for converted content. """ options.add_option( 'htmltemplate', '-htt', 'Specify an HTML template file', os.path.abspath(os.path.dirname(__file__) + '/../templates/exam.html'), str) parser_composer.add_format( name='html', extensions=['html'], description=signature[2], composer_preprocessor=composer_preprocessor, composer_postprocessor=composer_postprocessor, left_paren='<div', right_paren='</div>', # Use an OrderedDict to preserve token order format=collections.OrderedDict([ ('comment', ['<!--', (), '-->', '.']), ('questions', ['<div class="questions">', (), '</div>', '.']), ('$$', [' $$', (), '$$ ', '.']), ('$', [' $', (), '$ ', '.']), ('title', ['<div class="title">', (), '</div>', '.']), ('solution', ['<div class="solution">', (), '</div>', '.']), ('img', [ '<img alt="Embedded Image" src="data:image/png;base64,', (), '">', '.' ]), ('choice', ['<div class="choice">', (), '</div>', '.']), ('correctchoice', ['<div class="correctchoice">', (), '</div>', '.']), ('tolerance', [' tolerance ', (), '.']), ('verbatim', ['<pre class="verb-block">', (), '</pre>', '.']), ('true', ['<div class=True>True</div>', '.']), ('false', ['<div class=False>False</div>', '.']), ('h3', ['<h3>', (), '</h3>', '.']), ('h2', ['<h2>', (), '</h2>', '.']), ('h1', ['<h1>', (), '</h1>', '.']), ('list', ['<ul>', (), '</ul>', '.']), ('listitem', ['<li>', (), '</li>']), ('hr', ['<hr />', '.']), ('center', ['<div class="center">', (), '</div>', '.']), ('emphasis3', ['<i><b>', (), '</b></i>', '.']), ('emphasis2', ['<br /><b>', (), '</b>', '.']), ('emphasis1', ['<i>', (), '</i>', '.']), ('verbython', ['<pre class="verb-python">', (), '</pre>', '.']), ('verbhtml', ['<div></div>', (), '<div></div>', '.']), ('verbblock', ['<pre class="verb-block">', (), '</pre>', '.']), ('verbquote', ['<div class="verb-quote">', (), '</div>', '.']), ('verbexpr', ['<pre class="verb-expr">', (), '</pre>', '.']), ('newline', ['<br />', '.']) ])) return signature
def load(): """ Adds the org format to the [formatter](%/Modules/Formatter.html). :return: plugin signature """ parser_composer.add_format( name='org', extensions=['org'], description=signature[2], parser_preprocessor=parser_preprocessor, parser_postprocessor=parser_postprocessor, composer_preprocessor=composer_preprocessor, composer_postprocessor=composer_postprocessor, format=collections.OrderedDict([ ('comment', ['#', (), '\n']), ('commentblock', ['#+BEGIN_COMMENT ', (), '#+END_COMMENT']), ('commentblocktree', ['* COMMENT ', (), '\*']), ('$$', ['$$', (), '$$', '.']), ('$', ['$', (), '$', '.']), ('questions', ['* ?::', (), '\n\*\s']), ('question', ['** ?', (), '\n\*\*[^*]']), ('solution', ['*** solution', (), '\n\*']), ('dataset', ['*** dataset', (), '\n\*']), ('img', ['\includegraphics[width= \\linewidth]{', (), '}', '.']), ('choices', ['*** choices', (), '\n\*']), ('choice', ['- [ ]', (), '(- \[)|(\n\*)']), ('correctchoice', ['- [X]', (), '(- \[)|(\n\*)']), ('multichoice', [['title'], (), ['choices'], (), '$']), ('shortanswer', [['title'], (), ['solution'], (), '$']), ('essay', [['title'], (), '\n\*\*[^*]']), ('title', ['::', (), '\n']), ('newpage', ['* clearpage', '.']), ('center', ['* center', (), '\n']), ('h3', ['***', (), '\n']), ('h2', ['**', (), '\n']), ('h1', ['*', (), '\n']), ('listitem', ['- ', (), '(- )|\*|(\n\n)']), ('verbatim', ['\\begin{verbatim}', (), '\\end{verbatim}', '.']), ('verbython', ['```python', (), '```', '.']), ('verbhtml', ['```html', (), '```', '.']), ('verbquote', ['```quote', (), '```', '.']), ('verbblock', ['```', (), '```', '.']), ('hr', ['-----', '.']), ('emphasis2', ['``', (), '``', '.']), ('emphasis1', ['`', (), '`', '.']), ('verbexpr', ['~', (), '~', '.']), ('newline', ['<br />', '.']), ]) ) return signature
def load(): """ Adds the org format to the [formatter](%/Modules/Formatter.html). :return: plugin signature """ parser_composer.add_format( name='org', extensions=['org'], description=signature[2], parser_preprocessor=parser_preprocessor, parser_postprocessor=parser_postprocessor, composer_preprocessor=composer_preprocessor, composer_postprocessor=composer_postprocessor, format=collections.OrderedDict([ ('comment', ['#', (), '\n']), ('commentblock', ['#+BEGIN_COMMENT ', (), '#+END_COMMENT']), ('commentblocktree', ['* COMMENT ', (), '\*']), ('$$', ['$$', (), '$$', '.']), ('$', ['$', (), '$', '.']), ('questions', ['* ?::', (), '\n\*\s']), ('question', ['** ?', (), '\n\*\*[^*]']), ('solution', ['*** solution', (), '\n\*']), ('dataset', ['*** dataset', (), '\n\*']), ('img', ['\includegraphics[width= \\linewidth]{', (), '}', '.']), ('choices', ['*** choices', (), '\n\*']), ('choice', ['- [ ]', (), '(- \[)|(\n\*)']), ('correctchoice', ['- [X]', (), '(- \[)|(\n\*)']), ('multichoice', [['title'], (), ['choices'], (), '$']), ('shortanswer', [['title'], (), ['solution'], (), '$']), ('essay', [['title'], (), '\n\*\*[^*]']), ('title', ['::', (), '\n']), ('newpage', ['* clearpage', '.']), ('center', ['* center', (), '\n']), ('h3', ['***', (), '\n']), ('h2', ['**', (), '\n']), ('h1', ['*', (), '\n']), ('listitem', ['- ', (), '(- )|\*|(\n\n)']), ('verbatim', ['\\begin{verbatim}', (), '\\end{verbatim}', '.']), ('verbython', ['```python', (), '```', '.']), ('verbhtml', ['```html', (), '```', '.']), ('verbquote', ['```quote', (), '```', '.']), ('verbblock', ['```', (), '```', '.']), ('hr', ['-----', '.']), ('emphasis2', ['``', (), '``', '.']), ('emphasis1', ['`', (), '`', '.']), ('verbexpr', ['~', (), '~', '.']), ('newline', ['<br />', '.']), ])) return signature
def load(): """ Loads the tex formatter. """ parser_composer.add_format( name='tex', extensions=['tex', 'LaTeX', 'latex'], description=signature[2], parser_preprocessor=parser_preprocessor, parser_postprocessor=parser_postprocessor, composer_preprocessor=composer_preprocessor, composer_postprocessor=composer_postprocessor, left_paren='{', right_paren='}', # Use an OrderedDict to preserve token order format=collections.OrderedDict([ ('comment', ['%', (), '\n']), ('commentblock', ['\\begin{comment}', (), '\\end{comment}', '.']), ('$$', ['$$', (), '$$', '.']), ('$', ['$', (), '$', '.']), ('questions', ['\\begin{questions}', (), '\\end{questions}', '.']), ('solution', ['\\begin{solution}', (), '\\end{solution}', '.']), ('img', ['\\includegraphics[width= \linewidth]{', (), '}', '.']), ('choices', ['\\begin{choices}', (), '\\end{choices}', '.']), ('choice', ['\\choice ', (), r'(\\choice)|(\\CorrectChoice)']), ('correctchoice', ['\\CorrectChoice ', (), r'(\\choice)|(\\CorrectChoice)']), ('verbatim', ['\\begin{verbatim}', (), '\\end{verbatim}', '.']), ('verbython', ['\\begin{verbatim}', (), '\\end{verbatim}', '.']), ('verbhtml', ['\\begin{verbatim}\\end{verbatim}', '.']), ('verbblock', ['\\begin{verbatim}', (), '\\end{verbatim}', '.']), ('newpage', ['\\clearpage', '.']), ('h3', ['\\textbf{', (), '} \\\\', '.']), ('h2', ['\\subsection*{', (), '}', '.']), ('h1', ['\\section*{', (), '}', '.']), ('list', [' \\begin{description} ', (), ' \\end{description} ', '.']), ('listitem', ['\item ', (), '\n']), ('newline', ['\\\\', '.']), ('center', ['\\begin{center}', (), '\\end{center}', '.']), ('question', ['\\titled', (), end]), ('multichoice', [['title'], (), ['choices'], (), '$']), ('shortanswer', [['title'], (), ['solution'], (), '$']), ('truefalse', [['title'], (), ['choices'], '$']), ('essay', [['title'], (), '$']), ('title', ['question{', (), '}', '.']), ('center', ['\\begin{center}', (), '\\end{center}', '.']), ('emphasis2', ['\\textbf{', (), '}', '.']), ('emphasis1', ['\\textit{', (), '}', '.']), ('unknown', ['\\', (), '\\s+']) ])) return signature
def load(): """ Loads the moodle xml format. """ parser_composer.add_format( name='moodle', extensions=['xml'], description=signature[2], format=collections.OrderedDict([ ('comment', ['<!--', (), '-->', '.']), ('$$', [' $$', (), '$$ ', '.']), ('$', [' $', (), '$ ', '.']), ('questions', ['<?xml version="1.0" ?> <quiz>', (), '</quiz>', '.']), ('title', ['<name> <text>', (), '</text></name>', '.']), ('prompt', ['<questiontext format="html"> <text> <![CDATA[', mathjax, (), ']]> </text> </questiontext>', '.']), ('solution', ['<answer fraction="100">', (), '<feedback> <text> Correct </text> </feedback> </answer>', '.']), ('img', ['<img style="width: 100%" alt="Embedded Image" src="data:image/png;base64,', (), '">', '.']), ('choice', ['<answer fraction="0"> <text>', (), '</text> <feedback> <text>Incorrect</text> </feedback> </answer>', '.']), ('correctchoice', ['<answer fraction="100"> <text>', (), '</text> <feedback> <text>Correct</text> </feedback> </answer>', '.']), ('verbatim', ['<pre class="verbatim">', (), '</pre>', '.']), ('essay', ['<question type="essay">', (), '</question>', '']), ('tolerance', ['<tolerance>', (), '</tolerance><tolerancetype>1</tolerancetype>', '.']), ('shortanswer', ['<question type="shortanswer">', ['title'], (), '</question>', '.']), ('multichoice', ['<question type="multichoice">', ['title'], (), '<shuffleanswers>1</shuffleanswers></question>', '.']), ('multiselect', ['<question type="multichoice"><single>false</single>', ['title'], (), '<shuffleanswers>1</shuffleanswers></question>', '.']), ('numerical', ['<question type="numerical">', ['title'], (), '</question>', '.']), ('calculated', ['<question type="calculatedsimple">', ['title'], (), '</question>', '.']), ('params', ['<dataset_definitions>', (), '</dataset_definitions>', '.']), ('param', ['<dataset_definition><status><text>private</text></status>', (), '</dataset_definition>', '.']), ('paramname', ['<name><text>', (), '</text></name><distribution><text>uniform</text></distribution>', '.']), ('parammax', ['<maximum><text>', (), '</text></maximum>', '.']), ('parammin', ['<minimum><text>', (), '</text></minimum>', '.']), ('paramdec', ['<decimals><text>', (), '</text></decimals>', '.']), ('itemcount', ['<itemcount>', (), '</itemcount>', '.']), ('items', ['<dataset_items>', (), '</dataset_items>', '.']), ('itemnumber', ['<dataset_item><number>', (), '</number>', '.']), ('itemvalue', ['<value>', (), '</value></dataset_item>', '.']), ('emphasis3', ['<i><b> ', (), ' </b></i>', '.']), ('emphasis2', ['<b> ', (), ' </b>', '.']), ('emphasis1', ['<i> ', (), ' </i>', '.']), ('decimal', ['<correctanswerformat>1</correctanswerformat><correctanswerlength>', (), '</correctanswerlength>', '.']) ]), composer_preprocessor=composer_preprocessor, composer_postprocessor=composer_postprocessor ) return signature
def load(): """ Adds two dummy formats to the formatter, `pdf` and `dvi`. Hooks `pdf_bypass` to after `post_status` in the [process_list](%/Modules/process_list.html) to ensure that arguments from the command line and from the template file are both loaded. The bypass function checks to see if either PDF or DVI formats have been requested. Loads the following [options](%/Modules/options.html): - `recomps -r` The number of LaTeX recompilations :return: plugin signature """ parser_composer.add_format(name='pdf', extensions=['pdf'], description='PDF export support', format={}) parser_composer.add_format(name='dvi', extensions=['dvi'], description='DVI export support', format={}) process_list.run_after('post_status', pdf_bypass) options.add_option('recomps', '-r', 'The number of LaTeX recompilations', config.recomps, int) return signature
def load(): """ Loads the markdown format. """ parser_composer.add_format( name='markdown', extensions=['md'], description=signature[2], # Use an OrderedDict to preserve token order format=collections.OrderedDict([('h3', ['###', (), '\n']), ('h2', ['##', (), '\n']), ('h1', ['#', (), '\n']), ('listitem', [' - ', (), '\n']), ('hr', ['***', '\s']), ('emphasis3', ['***', (), '***', '.']), ('emphasis2', ['**', (), '**', '.']), ('emphasis1', ['*', (), '*', '.']), ('verbython', ['```python', (), '```', '.']), ('verbblock', ['```', (), '```', '.']), ('verbexpr', ['`', (), '`', '.'])])) return signature
def load(): """ Loads the markdown format. """ parser_composer.add_format( name='markdown', extensions=['md'], description=signature[2], # Use an OrderedDict to preserve token order format=collections.OrderedDict([ ('h3', ['###', (), '\n']), ('h2', ['##', (), '\n']), ('h1', ['#', (), '\n']), ('listitem', [' - ', (), '\n']), ('hr', ['***', '\s']), ('emphasis3', ['***', (), '***', '.']), ('emphasis2', ['**', (), '**', '.']), ('emphasis1', ['*', (), '*', '.']), ('verbython', ['```python', (), '```', '.']), ('verbblock', ['```', (), '```', '.']), ('verbexpr', ['`', (), '`', '.']) ]) ) return signature
def load(): """ Loads the moodle xml format. """ parser_composer.add_format( name='moodle', extensions=['xml'], description=signature[2], format=collections.OrderedDict([ ('comment', ['<!--', (), '-->', '.']), ('$$', [' $$', (), '$$ ', '.']), ('$', [' $', (), '$ ', '.']), ('questions', ['<?xml version="1.0" ?> <quiz>', (), '</quiz>', '.']), ('title', ['<name> <text>', (), '</text></name>', '.']), ('prompt', [ '<questiontext format="html"> <text> <![CDATA[', mathjax, (), ']]> </text> </questiontext>', '.' ]), ('solution', [ '<answer fraction="100">', (), '<feedback> <text> Correct </text> </feedback> </answer>', '.' ]), ('img', [ '<img style="width: 100%" alt="Embedded Image" src="data:image/png;base64,', (), '">', '.' ]), ('choice', [ '<answer fraction="0"> <text>', (), '</text> <feedback> <text>Incorrect</text> </feedback> </answer>', '.' ]), ('correctchoice', [ '<answer fraction="100"> <text>', (), '</text> <feedback> <text>Correct</text> </feedback> </answer>', '.' ]), ('verbatim', ['<pre class="verbatim">', (), '</pre>', '.']), ('essay', ['<question type="essay">', (), '</question>', '']), ('tolerance', [ '<tolerance>', (), '</tolerance><tolerancetype>1</tolerancetype>', '.' ]), ('shortanswer', [ '<question type="shortanswer">', ['title'], (), '</question>', '.' ]), ('multichoice', [ '<question type="multichoice">', ['title'], (), '<shuffleanswers>1</shuffleanswers></question>', '.' ]), ('multiselect', [ '<question type="multichoice"><single>false</single>', ['title'], (), '<shuffleanswers>1</shuffleanswers></question>', '.' ]), ('numerical', [ '<question type="numerical">', ['title'], (), '</question>', '.' ]), ('calculated', [ '<question type="calculatedsimple">', ['title'], (), '</question>', '.' ]), ('params', ['<dataset_definitions>', (), '</dataset_definitions>', '.']), ('param', [ '<dataset_definition><status><text>private</text></status>', (), '</dataset_definition>', '.' ]), ('paramname', [ '<name><text>', (), '</text></name><distribution><text>uniform</text></distribution>', '.' ]), ('parammax', ['<maximum><text>', (), '</text></maximum>', '.']), ('parammin', ['<minimum><text>', (), '</text></minimum>', '.']), ('paramdec', ['<decimals><text>', (), '</text></decimals>', '.']), ('itemcount', ['<itemcount>', (), '</itemcount>', '.']), ('items', ['<dataset_items>', (), '</dataset_items>', '.']), ('itemnumber', ['<dataset_item><number>', (), '</number>', '.']), ('itemvalue', ['<value>', (), '</value></dataset_item>', '.']), ('emphasis3', ['<i><b> ', (), ' </b></i>', '.']), ('emphasis2', ['<b> ', (), ' </b>', '.']), ('emphasis1', ['<i> ', (), ' </i>', '.']), ('decimal', [ '<correctanswerformat>1</correctanswerformat><correctanswerlength>', (), '</correctanswerlength>', '.' ]) ]), composer_preprocessor=composer_preprocessor, composer_postprocessor=composer_postprocessor) return signature