orchidhq / Orchid

Build and deploy beautiful documentation sites that grow with you
https://orchid.run
GNU General Public License v3.0
514 stars 53 forks source link

Usage of internal links in AsciiDoc #303

Closed zambrovski closed 5 years ago

zambrovski commented 5 years ago

I'm trying to use internal links inside of asciidoc wiki pages. Is there any way to do so?

{{ anchor('Some Page Title') }}

works perfect in a Markdown file and the resulting HTML contains the correct link. If used in the AsciiDoc file, the plugin generates the <a href="correct-url">Some Page Title</a> in content (escaped characters &lt; and &gt; instead of < and >) instead of a link.

Any ideas?

cjbrooks12 commented 5 years ago

It looks like Asciidoctor escapes raw HTML by default for safety. The {{ anchor(...) }} function is precompiled into that content, so it is evaluated before the document is transformed as Asciidoc to the final HTML. This means it adds raw HTML to the document before Asciidoctor processes it, which goes on to escape it.

You can use any of the following syntaxes around the {{ ... }} tags to make Asciidoc pass it through:

++++
{{ anchor('Some Page Title') }}
++++

+++{{ anchor('Some Page Title') }}+++

pass:[{{ anchor('Some Page Title') }}]

See Asciidoc reference for inline passthrough and passthrough blocks