xrefs and pdf generation of modular doc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

xrefs and pdf generation of modular doc

jbazik
I have a large document that exists in many separate files (with many authors).  I am targeting both html and pdf output and I'm using both asciidoc and asciidoctor toolchains.  I like the flexibility and ease of using xrefs (<<>>) to link both within and across files, as described in the asciidoctor docs.  I did not realize these would not validate when generating pdf.  (I generate modular html and monolithic pdf.)

In particular, <<myfile#mysection,mylabel>> breaks xml when I use a2x to generate pdf.

* Is there a workaround using a2x?

* Will this work using asciidoctor-pdf?

* Should I take a different approach?

John
Reply | Threaded
Open this post in threaded view
|

Re: xrefs and pdf generation of modular doc

jbazik
So, I worked around this with the following asciidoc config:

[xref2-inlinemacro]
<link linkend="{eval: "{1}".endswith('#') and "{1}".lstrip('/').rstrip('#').replace('/','-') + '-top' or '#' in "{1}" and "{1}".split('#')[1] or "{1}" }">{2}</link>
{2%}<xref linkend="{eval: "{1}".endswith('#') and "{1}".lstrip('/').rstrip('#').replace('/','-') + '-top' or '#' in "{1}" and "{1}".split('#')[1] or "{1}" }"/>

It assumes a [[foo-bar-baz-top]] id is inserted before each include::/foo/bar/baz.adoc[], and does this:

<</foo/bar/baz#,label>>  ->  linkend="foo-bar-baz-top"
<</foo/bar/baz#myanchor,label>>  -> linkend="myanchor"
<<myanchor>>  ->  linkend="myanchor"

John