diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-21 22:00:08 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-21 22:00:50 -0700 |
commit | 382763a7db3f886a598f87b770e9923a2c8b4454 (patch) | |
tree | c8d97c062c81efa65a17874d90bff04382267f3d /src/Text | |
parent | 00f1f4a220f870046ca4d257baf0e8f8e0e221e0 (diff) | |
download | pandoc-382763a7db3f886a598f87b770e9923a2c8b4454.tar.gz |
Man reader: support .ds, .ds1; also fix macro arguments.
Closes #4997.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/Man.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index 30e66acf1..c3ca1b76e 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -273,6 +273,8 @@ lexMacro = do "\\\"" -> return mempty "\\#" -> return mempty "de" -> lexMacroDef args + "ds" -> lexStringDef args + "ds1" -> lexStringDef args "sp" -> return $ singleTok MEmptyLine "so" -> lexIncludeFile args _ -> resolveMacro macroName args @@ -309,6 +311,17 @@ resolveMacro macroName args = do fillMacroArg x = x return $ ManTokens . fmap fillMacroArg . unManTokens $ ts +lexStringDef :: PandocMonad m => [Arg] -> ManLexer m ManTokens +lexStringDef args = do -- string definition + case args of + [] -> fail "No argument to .ds" + (x:ys) -> do + let ts = singleTok $ MLine (intercalate [RoffStr (" ", mempty)] ys) + let stringName = linePartsToString x + modifyState $ \st -> + st{ customMacros = M.insert stringName ts (customMacros st) } + return mempty + lexMacroDef :: PandocMonad m => [Arg] -> ManLexer m ManTokens lexMacroDef args = do -- macro definition (macroName, stopMacro) <- @@ -410,8 +423,7 @@ linePart = macroArg <|> esc <|> escStar <|> macroArg :: PandocMonad m => ManLexer m [LinePart] macroArg = try $ do - char '\\' - char '$' + string "\\\\$" x <- digit return [MacroArg $ ord x - ord '0'] |