git.iko.soy/typeable/pandoc
on master help sign in
Ms writer: changed some names and comments, man -> ms.
9945f91John MacFarlane
src/Text/Pandoc/Writers/Ms.hs+10−10
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 Stability : alpha
25 Stability : alpha
26 Portability : portable
26 Portability : portable
27
27
28−Conversion of 'Pandoc' documents to groff man page format.
28+Conversion of 'Pandoc' documents to groff ms format.
29
29
30TODO:
30TODO:
31
31
@@ -99,7 +99,7 @@ writeMs :: PandocMonad m => WriterOptions -> Pandoc -> m String
99writeMs opts document =
99writeMs opts document =
100 evalStateT (pandocToMs opts document) defaultWriterState
100 evalStateT (pandocToMs opts document) defaultWriterState
101
101
102−-- | Return groff man representation of document.
102+-- | Return groff ms representation of document.
103pandocToMs :: PandocMonad m => WriterOptions -> Pandoc -> MS m String
103pandocToMs :: PandocMonad m => WriterOptions -> Pandoc -> MS m String
104pandocToMs opts (Pandoc meta blocks) = do
104pandocToMs opts (Pandoc meta blocks) = do
105 let colwidth = if writerWrapText opts == WrapAuto
105 let colwidth = if writerWrapText opts == WrapAuto
@@ -139,8 +139,8 @@ pandocToMs opts (Pandoc meta blocks) = do
139 Just tpl -> return $ renderTemplate' tpl context
139 Just tpl -> return $ renderTemplate' tpl context
140
140
141-- | Association list of characters to escape.
141-- | Association list of characters to escape.
142−manEscapes :: Map.Map Char String
142+msEscapes :: Map.Map Char String
143−manEscapes = Map.fromList $
143+msEscapes = Map.fromList $
144 [ ('\160', "\\ ")
144 [ ('\160', "\\ ")
145 , ('\'', "\\[aq]")
145 , ('\'', "\\[aq]")
146 , ('’', "'")
146 , ('’', "'")
@@ -155,7 +155,7 @@ manEscapes = Map.fromList $
155 ]
155 ]
156
156
157escapeChar :: Char -> String
157escapeChar :: Char -> String
158−escapeChar c = case Map.lookup c manEscapes of
158+escapeChar c = case Map.lookup c msEscapes of
159 Just s -> s
159 Just s -> s
160 Nothing -> [c]
160 Nothing -> [c]
161
161
@@ -298,7 +298,7 @@ blockToMs opts (DefinitionList items) = do
298 contents <- mapM (definitionListItemToMs opts) items
298 contents <- mapM (definitionListItemToMs opts) items
299 return (vcat contents)
299 return (vcat contents)
300
300
301−-- | Convert bullet list item (list of blocks) to man.
301+-- | Convert bullet list item (list of blocks) to ms.
302bulletListItemToMs :: PandocMonad m => WriterOptions -> [Block] -> MS m Doc
302bulletListItemToMs :: PandocMonad m => WriterOptions -> [Block] -> MS m Doc
303bulletListItemToMs _ [] = return empty
303bulletListItemToMs _ [] = return empty
304bulletListItemToMs opts ((Para first):rest) =
304bulletListItemToMs opts ((Para first):rest) =
@@ -316,7 +316,7 @@ bulletListItemToMs opts (first:rest) = do
316 rest' <- blockListToMs opts rest
316 rest' <- blockListToMs opts rest
317 return $ text "\\[bu] .RS 2" $$ first' $$ rest' $$ text ".RE"
317 return $ text "\\[bu] .RS 2" $$ first' $$ rest' $$ text ".RE"
318
318
319−-- | Convert ordered list item (a list of blocks) to man.
319+-- | Convert ordered list item (a list of blocks) to ms.
320orderedListItemToMs :: PandocMonad m
320orderedListItemToMs :: PandocMonad m
321 => WriterOptions -- ^ options
321 => WriterOptions -- ^ options
322 -> String -- ^ order marker for list item
322 -> String -- ^ order marker for list item
@@ -336,7 +336,7 @@ orderedListItemToMs opts num indent (first:rest) = do
336 else text ".RS 4" $$ rest' $$ text ".RE"
336 else text ".RS 4" $$ rest' $$ text ".RE"
337 return $ first'' $$ rest''
337 return $ first'' $$ rest''
338
338
339−-- | Convert definition list item (label, list of blocks) to man.
339+-- | Convert definition list item (label, list of blocks) to ms.
340definitionListItemToMs :: PandocMonad m
340definitionListItemToMs :: PandocMonad m
341 => WriterOptions
341 => WriterOptions
342 -> ([Inline],[[Block]])
342 -> ([Inline],[[Block]])
@@ -356,7 +356,7 @@ definitionListItemToMs opts (label, defs) = do
356 return $ first' $$ text ".RS" $$ rest' $$ text ".RE"
356 return $ first' $$ text ".RS" $$ rest' $$ text ".RE"
357 return $ nowrap (text ".IP \"" <> labelText <> text "\"") $$ contents
357 return $ nowrap (text ".IP \"" <> labelText <> text "\"") $$ contents
358
358
359−-- | Convert list of Pandoc block elements to man.
359+-- | Convert list of Pandoc block elements to ms.
360blockListToMs :: PandocMonad m
360blockListToMs :: PandocMonad m
361 => WriterOptions -- ^ Options
361 => WriterOptions -- ^ Options
362 -> [Block] -- ^ List of block elements
362 -> [Block] -- ^ List of block elements
@@ -380,7 +380,7 @@ inlineListToMs' opts lst = do
380 y <- handleNotes opts empty
380 y <- handleNotes opts empty
381 return $ x <> y
381 return $ x <> y
382
382
383−-- | Convert Pandoc inline element to man.
383+-- | Convert Pandoc inline element to ms.
384inlineToMs :: PandocMonad m => WriterOptions -> Inline -> MS m Doc
384inlineToMs :: PandocMonad m => WriterOptions -> Inline -> MS m Doc
385inlineToMs opts (Span _ ils) = inlineListToMs opts ils
385inlineToMs opts (Span _ ils) = inlineListToMs opts ils
386inlineToMs opts (Emph lst) =
386inlineToMs opts (Emph lst) =