aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Roff.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-30 17:43:51 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-30 17:43:51 -0700
commitc46593304c8eec00c250b8c31bc066e534ecfbcd (patch)
tree34f3e76cf98ce01b13b053752db09cc39711a8e1 /src/Text/Pandoc/Readers/Roff.hs
parente9130b8e52d01ebbc157f26ecdc4f3d81b0f2e9b (diff)
downloadpandoc-c46593304c8eec00c250b8c31bc066e534ecfbcd.tar.gz
Roff reader: renamed constructors for RoffToken...
to more closely match nomenclature from man 7 groff.
Diffstat (limited to 'src/Text/Pandoc/Readers/Roff.hs')
-rw-r--r--src/Text/Pandoc/Readers/Roff.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/Roff.hs b/src/Text/Pandoc/Readers/Roff.hs
index b1011c2d3..df39c429e 100644
--- a/src/Text/Pandoc/Readers/Roff.hs
+++ b/src/Text/Pandoc/Readers/Roff.hs
@@ -101,10 +101,10 @@ data CellFormat =
type TableRow = ([CellFormat], [RoffTokens])
-data RoffToken = MLine [LinePart]
- | MEmptyLine
- | MMacro String [Arg] SourcePos
- | MTable [TableOption] [TableRow] SourcePos
+data RoffToken = RoffTextLine [LinePart]
+ | RoffEmptyLine
+ | RoffControlLine String [Arg] SourcePos
+ | RoffTable [TableOption] [TableRow] SourcePos
deriving Show
newtype RoffTokens = RoffTokens { unRoffTokens :: Seq.Seq RoffToken }
@@ -128,7 +128,7 @@ instance Default RoffState where
def = RoffState { customMacros = M.fromList
$ map (\(n, s) ->
(n, singleTok
- (MLine [RoffStr s])))
+ (RoffTextLine [RoffStr s])))
[ ("Tm", "\x2122")
, ("lq", "\x201C")
, ("rq", "\x201D")
@@ -370,7 +370,7 @@ lexMacro = do
"de1" -> lexMacroDef args
"ds" -> lexStringDef args
"ds1" -> lexStringDef args
- "sp" -> return $ singleTok MEmptyLine
+ "sp" -> return $ singleTok RoffEmptyLine
"so" -> lexIncludeFile args
_ -> resolveMacro macroName args pos
@@ -394,7 +394,7 @@ lexTable pos = do
string ".TE"
skipMany spacetab
eofline
- return $ singleTok $ MTable opts (rows ++ concat morerows) pos
+ return $ singleTok $ RoffTable opts (rows ++ concat morerows) pos
lexTableRows :: PandocMonad m => RoffLexer m [TableRow]
lexTableRows = do
@@ -531,15 +531,15 @@ resolveMacro :: PandocMonad m
resolveMacro macroName args pos = do
macros <- customMacros <$> getState
case M.lookup macroName macros of
- Nothing -> return $ singleTok $ MMacro macroName args pos
+ Nothing -> return $ singleTok $ RoffControlLine macroName args pos
Just ts -> do
let fillLP (MacroArg i) zs =
case drop (i - 1) args of
[] -> zs
(ys:_) -> ys ++ zs
fillLP z zs = z : zs
- let fillMacroArg (MLine lineparts) =
- MLine (foldr fillLP [] lineparts)
+ let fillMacroArg (RoffTextLine lineparts) =
+ RoffTextLine (foldr fillLP [] lineparts)
fillMacroArg x = x
return $ RoffTokens . fmap fillMacroArg . unRoffTokens $ ts
@@ -548,7 +548,7 @@ lexStringDef args = do -- string definition
case args of
[] -> fail "No argument to .ds"
(x:ys) -> do
- let ts = singleTok $ MLine (intercalate [RoffStr " " ] ys)
+ let ts = singleTok $ RoffTextLine (intercalate [RoffStr " " ] ys)
let stringName = linePartsToString x
modifyState $ \st ->
st{ customMacros = M.insert stringName ts (customMacros st) }
@@ -631,7 +631,7 @@ escString = try $ do
resolveString stringname pos = do
RoffTokens ts <- resolveMacro stringname [] pos
case Foldable.toList ts of
- [MLine xs] -> return xs
+ [RoffTextLine xs] -> return xs
_ -> do
report $ SkippedContent ("unknown string " ++ stringname) pos
return mempty
@@ -649,7 +649,7 @@ lexLine = do
-- this can happen if the line just contains \f[C], for example.
go [] = return mempty
go (RoffStr "" : xs) = go xs
- go xs = return $ singleTok $ MLine xs
+ go xs = return $ singleTok $ RoffTextLine xs
linePart :: PandocMonad m => RoffLexer m [LinePart]
linePart = macroArg <|> escape <|>
@@ -694,7 +694,7 @@ spaceTabChar = do
return [RoffStr [c]]
lexEmptyLine :: PandocMonad m => RoffLexer m RoffTokens
-lexEmptyLine = newline >> return (singleTok MEmptyLine)
+lexEmptyLine = newline >> return (singleTok RoffEmptyLine)
manToken :: PandocMonad m => RoffLexer m RoffTokens
manToken = lexComment <|> lexMacro <|> lexLine <|> lexEmptyLine