git.iko.soy/typeable/pandoc
on master help sign in
Added support for definition lists to RST writer.
09fa7e6fiddlosopher
src/Text/Pandoc/Writers/RST.hs+10
@@ -185,6 +185,9 @@ blockToRST opts (OrderedList items) = do
185 contents <- mapM (\(item, num) -> orderedListItemToRST opts item num) $
185 contents <- mapM (\(item, num) -> orderedListItemToRST opts item num) $
186 zip [1..] items
186 zip [1..] items
187 return $ (vcat contents) <> text "\n"
187 return $ (vcat contents) <> text "\n"
188+blockToRST opts (DefinitionList items) = do
189+ contents <- mapM (definitionListItemToRST opts) items
190+ return $ (vcat contents) <> text "\n"
188
191
189-- | Convert bullet list item (list of blocks) to RST.
192-- | Convert bullet list item (list of blocks) to RST.
190bulletListItemToRST :: WriterOptions -> [Block] -> State WriterState Doc
193bulletListItemToRST :: WriterOptions -> [Block] -> State WriterState Doc
@@ -203,6 +206,13 @@ orderedListItemToRST opts num items = do
203 return $ hang (text ((show num) ++ "." ++ spacer)) (writerTabStop opts)
206 return $ hang (text ((show num) ++ "." ++ spacer)) (writerTabStop opts)
204 contents
207 contents
205
208
209+-- | Convert defintion list item (label, list of blocks) to RST.
210+definitionListItemToRST :: WriterOptions -> ([Inline], [Block]) -> State WriterState Doc
211+definitionListItemToRST opts (label, items) = do
212+ label <- inlineListToRST opts label
213+ contents <- blockListToRST opts items
214+ return $ label $+$ nest (writerTabStop opts) contents
215+
206-- | Convert list of Pandoc block elements to RST.
216-- | Convert list of Pandoc block elements to RST.
207blockListToRST :: WriterOptions -- ^ Options
217blockListToRST :: WriterOptions -- ^ Options
208 -> [Block] -- ^ List of block elements
218 -> [Block] -- ^ List of block elements