git.iko.soy/typeable/pandoc
on master help sign in
DocBook: support segmentedlist.
commita5f71e5fad45e2daaae8e8dcf509a937bdb8ed73 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 12 May 2012, 18:34 (14 years ago) parent6dfaf43
1 file changed+17−4
src/Text/Pandoc/Readers/DocBook.hs+17−4
src/Text/Pandoc/Readers/DocBook.hs+17−4
@@ -378,10 +378,10 @@ List of all DocBook tags, with [x] indicating implemented,
378378 in the index
379379[ ] seealsoie - A See also entry in an index, rather than in the text
380380[ ] seeie - A See entry in an index, rather than in the text
381−[ ] seg - An element of a list item in a segmented list
382−[ ] seglistitem - A list item in a segmented list
383−[ ] segmentedlist - A segmented list, a list of sets of elements
384−[ ] segtitle - The title of an element of a list item in a segmented list
381+[x] seg - An element of a list item in a segmented list
382+[x] seglistitem - A list item in a segmented list
383+[x] segmentedlist - A segmented list, a list of sets of elements
384+[x] segtitle - The title of an element of a list item in a segmented list
385385[ ] seriesvolnums - Numbers of the volumes in a series of books
386386[ ] set - A collection of books
387387[ ] setindex - An index to a set of books
@@ -840,6 +840,7 @@ parseInline (Elem e) =
840840 then singleQuoted contents
841841 else doubleQuoted contents
842842 "simplelist" -> simpleList
843+ "segmentedlist" -> segmentedList
843844 "code" -> codeWithLang
844845 "filename" -> codeWithLang
845846 "literal" -> codeWithLang
@@ -888,3 +889,15 @@ parseInline (Elem e) =
888889 return $ codeWith (attrValue "id" e,classes',[]) $ strContent e
889890 simpleList = (mconcat . intersperse (str "," <> space)) <$> mapM getInlines
890891 (filterChildren (named "member") e)
892+ segmentedList = do
893+ tit <- maybe (return mempty) getInlines $ filterChild (named "title") e
894+ segtits <- mapM getInlines $ filterChildren (named "segtitle") e
895+ segitems <- mapM (mapM getInlines . filterChildren (named "seg"))
896+ $ filterChildren (named "seglistitem") e
897+ let toSeg = mconcat . zipWith (\x y -> strong (x <> str ":") <> space <>
898+ y <> linebreak) segtits
899+ let segs = mconcat $ map toSeg segitems
900+ let tit' = if tit == mempty
901+ then mempty
902+ else strong tit <> linebreak
903+ return $ linebreak <> tit' <> segs