Skip to content

Commit

Permalink
Eliminate empty control lines
Browse files Browse the repository at this point in the history
  • Loading branch information
silby committed Nov 1, 2024
1 parent f0c81a6 commit 051c41d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/Text/Pandoc/Readers/Mdoc/Lex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,19 @@ lexControlLine = do
pos <- getPosition
guard $ sourceColumn pos == 1
char '.'
m@(Macro name _) <- lexMacro
-- .Ns macros at the start of a line are ignored. We'd have to look behind
-- to keep track of the "start of the line" in the parser, so we'll drop
-- those macros in lexing.
let start | name == "Ns" = []
| otherwise = [m]
let parsed = isParsedMacro name
(wds, e) <- manyUntil (l parsed) eofline
return $ MdocTokens $ Seq.fromList $ start <> wds <> [e]
where
l True = try lexDelim <|> try lexCallableMacro <|> lexLit
l False = try lexDelim <|> lexLit
eofline *> mempty <|> do
m@(Macro name _) <- lexMacro
-- .Ns macros at the start of a line are ignored. We'd have to look behind
-- to keep track of the "start of the line" in the parser, so we'll drop
-- those macros in lexing.
let start | name == "Ns" = []
| otherwise = [m]
let parsed = isParsedMacro name
(wds, e) <- manyUntil (l parsed) eofline
return $ MdocTokens $ Seq.fromList $ start <> wds <> [e]
where
l True = try lexDelim <|> try lexCallableMacro <|> lexLit
l False = try lexDelim <|> lexLit

-- | Tokenize a string as a sequence of roff tokens.
lexMdoc :: PandocMonad m => SourcePos -> T.Text -> m MdocTokens
Expand Down

0 comments on commit 051c41d

Please # to comment.