require "fileutils"
require "base64"
module IsoDoc::HtmlFunction
module Html
def make_body1(body, _docxml)
body.div **{ class: "title-section" } do |div1|
div1.p { |p| p << " " } # placeholder
end
section_break(body)
end
def make_body2(body, docxml)
body.div **{ class: "prefatory-section" } do |div2|
div2.p { |p| p << " " } # placeholder
end
section_break(body)
end
def make_body3(body, docxml)
body.div **{ class: "main-section" } do |div3|
boilerplate docxml, div3
abstract docxml, div3
foreword docxml, div3
introduction docxml, div3
middle docxml, div3
footnotes div3
comments div3
end
end
def googlefonts()
<<~HEAD.freeze
HEAD
end
def html_head()
<<~HEAD.freeze
#{@meta&.get&.dig(:doctitle)}
#{googlefonts}
HEAD
end
def html_button()
''.freeze
end
def html_main(docxml)
docxml.at("//head").add_child(html_head())
d = docxml.at('//div[@class="main-section"]')
d.name = "main"
d.children.empty? or d.children.first.previous = html_button()
end
def sourcecodelang(lang)
return unless lang
case lang.downcase
when "javascript" then "lang-js"
when "c" then "lang-c"
when "c+" then "lang-cpp"
when "console" then "lang-bsh"
when "ruby" then "lang-rb"
when "html" then "lang-html"
when "java" then "lang-java"
when "xml" then "lang-xml"
when "perl" then "lang-perl"
when "python" then "lang-py"
when "xsl" then "lang-xsl"
else
""
end
end
def sourcecode_parse(node, out)
name = node.at(ns("./name"))
class1 = "prettyprint #{sourcecodelang(node&.at(ns('./@lang'))&.value)}"
out.pre **attr_code(id: node["id"], class: class1) do |div|
@sourcecode = true
node.children.each { |n| parse(n, div) unless n.name == "name" }
@sourcecode = false
end
sourcecode_name_parse(node, out, name)
end
end
end