aggsol
aggsol

Reputation: 2480

How to add custom data attributes with Asciidoctor?

I want to annotate paragraphs and the resulting HTML to have custom data attributes like this:

<div class="paragraph" data-progress="23">
<p>Lorem ipsum dolor sit</p>
</div>

I could extend the class attribute like this:

=== 5
[.progress=23]
Lorem ipsum dolor sit

But this approach is not for key value pairs. The result would look like this:

<div class="paragraph progress=23">
<p>Lorem ipsum dolor sit</p>
</div>

What is the recommended way to annotate or add meta data with Asciidoc or Asciidoctor?

Upvotes: 0

Views: 1017

Answers (1)

Mike Scotty
Mike Scotty

Reputation: 10782

There's currently no built-in support for data attributes.

Right now you have to customize the converter (either by making a custom converter or using custom templates).

There's an open issue to add support for data- attributes in core.

See https://github.com/asciidoctor/asciidoctor/issues/1305

-- mojavelinux, May 03, 2017; 10:14am

Source: http://discuss.asciidoctor.org/Passing-data-html-attributes-to-a-code-block-tp5414p5562.html

Upvotes: 1

Related Questions