From 29c015b79310aa4ecd6a51f9b895ad5910bb2766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 24 Sep 2025 22:22:00 +0800 Subject: [PATCH] style(lexer): make binding naming consistent --- src/Lexer.hs | 12 ++++++------ test/Spec.hs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Lexer.hs b/src/Lexer.hs index 9b33f03..c44c0e4 100644 --- a/src/Lexer.hs +++ b/src/Lexer.hs @@ -93,7 +93,7 @@ lexText = go , spaceToken , link , labeledLink - , modules + , module_ , anchor , textElement , quotes @@ -189,15 +189,15 @@ identifierChar = satisfy (\c -> isAlphaNum c || c == '_') -- "Module.Name" -- "Module.Name#anchor" -- "Module.Name\#anchor" -- known as "old anchor". this has been deprecated for 9 years, thanks Ben -modules :: Lexer -modules = between (char '"') (char '"') inner +module_ :: Lexer +module_ = between (char '"') (char '"') inner where inner = do - module_ <- located $ Module <$> moduleNames + m <- located $ Module <$> moduleNames mAnchor <- optionMaybe (located $ anchorHash *> (Anchor <$> anchorText)) pure $ case mAnchor of - Just anchor -> [module_, anchor] - Nothing -> [module_] + Just anc -> [m, anc] + Nothing -> [m] anchorHash :: Parser Text anchorHash = "#" <|> try "\\#" diff --git a/test/Spec.hs b/test/Spec.hs index 7ddbcff..745aefa 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -19,8 +19,8 @@ main = hspec $ do describe "minimal" do it "handles unicode" unicode it "escapes" escaping - it "maths" maths - it "anchors" anchors + it "maths" math + it "anchors" anchor it "space chars" space it "bare string" someString it "emphasis" emphatic @@ -84,14 +84,14 @@ labeledLink = , (1, 35, LabeledLinkClose) ] -anchors :: Expectation -anchors = +anchor :: Expectation +anchor = "#myAnchor#" `shouldLexTo` [ (1, 1, Anchor "myAnchor") ] -maths :: IO () -maths = do +math :: IO () +math = do "\\[some math\\]" `shouldLexTo` [ (1, 1, MathMultilineOpen) , (1, 3, Token "some math")