Added anchors
This commit is contained in:
parent
7c4603528d
commit
fe930b2fec
2 changed files with 27 additions and 0 deletions
19
src/Lexer.hs
19
src/Lexer.hs
|
|
@ -83,6 +83,7 @@ lexText = go
|
||||||
, link
|
, link
|
||||||
, labeledLink
|
, labeledLink
|
||||||
, modules
|
, modules
|
||||||
|
, anchors
|
||||||
, textElement
|
, textElement
|
||||||
, quotes
|
, quotes
|
||||||
, birdTrack
|
, birdTrack
|
||||||
|
|
@ -161,6 +162,24 @@ header5 = delimitedMaybe (void $ "===== ") eol (Header Five) Nothing
|
||||||
header6 :: Lexer
|
header6 :: Lexer
|
||||||
header6 = delimitedMaybe (void $ "====== ") eol (Header Six) Nothing
|
header6 = delimitedMaybe (void $ "====== ") eol (Header Six) Nothing
|
||||||
|
|
||||||
|
-- #anchors#
|
||||||
|
anchors :: Lexer
|
||||||
|
anchors = do
|
||||||
|
pos <- getPosition
|
||||||
|
void $ try anchor'
|
||||||
|
pos' <- getPosition
|
||||||
|
txt <- anyUntil anchor'
|
||||||
|
pos'' <- getPosition
|
||||||
|
void $ try anchor'
|
||||||
|
|
||||||
|
pure
|
||||||
|
[ (pos, Anchor)
|
||||||
|
, (pos', Token txt)
|
||||||
|
, (pos'', Anchor)
|
||||||
|
]
|
||||||
|
where
|
||||||
|
anchor' = (string "#" <|> string "\\#")
|
||||||
|
|
||||||
-- "Module.Name"
|
-- "Module.Name"
|
||||||
-- "Module.Name#anchor"
|
-- "Module.Name#anchor"
|
||||||
-- "Module.Name#anchor"
|
-- "Module.Name#anchor"
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,14 @@ labeledLink =
|
||||||
, (1, 35, LabeledLinkClose)
|
, (1, 35, LabeledLinkClose)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
anchors :: Expectation
|
||||||
|
anchors =
|
||||||
|
"#myAnchor#"
|
||||||
|
`shouldLexTo` [ (1, 1, Anchor)
|
||||||
|
, (1, 2, Token "myAnchor")
|
||||||
|
, (1, 10, Anchor)
|
||||||
|
]
|
||||||
|
|
||||||
maths :: IO ()
|
maths :: IO ()
|
||||||
maths = do
|
maths = do
|
||||||
"\\[some math\\]"
|
"\\[some math\\]"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue