Compare commits

..

2 commits

2 changed files with 14 additions and 14 deletions

View file

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

View file

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