Daniel Rikowski
Daniel Rikowski

Reputation: 72524

How can I add mutiple anchors to the same block?

I'm using AsciiDoctor to create an HTML manual. In order to keep existing links valid, I need multiple anchors at the same header.

Basically I want this output:

<a id="historic1"></a>
<a id="historic2"></a>
<h2 id="current">Caption</h2>

While it is possible to create multiple inline anchors like this

Inline [[historic1]] [[historic2]] [[current]] Anchor
Inline <a id="historic1"></a> <a id="historic2"></a> <a id="current"></a> Anchor

it looks like additional anchor macros in front of blocks are simply swallowed:

[[historic1]]
[[historic2]]
[[current]]
== Caption
<h2 id="current">Caption</h2>

So what are my options to have multiple anchors in front of a block?

Upvotes: 1

Views: 292

Answers (2)

Jmini
Jmini

Reputation: 9497

The best I could do (tested with Asciidoctor.js 1.5.4):

== anchor:historic1[historic1] anchor:historic2[historic2] anchor:current[current] Caption

Some text

Output:

<h2 id="__a_id_historic1_a_a_id_historic2_a_a_id_current_a_caption"><a id="historic1"></a> <a id="historic2"></a> <a id="current"></a> Caption</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Some text</p>
</div>
</div>

There are two issues:

Upvotes: 0

Dan Allen
Dan Allen

Reputation: 2478

You can also use the shorthand version of this solution.

[#current]
== [[historic1]][[historic2]]Caption

Now you get all three anchors on the same heading.

Upvotes: 3

Related Questions