Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd just go ahead and use <a href="http://freewisdom.org/projects/python-markdown/" rel="noreferrer">python-markdown</a> and monkey-patch it. You can write your own <code>def_block_parser()</code> function and substitute that in for the default one to disable some of the Markdown functionality:</p> <pre><code>from markdown import blockprocessors as bp def build_block_parser(md_instance, **kwargs): """ Build the default block parser used by Markdown. """ parser = bp.BlockParser(md_instance) parser.blockprocessors['empty'] = bp.EmptyBlockProcessor(parser) parser.blockprocessors['indent'] = bp.ListIndentProcessor(parser) # parser.blockprocessors['code'] = bp.CodeBlockProcessor(parser) parser.blockprocessors['hashheader'] = bp.HashHeaderProcessor(parser) parser.blockprocessors['setextheader'] = bp.SetextHeaderProcessor(parser) parser.blockprocessors['hr'] = bp.HRProcessor(parser) parser.blockprocessors['olist'] = bp.OListProcessor(parser) parser.blockprocessors['ulist'] = bp.UListProcessor(parser) parser.blockprocessors['quote'] = bp.BlockQuoteProcessor(parser) parser.blockprocessors['paragraph'] = bp.ParagraphProcessor(parser) return parser bp.build_block_parser = build_block_parser </code></pre> <p>Note that I've simply copied and pasted the default <code>build_block_processor()</code> function from the <code>blockprocessors.py</code> file, tweaked it a bit (inserting <code>bp.</code> in front of all the names from that module), and commented out the line where it adds the code block processor. The resulting function is then monkey-patched back into the module. A similar method looks feasible for <code>inlinepatterns.py</code>, <code>treeprocessor.py</code>, <code>preprocessor.py</code>, and <code>postprocessor.py</code>, each of which does a different kind of processing.</p> <p>Rather than rewriting the function that sets up the individual parsers, as I've done above, you could also patch out the parser classes themselves with do-nothing subclasses that would still be invoked but which would do nothing. That is probably simpler:</p> <pre><code>from markdown import blockprocessors as bp class NoProcessing(bp.BlockProcessor): def test(self, parent, block): return False # never invoke this processor bp.CodeBlockProcessor = NoProcessing </code></pre> <p>There might be other Markdown libraries that more explicitly allow functionality to be disabled, but <code>python-markdown</code> looks like it is reasonably hackable.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload