Re: Custom style on title/heading element?

Posted by mojavelinux on
URL: https://discuss.asciidoctor.org/Solved-Custom-style-on-title-heading-element-tp4543p4545.html

Section titles support roles just like all blocks.

thoraxe wrote:
[.category-title]
=== Title

This is the correct syntax. It generates the following HTML:

<div class="sect2 category-title">
<h3 id="_title">Title</h3>
</div>

By default, the HTML converter wraps the section in a div. That's where the role goes. To style it, you'd use:

.category-title > h3 {
  ...
}

or

.sect2.category-title > h3 {
  ...
}

If you want to change how the HTML is generated, you need to use a custom template, in this case for section (e.g., section.html.slim). Here's an example: https://github.com/asciidoctor/asciidoctor-backends/blob/master/slim/html5/section.html.slim.

More information about custom templates can be found in the following issue: https://github.com/asciidoctor/asciidoctor.org/issues/80

Cheers,

-Dan

--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen