Compare commits

...

2 commits

2 changed files with 14 additions and 14 deletions

View file

@ -51,10 +51,10 @@ data Token
| ParenClose | ParenClose
| BracketOpen | BracketOpen
| BracketClose | BracketClose
| MathsParenOpen | MathInlineOpen
| MathsParenClose | MathInlineClose
| MathsBracketOpen | MathsMultilineOpen
| MathsBracketClose | MathsMultilineClose
| NumericEntity Int | NumericEntity Int
| Module Text | Module Text
| QuoteOpen | QuoteOpen
@ -85,8 +85,8 @@ lexText = go
toks <- toks <-
choice $ choice $
Parsec.try Parsec.try
<$> [ mathsBracket <$> [ mathMultiline
, mathsParens , mathInline
, escape -- maths go before escape to avoid mismatch , escape -- maths go before escape to avoid mismatch
, headers , headers
, newlineToken , newlineToken
@ -242,11 +242,11 @@ labeledLink = do
, (pos8, LabeledLinkClose) , (pos8, LabeledLinkClose)
] ]
mathsBracket :: Lexer mathMultiline :: Lexer
mathsBracket = delimited "\\[" "\\]" MathsBracketOpen MathsBracketClose mathMultiline = delimited "\\[" "\\]" MathsMultilineOpen MathsMultilineClose
mathsParens :: Lexer mathInline :: Lexer
mathsParens = delimited "\\(" "\\)" MathsParenOpen MathsParenClose mathInline = delimited "\\(" "\\)" MathInlineOpen MathInlineClose
birdTrack :: Lexer birdTrack :: Lexer
birdTrack = delimitedNoTrailing ">> " eol BirdTrack birdTrack = delimitedNoTrailing ">> " eol BirdTrack

View file

@ -93,14 +93,14 @@ anchors =
maths :: IO () maths :: IO ()
maths = do maths = do
"\\[some math\\]" "\\[some math\\]"
`shouldLexTo` [ (1, 1, MathsBracketOpen) `shouldLexTo` [ (1, 1, MathsMultilineOpen)
, (1, 3, Token "some math") , (1, 3, Token "some math")
, (1, 12, MathsBracketClose) , (1, 12, MathsMultilineClose)
] ]
"\\(other maths\\)" "\\(other maths\\)"
`shouldLexTo` [ (1, 1, MathsParenOpen) `shouldLexTo` [ (1, 1, MathInlineOpen)
, (1, 3, Token "other maths") , (1, 3, Token "other maths")
, (1, 14, MathsParenClose) , (1, 14, MathInlineClose)
] ]
escaping :: Expectation escaping :: Expectation