From: Waylan L. <way...@ic...> - 2014-09-16 23:29:55
|
Guy, There are a few different approaches you could take. First, did you check that an extension doesn’t already exist that meets your needs? See the wiki: https://github.com/waylan/Python-Markdown/wiki/Third-Party-Extensions Or could you put your equations in `code spans`? If not, you could easily create your own extension using our extension API: https://pythonhosted.org/Markdown/extensions/api.html I expect you would be creating an inlinePattern. I would look at the `BacktickPattern` (which processes inline code) for guidance: https://github.com/waylan/Python-Markdown/blob/master/markdown/inlinepatterns.py#L256 The `BacktickPattern` just uses an `AtomicString` to tell markdown not to process the string any further. However, note that the entire string must be an Atomic string. So if your equation in imbedded in the middle of a paragraph with other markdown syntax, you would need to wrap your string in a tag (perhaps `<span>`) to preserve the AtomicString and allow the rest of the paragraph to be parsed as Markdown text. The following tutorials might be a gentler introduction to creating your own extensions: http://achinghead.com/python-markdown-adding-insert-delete.html http://achinghead.com/python-markdown-changing-bold-italics.html Hope that helps. Waylan From: Guy Rutenberg [mailto:guy...@gm...] Sent: Tuesday, September 16, 2014 4:01 PM To: pyt...@li... Subject: [Python-markdown-discuss] Treating anything between $ signs as raw text Hi, I want to use python-markdown together with MathJax (similar to the way equations are implemented in StackExchange sites). In order to do so, I need to make the parser keep everything between $ (dollar) signs as is, ignoring backspaces and other special characters. Is there a simple way to do it? Thanks, Guy ---- http://www.guyrutenberg.com |