Header anchor format: #source-code vs #_source_code

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

Header anchor format: #source-code vs #_source_code

Jeremie Bresson
If we take the example-manual.adoc document [from the maven example repo (raw, source on GitHub, rendered with gist.asciidoctor.org)], I have noticed following difference:

Document compiled with maven:

[source,html]
----
<h2 id="source-code">Source Code</h2>
---

Document rendered with the browser live preview (Chrome or Firefox) or with gist.asciidoctor.org:

[source,html]
----
<h2 id="_source_code">Source Code</h2>
----

Why this inconsistency?

.
Reply | Threaded
Open this post in threaded view
|

Re: Header anchor format: #source-code vs #_source_code

mojavelinux
Administrator
Jeremie,

My guess is because in the Maven configuration, you have the idprefix and idseparator attributes defined (to blank and hyphen, respectively). I tend to set these two attributes this way because it forces Asciidoctor to generate ids that matches what is rendered on GitHub.*

The browser extensions don't set these by default. To make the rendering the same, I recommend setting them in the document (or not setting them in the Maven configuration).

Cheers,

-Dan


* Unfortunately, GitHub doesn't generate ids using Asciidoctor, so this is only a close approximation rather than an exact match. We are planning to resolve this mismatch eventually. For now, using idprefix and idseparator is a workable solution.

On Wed, Apr 22, 2015 at 5:27 AM, Jeremie Bresson [via Asciidoctor :: Discussion] <[hidden email]> wrote:
If we take the example-manual.adoc document [from the maven example repo (raw, source on GitHub, rendered with gist.asciidoctor.org)], I have noticed following difference:

Document compiled with maven:

[source,html]
----
<h2 id="source-code">Source Code</h2>
---

Document rendered with the browser live preview (Chrome or Firefox) or with gist.asciidoctor.org:

[source,html]
----
<h2 id="_source_code">Source Code</h2>
----

Why this inconsistency?

.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Header-anchor-format-source-code-vs-source-code-tp3014.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Header anchor format: #source-code vs #_source_code

Jeremie Bresson
Thanks for your answer.

Having those settings:

[source,asciidoc]
----
:idprefix:
:idseparator: -
----

in all documents is definitivelly a best practice.