git.iko.soy/typeable/pandoc
on master help sign in
Docbook5 writer: Properly handle ulink/link
commitfd36e6b64a516ffd281af0667afc6d9c00a70d64 authorIvo Clarysse <ivo@bcdevices.com> dateFri 29 Apr 2016, 16:06 (10 years ago) parent987ec3a
2 files changed+37−34
src/Text/Pandoc/Writers/Docbook.hs+3−1 tests/writer.docbook5+34−33
src/Text/Pandoc/Writers/Docbook.hs+3−1
@@ -351,7 +351,9 @@ inlineToDocbook opts (Link attr txt (src, _))
351351 | otherwise =
352352 (if isPrefixOf "#" src
353353 then inTags False "link" $ ("linkend", drop 1 src) : idAndRole attr
354− else inTags False "ulink" $ ("url", src) : idAndRole attr ) $
354+ else if writerDocbook5 opts
355+ then inTags False "link" $ ("xlink:href", src) : idAndRole attr
356+ else inTags False "ulink" $ ("url", src) : idAndRole attr ) $
355357 inlinesToDocbook opts txt
356358inlineToDocbook opts (Image attr _ (src, tit)) =
357359 let titleDoc = if null tit
tests/writer.docbook5+34−33
@@ -22,7 +22,8 @@
2222<section id="headers">
2323 <title>Headers</title>
2424 <section id="level-2-with-an-embedded-link">
25− <title>Level 2 with an <ulink url="/url">embedded link</ulink></title>
25+ <title>Level 2 with an <link xlink:href="/url">embedded
26+ link</link></title>
2627 <section id="level-3-with-emphasis">
2728 <title>Level 3 with <emphasis>emphasis</emphasis></title>
2829 <section id="level-4">
@@ -940,7 +941,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
940941 <emphasis role="strong">is this</emphasis>.
941942 </para>
942943 <para>
943− An <emphasis><ulink url="/url">emphasized link</ulink></emphasis>.
944+ An <emphasis><link xlink:href="/url">emphasized link</link></emphasis>.
944945 </para>
945946 <para>
946947 <emphasis role="strong"><emphasis>This is strong and
@@ -998,8 +999,8 @@ These should not be escaped: \$ \\ \&gt; \[ \{
998999 </para>
9991000 <para>
10001001 Here is some quoted <quote><literal>code</literal></quote> and a
1001− <quote><ulink url="http://example.com/?foo=1&amp;bar=2">quoted
1002− link</ulink></quote>.
1002+ <quote><link xlink:href="http://example.com/?foo=1&amp;bar=2">quoted
1003+ link</link></quote>.
10031004 </para>
10041005 <para>
10051006 Some dashes: one—two — three—four — five.
@@ -1188,58 +1189,58 @@ These should not be escaped: \$ \\ \&gt; \[ \{
11881189 <section id="explicit">
11891190 <title>Explicit</title>
11901191 <para>
1191− Just a <ulink url="/url/">URL</ulink>.
1192+ Just a <link xlink:href="/url/">URL</link>.
11921193 </para>
11931194 <para>
1194− <ulink url="/url/">URL and title</ulink>.
1195+ <link xlink:href="/url/">URL and title</link>.
11951196 </para>
11961197 <para>
1197− <ulink url="/url/">URL and title</ulink>.
1198+ <link xlink:href="/url/">URL and title</link>.
11981199 </para>
11991200 <para>
1200− <ulink url="/url/">URL and title</ulink>.
1201+ <link xlink:href="/url/">URL and title</link>.
12011202 </para>
12021203 <para>
1203− <ulink url="/url/">URL and title</ulink>
1204+ <link xlink:href="/url/">URL and title</link>
12041205 </para>
12051206 <para>
1206− <ulink url="/url/">URL and title</ulink>
1207+ <link xlink:href="/url/">URL and title</link>
12071208 </para>
12081209 <para>
1209− <ulink url="/url/with_underscore">with_underscore</ulink>
1210+ <link xlink:href="/url/with_underscore">with_underscore</link>
12101211 </para>
12111212 <para>
12121213 Email link (<email>nobody@nowhere.net</email>)
12131214 </para>
12141215 <para>
1215− <ulink url="">Empty</ulink>.
1216+ <link xlink:href="">Empty</link>.
12161217 </para>
12171218 </section>
12181219 <section id="reference">
12191220 <title>Reference</title>
12201221 <para>
1221− Foo <ulink url="/url/">bar</ulink>.
1222+ Foo <link xlink:href="/url/">bar</link>.
12221223 </para>
12231224 <para>
1224− Foo <ulink url="/url/">bar</ulink>.
1225+ Foo <link xlink:href="/url/">bar</link>.
12251226 </para>
12261227 <para>
1227− Foo <ulink url="/url/">bar</ulink>.
1228+ Foo <link xlink:href="/url/">bar</link>.
12281229 </para>
12291230 <para>
1230− With <ulink url="/url/">embedded [brackets]</ulink>.
1231+ With <link xlink:href="/url/">embedded [brackets]</link>.
12311232 </para>
12321233 <para>
1233− <ulink url="/url/">b</ulink> by itself should be a link.
1234+ <link xlink:href="/url/">b</link> by itself should be a link.
12341235 </para>
12351236 <para>
1236− Indented <ulink url="/url">once</ulink>.
1237+ Indented <link xlink:href="/url">once</link>.
12371238 </para>
12381239 <para>
1239− Indented <ulink url="/url">twice</ulink>.
1240+ Indented <link xlink:href="/url">twice</link>.
12401241 </para>
12411242 <para>
1242− Indented <ulink url="/url">thrice</ulink>.
1243+ Indented <link xlink:href="/url">thrice</link>.
12431244 </para>
12441245 <para>
12451246 This should [not][] be a link.
@@ -1248,35 +1249,35 @@ These should not be escaped: \$ \\ \&gt; \[ \{
12481249[not]: /url
12491250</programlisting>
12501251 <para>
1251− Foo <ulink url="/url/">bar</ulink>.
1252+ Foo <link xlink:href="/url/">bar</link>.
12521253 </para>
12531254 <para>
1254− Foo <ulink url="/url/">biz</ulink>.
1255+ Foo <link xlink:href="/url/">biz</link>.
12551256 </para>
12561257 </section>
12571258 <section id="with-ampersands">
12581259 <title>With ampersands</title>
12591260 <para>
1260− Here’s a <ulink url="http://example.com/?foo=1&amp;bar=2">link with an
1261− ampersand in the URL</ulink>.
1261+ Here’s a <link xlink:href="http://example.com/?foo=1&amp;bar=2">link
1262+ with an ampersand in the URL</link>.
12621263 </para>
12631264 <para>
12641265 Here’s a link with an amersand in the link text:
1265− <ulink url="http://att.com/">AT&amp;T</ulink>.
1266+ <link xlink:href="http://att.com/">AT&amp;T</link>.
12661267 </para>
12671268 <para>
1268− Here’s an <ulink url="/script?foo=1&amp;bar=2">inline link</ulink>.
1269+ Here’s an <link xlink:href="/script?foo=1&amp;bar=2">inline link</link>.
12691270 </para>
12701271 <para>
1271− Here’s an <ulink url="/script?foo=1&amp;bar=2">inline link in pointy
1272− braces</ulink>.
1272+ Here’s an <link xlink:href="/script?foo=1&amp;bar=2">inline link in
1273+ pointy braces</link>.
12731274 </para>
12741275 </section>
12751276 <section id="autolinks">
12761277 <title>Autolinks</title>
12771278 <para>
12781279 With an ampersand:
1279− <ulink url="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ulink>
1280+ <link xlink:href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</link>
12801281 </para>
12811282 <itemizedlist spacing="compact">
12821283 <listitem>
@@ -1286,7 +1287,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
12861287 </listitem>
12871288 <listitem>
12881289 <para>
1289− <ulink url="http://example.com/">http://example.com/</ulink>
1290+ <link xlink:href="http://example.com/">http://example.com/</link>
12901291 </para>
12911292 </listitem>
12921293 <listitem>
@@ -1301,7 +1302,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
13011302 <blockquote>
13021303 <para>
13031304 Blockquoted:
1304− <ulink url="http://example.com/">http://example.com/</ulink>
1305+ <link xlink:href="http://example.com/">http://example.com/</link>
13051306 </para>
13061307 </blockquote>
13071308 <para>
@@ -1362,8 +1363,8 @@ or here: &lt;http://example.com/&gt;
13621363 because it contains a space.[^my note] Here is an inline note.<footnote>
13631364 <para>
13641365 This is <emphasis>easier</emphasis> to type. Inline notes may contain
1365− <ulink url="http://google.com">links</ulink> and <literal>]</literal>
1366− verbatim characters, as well as [bracketed text].
1366+ <link xlink:href="http://google.com">links</link> and
1367+ <literal>]</literal> verbatim characters, as well as [bracketed text].
13671368 </para>
13681369 </footnote>
13691370 </para>