git.iko.soy/typeable/pandoc
on master help sign in
DocBook reader: get string content in inner tags for literal elements.

Closes #1816.

commitc350847943fe8e879b4c9a909a9c5c801db62eaf authorJohn MacFarlane <jgm@berkeley.edu> dateSun 14 Dec 2014, 19:12 (12 years ago) parent9e83cd6
1 file changed+9−6
src/Text/Pandoc/Readers/DocBook.hs+9−6
src/Text/Pandoc/Readers/DocBook.hs+9−6
@@ -773,11 +773,6 @@ parseBlock (Elem e) =
773773 x -> [x]
774774 return $ codeBlockWith (attrValue "id" e, classes', [])
775775 $ trimNl $ strContentRecursive e
776− strContentRecursive = strContent . (\e' -> e'{ elContent =
777− map elementToStr $ elContent e' })
778− elementToStr :: Content -> Content
779− elementToStr (Elem e') = Text $ CData CDataText (strContentRecursive e') Nothing
780− elementToStr x = x
781776 parseBlockquote = do
782777 attrib <- case filterChild (named "attribution") e of
783778 Nothing -> return mempty
@@ -880,6 +875,14 @@ parseBlock (Elem e) =
880875getInlines :: Element -> DB Inlines
881876getInlines e' = (trimInlines . mconcat) <$> (mapM parseInline $ elContent e')
882877
878+strContentRecursive :: Element -> String
879+strContentRecursive = strContent .
880+ (\e' -> e'{ elContent = map elementToStr $ elContent e' })
881+
882+elementToStr :: Content -> Content
883+elementToStr (Elem e') = Text $ CData CDataText (strContentRecursive e') Nothing
884+elementToStr x = x
885+
883886parseInline :: Content -> DB Inlines
884887parseInline (Text (CData _ s _)) = return $ text s
885888parseInline (CRef ref) =
@@ -964,7 +967,7 @@ parseInline (Elem e) =
964967 let classes' = case attrValue "language" e of
965968 "" -> []
966969 l -> [l]
967− return $ codeWith (attrValue "id" e,classes',[]) $ strContent e
970+ return $ codeWith (attrValue "id" e,classes',[]) $ strContentRecursive e
968971 simpleList = (mconcat . intersperse (str "," <> space)) <$> mapM getInlines
969972 (filterChildren (named "member") e)
970973 segmentedList = do