forked from elland/haddock2
Compare commits
No commits in common. "bd07547e26b167f1907cbcb66ea39e9d6fb346ec" and "f3b3b08919662479df126597446738e0fb92ef6d" have entirely different histories.
bd07547e26
...
f3b3b08919
2 changed files with 14 additions and 14 deletions
20
src/Lexer.hs
20
src/Lexer.hs
|
|
@ -51,10 +51,10 @@ data Token
|
|||
| ParenClose
|
||||
| BracketOpen
|
||||
| BracketClose
|
||||
| MathInlineOpen
|
||||
| MathInlineClose
|
||||
| MathsMultilineOpen
|
||||
| MathsMultilineClose
|
||||
| MathsParenOpen
|
||||
| MathsParenClose
|
||||
| MathsBracketOpen
|
||||
| MathsBracketClose
|
||||
| NumericEntity Int
|
||||
| Module Text
|
||||
| QuoteOpen
|
||||
|
|
@ -85,8 +85,8 @@ lexText = go
|
|||
toks <-
|
||||
choice $
|
||||
Parsec.try
|
||||
<$> [ mathMultiline
|
||||
, mathInline
|
||||
<$> [ mathsBracket
|
||||
, mathsParens
|
||||
, escape -- maths go before escape to avoid mismatch
|
||||
, headers
|
||||
, newlineToken
|
||||
|
|
@ -242,11 +242,11 @@ labeledLink = do
|
|||
, (pos8, LabeledLinkClose)
|
||||
]
|
||||
|
||||
mathMultiline :: Lexer
|
||||
mathMultiline = delimited "\\[" "\\]" MathsMultilineOpen MathsMultilineClose
|
||||
mathsBracket :: Lexer
|
||||
mathsBracket = delimited "\\[" "\\]" MathsBracketOpen MathsBracketClose
|
||||
|
||||
mathInline :: Lexer
|
||||
mathInline = delimited "\\(" "\\)" MathInlineOpen MathInlineClose
|
||||
mathsParens :: Lexer
|
||||
mathsParens = delimited "\\(" "\\)" MathsParenOpen MathsParenClose
|
||||
|
||||
birdTrack :: Lexer
|
||||
birdTrack = delimitedNoTrailing ">> " eol BirdTrack
|
||||
|
|
|
|||
|
|
@ -93,14 +93,14 @@ anchors =
|
|||
maths :: IO ()
|
||||
maths = do
|
||||
"\\[some math\\]"
|
||||
`shouldLexTo` [ (1, 1, MathsMultilineOpen)
|
||||
`shouldLexTo` [ (1, 1, MathsBracketOpen)
|
||||
, (1, 3, Token "some math")
|
||||
, (1, 12, MathsMultilineClose)
|
||||
, (1, 12, MathsBracketClose)
|
||||
]
|
||||
"\\(other maths\\)"
|
||||
`shouldLexTo` [ (1, 1, MathInlineOpen)
|
||||
`shouldLexTo` [ (1, 1, MathsParenOpen)
|
||||
, (1, 3, Token "other maths")
|
||||
, (1, 14, MathInlineClose)
|
||||
, (1, 14, MathsParenClose)
|
||||
]
|
||||
|
||||
escaping :: Expectation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue