Login  Register

Re: Small changes to default HTML5 templates

Posted by mojavelinux on Apr 16, 2019; 8:28pm
URL: https://discuss.asciidoctor.org/Small-changes-to-default-HTML5-templates-tp6851p6855.html

Asciidoctor gives you lots of options for modifying the generated HTML (and supplementing it with additional CSS). One way is to use templates. As Mark points out, docinfo is another option.

The templates in https://github.com/asciidoctor/asciidoctor-backends are just meant to be a reference to get you started. You only need to use the templates for the nodes you want to change. If a template is missing, Asciidoctor falls back to the built-in HTML converter.

Another solution, new in Asciidoctor 2, is to override the converter directly. This is the same as using templates, but done in Ruby. For example, if you want to override the HTML for a paragraph, you can use:

class MyHtmlConverter < (Asciidoctor::Converter.for 'html5')
  register_for 'html5'
  def convert_paragraph node
    %(<p>#{node.content}</p>)
  end
end

Then just pass that script to the asciidoctor command using the -r option.

Best,

-Dan

On Tue, Apr 16, 2019 at 2:12 PM msc [via Asciidoctor :: Discussion] <[hidden email]> wrote:


On Apr 16, 2019, at 11:22, MattBlissett [via Asciidoctor :: Discussion] <[hidden email]> wrote:

What's the recommended way to make minor changes to the existing html5 template? 

I don’t know that it is recommended but my way is to put the modified styles in the docinfo.html file.

Regards

    -Mark




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Small-changes-to-default-HTML5-templates-tp6851p6854.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux