elastic / docs

246 stars 334 forks source link

Fix support for linkattrs #726

Open lcawl opened 5 years ago

lcawl commented 5 years ago

Per https://github.com/elastic/docs/issues/505#issuecomment-459163236, I would like to use the linkattrs functionality described here:

https://asciidoctor.org/docs/asciidoc-writers-guide/#target-window-and-role-attributes-for-links

When I try any of the examples there in the Glossary, for example:

== Introduction

:linkattrs:

Chat with other Asciidoctor users on the http://discuss.asciidoctor.org/[*mailing list*^, role="green"].

the attributes are not recognized. They're output as:

<a class="ulink" href="http://discuss.asciidoctor.org/" target="_top"><span class="strong strong"><strong>mailing list</strong></span>^, role="green"</a>

nik9000 commented 5 years ago

I dug into this. It doesn't work for a whole stack of reasons:

  1. Docbook 4.5 doesn't support it. Docbook 5 might, I'm not sure.
  2. We force compat-mode on all of the documents. We probably shouldn't but we do. That seem like a thing for another time though. When we're in compat-mode we can't use linkatts.

We should fix compat-mode. Beyond that, though, we probably won't be able to use these until we take another look at docbook.

nik9000 commented 5 years ago

I filed #728 for us to get off compat-mode.

lcawl commented 5 years ago

You're right, it works when I disable compat-mode, enable linkattrs and use a default Asciidoctor -> HTML build. It does not seem to work with docbook or docbook5

asciidoctor index.asciidoc -b docbook45 yields:

<simpara>Chat with other Asciidoctor users on the <ulink url="http://discuss.asciidoctor.org/"><emphasis role="strong">mailing list</emphasis></ulink>.</simpara>

asciidoctor index.asciidoc -b docbook5 yields:

<simpara>Chat with other Asciidoctor users on the <link xl:href="http://discuss.asciidoctor.org/"><emphasis role="strong">mailing list</emphasis></link>.</simpara>

asciidoctor index.asciidoc -b html and -b xhtml yield:

<p>Chat with other Asciidoctor users on the <a href="http://discuss.asciidoctor.org/" class="green" target="_blank" rel="noopener"><strong>mailing list</strong></a>.</p>