Docbook5 writer: Properly handle ulink/link

This commit is contained in:
Ivo Clarysse 2016-04-29 16:06:55 -07:00
parent 987ec3a752
commit fd36e6b64a
2 changed files with 37 additions and 34 deletions

View file

@ -351,7 +351,9 @@ inlineToDocbook opts (Link attr txt (src, _))
| otherwise = | otherwise =
(if isPrefixOf "#" src (if isPrefixOf "#" src
then inTags False "link" $ ("linkend", drop 1 src) : idAndRole attr then inTags False "link" $ ("linkend", drop 1 src) : idAndRole attr
else inTags False "ulink" $ ("url", src) : idAndRole attr ) $ else if writerDocbook5 opts
then inTags False "link" $ ("xlink:href", src) : idAndRole attr
else inTags False "ulink" $ ("url", src) : idAndRole attr ) $
inlinesToDocbook opts txt inlinesToDocbook opts txt
inlineToDocbook opts (Image attr _ (src, tit)) = inlineToDocbook opts (Image attr _ (src, tit)) =
let titleDoc = if null tit let titleDoc = if null tit

View file

@ -22,7 +22,8 @@
<section id="headers"> <section id="headers">
<title>Headers</title> <title>Headers</title>
<section id="level-2-with-an-embedded-link"> <section id="level-2-with-an-embedded-link">
<title>Level 2 with an <ulink url="/url">embedded link</ulink></title> <title>Level 2 with an <link xlink:href="/url">embedded
link</link></title>
<section id="level-3-with-emphasis"> <section id="level-3-with-emphasis">
<title>Level 3 with <emphasis>emphasis</emphasis></title> <title>Level 3 with <emphasis>emphasis</emphasis></title>
<section id="level-4"> <section id="level-4">
@ -940,7 +941,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<emphasis role="strong">is this</emphasis>. <emphasis role="strong">is this</emphasis>.
</para> </para>
<para> <para>
An <emphasis><ulink url="/url">emphasized link</ulink></emphasis>. An <emphasis><link xlink:href="/url">emphasized link</link></emphasis>.
</para> </para>
<para> <para>
<emphasis role="strong"><emphasis>This is strong and <emphasis role="strong"><emphasis>This is strong and
@ -998,8 +999,8 @@ These should not be escaped: \$ \\ \&gt; \[ \{
</para> </para>
<para> <para>
Here is some quoted <quote><literal>code</literal></quote> and a Here is some quoted <quote><literal>code</literal></quote> and a
<quote><ulink url="http://example.com/?foo=1&amp;bar=2">quoted <quote><link xlink:href="http://example.com/?foo=1&amp;bar=2">quoted
link</ulink></quote>. link</link></quote>.
</para> </para>
<para> <para>
Some dashes: one—two — three—four — five. Some dashes: one—two — three—four — five.
@ -1188,58 +1189,58 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<section id="explicit"> <section id="explicit">
<title>Explicit</title> <title>Explicit</title>
<para> <para>
Just a <ulink url="/url/">URL</ulink>. Just a <link xlink:href="/url/">URL</link>.
</para> </para>
<para> <para>
<ulink url="/url/">URL and title</ulink>. <link xlink:href="/url/">URL and title</link>.
</para> </para>
<para> <para>
<ulink url="/url/">URL and title</ulink>. <link xlink:href="/url/">URL and title</link>.
</para> </para>
<para> <para>
<ulink url="/url/">URL and title</ulink>. <link xlink:href="/url/">URL and title</link>.
</para> </para>
<para> <para>
<ulink url="/url/">URL and title</ulink> <link xlink:href="/url/">URL and title</link>
</para> </para>
<para> <para>
<ulink url="/url/">URL and title</ulink> <link xlink:href="/url/">URL and title</link>
</para> </para>
<para> <para>
<ulink url="/url/with_underscore">with_underscore</ulink> <link xlink:href="/url/with_underscore">with_underscore</link>
</para> </para>
<para> <para>
Email link (<email>nobody@nowhere.net</email>) Email link (<email>nobody@nowhere.net</email>)
</para> </para>
<para> <para>
<ulink url="">Empty</ulink>. <link xlink:href="">Empty</link>.
</para> </para>
</section> </section>
<section id="reference"> <section id="reference">
<title>Reference</title> <title>Reference</title>
<para> <para>
Foo <ulink url="/url/">bar</ulink>. Foo <link xlink:href="/url/">bar</link>.
</para> </para>
<para> <para>
Foo <ulink url="/url/">bar</ulink>. Foo <link xlink:href="/url/">bar</link>.
</para> </para>
<para> <para>
Foo <ulink url="/url/">bar</ulink>. Foo <link xlink:href="/url/">bar</link>.
</para> </para>
<para> <para>
With <ulink url="/url/">embedded [brackets]</ulink>. With <link xlink:href="/url/">embedded [brackets]</link>.
</para> </para>
<para> <para>
<ulink url="/url/">b</ulink> by itself should be a link. <link xlink:href="/url/">b</link> by itself should be a link.
</para> </para>
<para> <para>
Indented <ulink url="/url">once</ulink>. Indented <link xlink:href="/url">once</link>.
</para> </para>
<para> <para>
Indented <ulink url="/url">twice</ulink>. Indented <link xlink:href="/url">twice</link>.
</para> </para>
<para> <para>
Indented <ulink url="/url">thrice</ulink>. Indented <link xlink:href="/url">thrice</link>.
</para> </para>
<para> <para>
This should [not][] be a link. This should [not][] be a link.
@ -1248,35 +1249,35 @@ These should not be escaped: \$ \\ \&gt; \[ \{
[not]: /url [not]: /url
</programlisting> </programlisting>
<para> <para>
Foo <ulink url="/url/">bar</ulink>. Foo <link xlink:href="/url/">bar</link>.
</para> </para>
<para> <para>
Foo <ulink url="/url/">biz</ulink>. Foo <link xlink:href="/url/">biz</link>.
</para> </para>
</section> </section>
<section id="with-ampersands"> <section id="with-ampersands">
<title>With ampersands</title> <title>With ampersands</title>
<para> <para>
Heres a <ulink url="http://example.com/?foo=1&amp;bar=2">link with an Heres a <link xlink:href="http://example.com/?foo=1&amp;bar=2">link
ampersand in the URL</ulink>. with an ampersand in the URL</link>.
</para> </para>
<para> <para>
Heres a link with an amersand in the link text: Heres a link with an amersand in the link text:
<ulink url="http://att.com/">AT&amp;T</ulink>. <link xlink:href="http://att.com/">AT&amp;T</link>.
</para> </para>
<para> <para>
Heres an <ulink url="/script?foo=1&amp;bar=2">inline link</ulink>. Heres an <link xlink:href="/script?foo=1&amp;bar=2">inline link</link>.
</para> </para>
<para> <para>
Heres an <ulink url="/script?foo=1&amp;bar=2">inline link in pointy Heres an <link xlink:href="/script?foo=1&amp;bar=2">inline link in
braces</ulink>. pointy braces</link>.
</para> </para>
</section> </section>
<section id="autolinks"> <section id="autolinks">
<title>Autolinks</title> <title>Autolinks</title>
<para> <para>
With an ampersand: With an ampersand:
<ulink url="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ulink> <link xlink:href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</link>
</para> </para>
<itemizedlist spacing="compact"> <itemizedlist spacing="compact">
<listitem> <listitem>
@ -1286,7 +1287,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<ulink url="http://example.com/">http://example.com/</ulink> <link xlink:href="http://example.com/">http://example.com/</link>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
@ -1301,7 +1302,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<blockquote> <blockquote>
<para> <para>
Blockquoted: Blockquoted:
<ulink url="http://example.com/">http://example.com/</ulink> <link xlink:href="http://example.com/">http://example.com/</link>
</para> </para>
</blockquote> </blockquote>
<para> <para>
@ -1362,8 +1363,8 @@ or here: &lt;http://example.com/&gt;
because it contains a space.[^my note] Here is an inline note.<footnote> because it contains a space.[^my note] Here is an inline note.<footnote>
<para> <para>
This is <emphasis>easier</emphasis> to type. Inline notes may contain This is <emphasis>easier</emphasis> to type. Inline notes may contain
<ulink url="http://google.com">links</ulink> and <literal>]</literal> <link xlink:href="http://google.com">links</link> and
verbatim characters, as well as [bracketed text]. <literal>]</literal> verbatim characters, as well as [bracketed text].
</para> </para>
</footnote> </footnote>
</para> </para>