Skip to content

Commit

Permalink
fixed <xref> references to tables in DocBook files
Browse files Browse the repository at this point in the history
Closes #8626.
  • Loading branch information
Pavol Otto authored and jgm committed Feb 15, 2023
1 parent 5889d70 commit da9c196
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Text/Pandoc/Readers/DocBook.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,7 @@ parseInline (Elem e) =
"cmdsynopsis" -> descendantContent "command" el
"funcsynopsis" -> descendantContent "function" el
"figure" -> descendantContent "title" el
"table" -> descendantContent "title" el
_ -> qName (elName el) <> "_title"
where
xrefLabel = attrValue "xreflabel" el
Expand Down
23 changes: 23 additions & 0 deletions test/docbook-xref.docbook
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ cross-reference text: <xref linkend="ch02"/>.
<listitem><para>A link to a
<sgmltag>figure</sgmltag> element: <xref linkend="fig01"/>.
</para></listitem>
<listitem><para>A link to a
<sgmltag>table</sgmltag> element: <xref linkend="table01"/>.
</para></listitem>
</itemizedlist>
</chapter>

Expand Down Expand Up @@ -77,5 +80,25 @@ cross-reference text: <xref linkend="ch02"/>.
</mediaobject>
</figure>

<table id="table01" frame="all" rowsep="1" colsep="1">
<title>Supported features by version</title>
<tgroup cols="2">
<colspec colname="col_1" colwidth="50*"/>
<colspec colname="col_2" colwidth="50*"/>
<thead>
<row>
<entry>Version</entry>
<entry>Feat</entry>
</row>
</thead>
<tbody>
<row>
<entry>Free</entry>
<entry>no</entry>
</row>
</tbody>
</tgroup>
</table>

</chapter>
</book>
84 changes: 84 additions & 0 deletions test/docbook-xref.native
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,33 @@ Pandoc
, Str "."
]
]
, [ Para
[ Str "A"
, Space
, Str "link"
, Space
, Str "to"
, Space
, Str "a"
, SoftBreak
, Str "table"
, Space
, Str "element:"
, Space
, Link
( "" , [] , [] )
[ Str "Supported"
, Space
, Str "features"
, Space
, Str "by"
, Space
, Str "version"
]
( "#table01" , "" )
, Str "."
]
]
]
, Header
1
Expand Down Expand Up @@ -214,4 +241,61 @@ Pandoc
]
( "figures/pythag.png" , "fig:" )
]
, Table
( "" , [] , [] )
(Caption
Nothing
[ Plain
[ Str "Supported"
, Space
, Str "features"
, Space
, Str "by"
, Space
, Str "version"
]
])
[ ( AlignDefault , ColWidth 0.5 )
, ( AlignDefault , ColWidth 0.5 )
]
(TableHead
( "" , [] , [] )
[ Row
( "" , [] , [] )
[ Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "Version" ] ]
, Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "Feat" ] ]
]
])
[ TableBody
( "" , [] , [] )
(RowHeadColumns 0)
[]
[ Row
( "" , [] , [] )
[ Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "Free" ] ]
, Cell
( "" , [] , [] )
AlignDefault
(RowSpan 1)
(ColSpan 1)
[ Plain [ Str "no" ] ]
]
]
]
(TableFoot ( "" , [] , [] ) [])
]

0 comments on commit da9c196

Please sign in to comment.