style(lexer): make binding naming consistent
This commit is contained in:
parent
326c7b681c
commit
29c015b793
2 changed files with 12 additions and 12 deletions
12
src/Lexer.hs
12
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 "\\#"
|
||||
|
|
|
|||
12
test/Spec.hs
12
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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue