forked from elland/haddock2
ref(lexer): simplify anchor
This commit is contained in:
parent
064e253f03
commit
c956c97e0c
1 changed files with 7 additions and 9 deletions
16
src/Lexer.hs
16
src/Lexer.hs
|
|
@ -152,6 +152,9 @@ delimitedSymmetric s t1 t2 = delimited s s t1 t2
|
|||
eol :: Parser ()
|
||||
eol = void "\n" <|> void "\r\n" <|> Parsec.eof
|
||||
|
||||
anchorHash :: Parser Text
|
||||
anchorHash = "#" <|> try "\\#"
|
||||
|
||||
header1 :: Lexer
|
||||
header1 = delimitedNoTrailing "= " eol (Header One)
|
||||
|
||||
|
|
@ -172,15 +175,10 @@ header6 = delimitedNoTrailing "====== " eol (Header Six)
|
|||
|
||||
-- #anchors#
|
||||
anchors :: Lexer
|
||||
anchors = do
|
||||
pos <- getPosition
|
||||
void $ try anchor'
|
||||
txt <- anyUntil anchor'
|
||||
void $ try anchor'
|
||||
|
||||
pure [(pos, Anchor txt)]
|
||||
where
|
||||
anchor' = (string "#" <|> string "\\#")
|
||||
anchors =
|
||||
tokenise
|
||||
[ between anchorHash anchorHash (Anchor <$> anyUntil anchorHash)
|
||||
]
|
||||
|
||||
-- "Module.Name"
|
||||
-- "Module.Name#anchor"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue