Advertisement
themoosemind

LaTeX fix for Jekyll

Jan 7th, 2014
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1.     """Replace $..$ by `$..$` and $$..$$ by `$$..$$`, but
  2.        * Don't replace \$ (\ should escape)
  3.        * Don't replace if one of the patterns above is in code blocks:
  4.            ```
  5.            ....
  6.            ...   $...$
  7.            ```
  8.          or
  9.            {% highlight [some language] %}
  10.            ...
  11.            ...  $...$
  12.            {% endhighlight %}
  13.    """
  14.     import re
  15.     # first two dollar signs environment
  16.     content = re.sub(r'(?<![\\])\$\$([^\$]+)\$\$', "`\n$$\g<1>$$`", content)
  17.     # then one dollar sign environment
  18.     content = re.sub(r'(?<!\<span\>)(?<!\$)\$([^\$]+)\$', "`$\g<1>$`", content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement