git.iko.soy/typeable/pandoc
on master help sign in
Fixed xref lookup in DocBook reader. Closes #3243.

It previously only worked when the qnames lacked the docbook namespace URI.

commite4798a6726e417decb959c86dae7545ab6c8522d authorJohn MacFarlane <jgm@berkeley.edu> dateSat 19 Nov 2016, 10:30 (10 years ago) parent1a8af5f
2 files changed+9−7
src/Text/Pandoc/Readers/DocBook.hs+6−4 tests/docbook-xref.native+3−3
src/Text/Pandoc/Readers/DocBook.hs+6−4
@@ -964,9 +964,11 @@ parseInline (Elem e) =
964964 content <- dbContent <$> get
965965 let linkend = attrValue "linkend" e
966966 let title = case attrValue "endterm" e of
967− "" -> maybe "???" xrefTitleByElem (findElementById linkend content)
968− endterm -> maybe "???" strContent (findElementById endterm content)
969− return $ link ('#' : linkend) "" (singleton (Str title))
967+ "" -> maybe "???" xrefTitleByElem
968+ (findElementById linkend content)
969+ endterm -> maybe "???" strContent
970+ (findElementById endterm content)
971+ return $ link ('#' : linkend) "" (text title)
970972 "email" -> return $ link ("mailto:" ++ strContent e) ""
971973 $ str $ strContent e
972974 "uri" -> return $ link (strContent e) "" $ str $ strContent e
@@ -1050,4 +1052,4 @@ parseInline (Elem e) =
10501052 where
10511053 xrefLabel = attrValue "xreflabel" el
10521054 descendantContent name = maybe "???" strContent
1053− . findElement (QName name Nothing Nothing)
1055+ . filterElementName (\n -> qName n == name)
tests/docbook-xref.native+3−3
@@ -2,9 +2,9 @@ Pandoc (Meta {unMeta = fromList []})
22[Header 1 ("ch01",[],[]) [Str "XRef",Space,Str "Samples"]
33,Para [Str "This",Space,Str "paragraph",Space,Str "demonstrates",Space,Str "several",Space,Str "features",Space,Str "of",SoftBreak,Str "XRef."]
44,BulletList
5− [[Para [Str "A",Space,Str "straight",Space,Str "link",Space,Str "generates",Space,Str "the",SoftBreak,Str "cross-reference",Space,Str "text:",Space,Link ("",[],[]) [Str "The Second Chapter"] ("#ch02",""),Str "."]]
6− ,[Para [Str "A",Space,Str "link",Space,Str "to",Space,Str "an",Space,Str "element",Space,Str "with",Space,Str "an",SoftBreak,Str "XRefLabel:",SoftBreak,Link ("",[],[]) [Str "Chapter the Third"] ("#ch03",""),Str "."]]
7− ,[Para [Str "A",Space,Str "link",Space,Str "with",Space,Str "an",SoftBreak,Str "EndTerm:",SoftBreak,Link ("",[],[]) [Str "Chapter 4"] ("#ch04",""),Str "."]]
5+ [[Para [Str "A",Space,Str "straight",Space,Str "link",Space,Str "generates",Space,Str "the",SoftBreak,Str "cross-reference",Space,Str "text:",Space,Link ("",[],[]) [Str "The",Space,Str "Second",Space,Str "Chapter"] ("#ch02",""),Str "."]]
6+ ,[Para [Str "A",Space,Str "link",Space,Str "to",Space,Str "an",Space,Str "element",Space,Str "with",Space,Str "an",SoftBreak,Str "XRefLabel:",SoftBreak,Link ("",[],[]) [Str "Chapter",Space,Str "the",Space,Str "Third"] ("#ch03",""),Str "."]]
7+ ,[Para [Str "A",Space,Str "link",Space,Str "with",Space,Str "an",SoftBreak,Str "EndTerm:",SoftBreak,Link ("",[],[]) [Str "Chapter",Space,Str "4"] ("#ch04",""),Str "."]]
88 ,[Para [Str "A",Space,Str "link",Space,Str "to",Space,Str "an",SoftBreak,Str "cmdsynopsis",Space,Str "element:",Space,Link ("",[],[]) [Str "chgrp"] ("#cmd01",""),Str "."]]
99 ,[Para [Str "A",Space,Str "link",Space,Str "to",Space,Str "an",SoftBreak,Str "funcsynopsis",Space,Str "element:",Space,Link ("",[],[]) [Str "max"] ("#func01",""),Str "."]]]
1010,Header 1 ("ch02",[],[]) [Str "The",Space,Str "Second",Space,Str "Chapter"]