DocBook reader: handle "book" for xref references

This also adds a test xref to book and part. See also 4ea0508e6 / #8712.
This commit is contained in:
Andres Freund
2023-03-21 20:47:45 -07:00
committed by John MacFarlane
parent 440b438158
commit 821cf3df4d
3 changed files with 64 additions and 4 deletions
+1
View File
@@ -1354,6 +1354,7 @@ parseInline (Elem e) =
xrefTitleByElem el
| not (T.null xrefLabel) = xrefLabel
| otherwise = case qName (elName el) of
"book" -> descendantContent "title" el
"part" -> descendantContent "title" el
"chapter" -> descendantContent "title" el
"section" -> descendantContent "title" el
+11 -1
View File
@@ -1,6 +1,6 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<book><title>An Example Book</title>
<book id='book01'><title>An Example Book</title>
<chapter id="ch01"><title>XRef Samples</title>
<para>
This paragraph demonstrates several features of
@@ -30,6 +30,12 @@ cross-reference text: <xref linkend="ch02"/>.
<listitem><para>A link to a
<sgmltag>table</sgmltag> element: <xref linkend="table01"/>.
</para></listitem>
<listitem><para>A link to a
<sgmltag>part</sgmltag> element: <xref linkend="part01"/>.
</para></listitem>
<listitem><para>A link to a
<sgmltag>book</sgmltag> element: <xref linkend="book01"/>.
</para></listitem>
</itemizedlist>
</chapter>
@@ -38,6 +44,9 @@ cross-reference text: <xref linkend="ch02"/>.
<para>Some content here</para>
</chapter>
<part id="part01">
<title>Later Part</title>
<chapter id="ch03" xreflabel="Chapter the Third">
<title>The Third Chapter</title>
<para>Some content here</para>
@@ -101,4 +110,5 @@ cross-reference text: <xref linkend="ch02"/>.
</table>
</chapter>
</part>
</book>
+52 -3
View File
@@ -14,7 +14,7 @@ Pandoc
]
}
[ Header
1
2
( "ch01" , [] , [] )
[ Str "XRef" , Space , Str "Samples" ]
, Para
@@ -195,21 +195,70 @@ Pandoc
, Str "."
]
]
, [ Para
[ Str "A"
, Space
, Str "link"
, Space
, Str "to"
, Space
, Str "a"
, SoftBreak
, Str "part"
, Space
, Str "element:"
, Space
, Link
( "" , [] , [] )
[ Str "Later" , Space , Str "Part" ]
( "#part01" , "" )
, Str "."
]
]
, [ Para
[ Str "A"
, Space
, Str "link"
, Space
, Str "to"
, Space
, Str "a"
, SoftBreak
, Str "book"
, Space
, Str "element:"
, Space
, Link
( "" , [] , [] )
[ Str "An"
, Space
, Str "Example"
, Space
, Str "Book"
]
( "#book01" , "" )
, Str "."
]
]
]
, Header
1
2
( "ch02" , [] , [] )
[ Str "The" , Space , Str "Second" , Space , Str "Chapter" ]
, Para
[ Str "Some" , Space , Str "content" , Space , Str "here" ]
, Header
1
( "part01" , [] , [] )
[ Str "Later" , Space , Str "Part" ]
, Header
2
( "ch03" , [] , [] )
[ Str "The" , Space , Str "Third" , Space , Str "Chapter" ]
, Para
[ Str "Some" , Space , Str "content" , Space , Str "here" ]
, Header
1
2
( "ch04" , [] , [ ( "titleabbrev" , "Chapter 4" ) ] )
[ Str "The" , Space , Str "Fourth" , Space , Str "Chapter" ]
, Para