DocBook reader: Better handle elements inside code environments.

Of course, we can't include structure in the code block, but
this way we at least preserve the text.  Closes #1449.
This commit is contained in:
John MacFarlane 2014-07-23 10:06:36 -07:00
parent 5089bc8fe2
commit 9c3f7688ee
3 changed files with 10 additions and 1 deletions

View file

@ -769,7 +769,12 @@ parseBlock (Elem e) =
"" -> []
x -> [x]
return $ codeBlockWith (attrValue "id" e, classes', [])
$ trimNl $ strContent e
$ trimNl $ strContentRecursive e
strContentRecursive = strContent . (\e' -> e'{ elContent =
map elementToStr $ elContent e' })
elementToStr :: Content -> Content
elementToStr (Elem e') = Text $ CData CDataText (strContentRecursive e') Nothing
elementToStr x = x
parseBlockquote = do
attrib <- case filterChild (named "attribution") e of
Nothing -> return mempty

View file

@ -89,6 +89,9 @@ sub status {
print &quot;working&quot;;
}
</programlisting>
<screen>
% <command>ls</command>
</screen>
<para>
A list:
</para>

View file

@ -23,6 +23,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,BlockQuote
[Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
,CodeBlock ("",[],[]) "% ls"
,Para [Str "A",Space,Str "list:"]
,OrderedList (1,Decimal,DefaultDelim)
[[Para [Str "item",Space,Str "one"]]