Handle escaped $ in latex math. Closes #186.
This commit is contained in:
parent
9538328c6b
commit
328c91e307
1 changed files with 8 additions and 2 deletions
|
@ -136,6 +136,12 @@ mathDisplay p = displayMath <$> (try p >>= applyMacros' . trim)
|
|||
mathInline :: LP String -> LP Inlines
|
||||
mathInline p = math <$> (try p >>= applyMacros')
|
||||
|
||||
mathChars :: LP String
|
||||
mathChars = concat <$>
|
||||
many ( many1 (satisfy (\c -> c /= '$' && c /='\\'))
|
||||
<|> (\c -> ['\\',c]) <$> (try $ char '\\' *> anyChar)
|
||||
)
|
||||
|
||||
double_quote :: LP Inlines
|
||||
double_quote = (doubleQuoted . mconcat) <$>
|
||||
(try $ string "``" *> manyTill inline (try $ string "''"))
|
||||
|
@ -158,8 +164,8 @@ inline = (mempty <$ comment)
|
|||
<|> single_quote
|
||||
<|> (str "’" <$ char '\'')
|
||||
<|> (str "\160" <$ char '~')
|
||||
<|> (mathDisplay $ string "$$" *> manyTill anyChar (try $ string "$$"))
|
||||
<|> (mathInline $ char '$' *> manyTill anyChar (char '$'))
|
||||
<|> (mathDisplay $ string "$$" *> mathChars <* string "$$")
|
||||
<|> (mathInline $ char '$' *> mathChars <* char '$')
|
||||
<|> (superscript <$> (char '^' *> tok))
|
||||
<|> (subscript <$> (char '_' *> tok))
|
||||
<|> (failUnlessLHS *> char '|' *> doLHSverb)
|
||||
|
|
Loading…
Add table
Reference in a new issue