require "fileutils"
require "base64"
module IsoDoc
module HtmlFunction
module Html
def convert1(docxml, filename, dir)
noko do |xml|
xml.html lang: @lang.to_s do |html|
info docxml, nil
populate_css
html.head { |head| define_head head, filename, dir }
make_body(html, docxml)
end
end.join("\n")
end
def preprocess_xslt(docxml)
super
end
def make_body1(body, _docxml)
return if @bare
body.div class: "title-section" do |div1|
div1.p { |p| p << " " } # placeholder
end
section_break(body)
end
def make_body2(body, _docxml)
return if @bare
body.div class: "prefatory-section" do |div2|
div2.p { |p| p << " " } # placeholder
end
section_break(body)
end
def googlefonts
<<~HEAD.freeze
HEAD
end
def html_head
<<~HEAD.freeze
#{@meta&.get&.dig(:doctitle)}
#{googlefonts}
HEAD
end
def html_button
return "" if @bare
''.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 sourcecode_parse(node, out)
name = node.at(ns("./name"))
tag = node.at(ns(".//sourcecode | .//table")) ? "div" : "pre"
attr = sourcecode_attrs(node).merge(class: "sourcecode")
out.send tag, **attr do |div|
sourcecode_parse1(node, div)
end
annotation_parse(node, out)
sourcecode_name_parse(node, out, name)
end
def underline_parse(node, out)
style = node["style"] ? " #{node['style']}" : ""
attr = { style: "text-decoration: underline#{style}" }
out.span **attr do |e|
node.children.each { |n| parse(n, e) }
end
end
def table_attrs(node)
ret = super
node.at(ns("./colgroup")) and ret[:style] += "table-layout:fixed;"
ret
end
def image_parse(node, out, caption)
if svg = node.at("./m:svg", "m" => "http://www.w3.org/2000/svg")
svg_parse(svg, out)
return
end
super
end
end
end
end