From 821cf3df4df695d4bb8f8659a85993033939e860 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Tue, 21 Mar 2023 20:47:45 -0700 Subject: [PATCH] DocBook reader: handle "book" for xref references This also adds a test xref to book and part. See also 4ea0508e6 / #8712. --- src/Text/Pandoc/Readers/DocBook.hs | 1 + test/docbook-xref.docbook | 12 ++++++- test/docbook-xref.native | 55 ++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index a0fdfa319..56fc0dc4c 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -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 diff --git a/test/docbook-xref.docbook b/test/docbook-xref.docbook index 624b4c081..87aaf86c6 100644 --- a/test/docbook-xref.docbook +++ b/test/docbook-xref.docbook @@ -1,6 +1,6 @@ -An Example Book +An Example Book XRef Samples This paragraph demonstrates several features of @@ -30,6 +30,12 @@ cross-reference text: . A link to a table element: . +A link to a +part element: . + +A link to a +book element: . + @@ -38,6 +44,9 @@ cross-reference text: . Some content here + + Later Part + The Third Chapter Some content here @@ -101,4 +110,5 @@ cross-reference text: . + diff --git a/test/docbook-xref.native b/test/docbook-xref.native index 8025f698b..dedd7bfc5 100644 --- a/test/docbook-xref.native +++ b/test/docbook-xref.native @@ -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