diff --git a/lib/asciidoctor/foodogsquared/converters/html5-extended.rb b/lib/asciidoctor/foodogsquared/converters/html5-extended.rb index 08300ee..2a34e98 100644 --- a/lib/asciidoctor/foodogsquared/converters/html5-extended.rb +++ b/lib/asciidoctor/foodogsquared/converters/html5-extended.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'nokogiri' require 'mime/types' module Asciidoctor::Foodogsquared::Converters @@ -11,29 +12,30 @@ module Asciidoctor::Foodogsquared::Converters # 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::Html5Extended + register_for 'html5' + def convert_paragraph(node) - attributes = html_attributes node + html = Nokogiri::XML::DocumentFragment.parse '
' + + paragraph = html.first_element_child + add_common_attributes node, paragraph if node.title? - <<~HTML -- #{node.captioned_title} - #{node.content} -
- HTML - else - <<~HTML -#{node.content}
- HTML + title = html.document.create_element 'strong', class: 'title' + title.content = node.captioned_title + paragraph.add_child title end + + paragraph.inner_html += node.content + html.to_html end - def html_attributes(node) - attributes = [] - attributes << %(id="#{node.id}") if node.id - attributes << %(class="#{node.role}") if node.role - attributes + def add_common_attributes(node, html) + html['id'] = node.id if node.id + html['class'] = node.role if node.role + + html end end end