diff --git a/src/Lexer.hs b/src/Lexer.hs index 436ebfe..b4ad0b8 100644 --- a/src/Lexer.hs +++ b/src/Lexer.hs @@ -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 diff --git a/test/Spec.hs b/test/Spec.hs index a09489e..656159e 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -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