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