Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """Replace $..$ by `$..$` and $$..$$ by `$$..$$`, but
- * Don't replace \$ (\ should escape)
- * Don't replace if one of the patterns above is in code blocks:
- ```
- ....
- ... $...$
- ```
- or
- {% highlight [some language] %}
- ...
- ... $...$
- {% endhighlight %}
- """
- import re
- # first two dollar signs environment
- content = re.sub(r'(?<![\\])\$\$([^\$]+)\$\$', "`\n$$\g<1>$$`", content)
- # then one dollar sign environment
- content = re.sub(r'(?<!\<span\>)(?<!\$)\$([^\$]+)\$', "`$\g<1>$`", content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement