Re: Printing the id of a block
Posted by
mojavelinux on
Apr 22, 2020; 10:51pm
URL: https://discuss.asciidoctor.org/Printing-the-id-of-a-block-tp7943p7947.html
Daniel,
To activate attribute references inside a verbatim block, you must apply incremental subs to the block:
[subs=attributes+]
The ID of the block cannot be referenced using an attribute reference. However, you may define the ID using a document attribute, then assign it to the block ID (so the other way around)
:block-id: foobar
[id={block-id},subs=attributes+]
----
{block-id}
----
Best Regards,
-Dan
On Wed, Apr 22, 2020 at 5:46 AM Daniel K [via Asciidoctor :: Discussion] <
[hidden email]> wrote:
Hi all,
we are using blocks with ids as follows:
[#blockid,role="highlightedblock"]
:myattribute: myvalue
--
Text in block
{myattribute}
--
It is possible to print out the value of a defined attribute.
Is it somehow possible to print the id of the current block itself?
The Id shall be shown in the HTML and PDF output.
For HTML, we currently using a workaround with CSS:
.highlightedblock::before {content: "[" attr(id) "]"; margin-right: 1em; font-weight: bold}
This is not a very nice solution since it does not work with the PDF output. Moreover, in HTML it is not part of the DOM tree.
Does somebody see any solution to solve this issue?
Thanks!
--