From 5cb366fb2a69cdbb1e9f6db780e6ce7e58b44c26 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Thu, 16 Nov 2023 19:40:15 +0800 Subject: [PATCH] Add modified version of built-in HTML5 converter --- .../converters/html5-extended.rb | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/asciidoctor/foodogsquared/converters/html5-extended.rb diff --git a/lib/asciidoctor/foodogsquared/converters/html5-extended.rb b/lib/asciidoctor/foodogsquared/converters/html5-extended.rb new file mode 100644 index 0000000..64de4cc --- /dev/null +++ b/lib/asciidoctor/foodogsquared/converters/html5-extended.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'mime/types' + +module Asciidoctor::Foodogsquared::Converters + # A modified version of the built-in HTML5 converter. This is separated with + # the default project converter that should only contain new blocks to + # prevent overriding the converter that most likely going to trip up the + # user. + # + # Take note this is only intended for the author. The user has to explicitly + # require them somewhere to make use of this. + class HTML5Modified < Asciidoctor::Foodogsquared::Converter + def convert_paragraph(node) + attributes = html_attributes node + + if node.title? + <<~HTML + + #{node.captioned_title} + #{node.content} +

+ HTML + else + <<~HTML + #{node.content}

+ HTML + end + end + + def html_attributes(node) + attributes = [] + attributes << %(id="#{node.id}") if node.id + attributes << %(class="#{node.role}") if node.role + + attributes + end + end +end