Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Jul 22, 2024
1 parent a1838b8 commit cfb96ef
Show file tree
Hide file tree
Showing 28 changed files with 682 additions and 680 deletions.
1 change: 1 addition & 0 deletions isodoc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "sassc", "~> 2.4.0"
spec.add_development_dependency "simplecov", "~> 0.15"
spec.add_development_dependency "timecop", "~> 0.9"
spec.add_development_dependency "xml-c14n"
# spec.metadata["rubygems_mfa_required"] = "true"
end
24 changes: 10 additions & 14 deletions lib/isodoc/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def l10n(expr, lang = @lang, script = @script, locale = @locale)
end

def initialize(lang, script, locale, i18n, fonts_options = {})
@metadata = { lang: lang, script: script }
@metadata = { lang:, script: }
DATETYPES.each { |w| @metadata["#{w.gsub('-', '_')}date".to_sym] = "XXX" }
@lang = lang
@script = script
Expand All @@ -29,10 +29,6 @@ def get
@metadata
end

def labels
@labels
end

def set(key, value)
@metadata[key] = value
end
Expand All @@ -44,12 +40,12 @@ def currlang
end

def doctype(isoxml, _out)
b = isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}"))&.text || return
set(:doctype, status_print(b))
b1 = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}"))&.text || b
set(:doctype_display, status_print(b1))
b = isoxml&.at(ns("//bibdata/ext/subdoctype#{NOLANG}"))&.text || return
set(:subdoctype, status_print(b))
b = isoxml.at(ns("//bibdata/ext/doctype#{NOLANG}")) || return
set(:doctype, status_print(b.text))
b1 = isoxml.at(ns("//bibdata/ext/doctype#{currlang}")) || b
set(:doctype_display, status_print(b1.text))
b = isoxml.at(ns("//bibdata/ext/subdoctype#{NOLANG}")) || return
set(:subdoctype, status_print(b.text))
end

def docstatus(xml, _out)
Expand All @@ -59,11 +55,11 @@ def docstatus(xml, _out)
s1 = xml.at(ns("//bibdata/status/stage#{currlang}")) || s
set(:stage, status_print(s.text))
s1 and set(:stage_display, status_print(s1.text))
(i = xml&.at(ns("//bibdata/status/substage#{NOLANG}"))&.text) and
(i = xml.at(ns("//bibdata/status/substage#{NOLANG}"))&.text) and
set(:substage, i)
(i1 = xml&.at(ns("//bibdata/status/substage#{currlang}"))&.text || i) and
(i1 = xml.at(ns("//bibdata/status/substage#{currlang}"))&.text || i) and
set(:substage_display, i1)
(i2 = xml&.at(ns("//bibdata/status/iteration"))&.text) and
(i2 = xml.at(ns("//bibdata/status/iteration"))&.text) and
set(:iteration, i2)
set(:unpublished, unpublished(s.text))
unpublished(s.text) && set(:stageabbr, stage_abbr(s.text))
Expand Down
9 changes: 5 additions & 4 deletions lib/isodoc/xref/xref_gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,16 @@ def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
list.xpath(ns("./li")).each do |li|
bare_label, label =
list_item_value(li, c, depth, { list_anchor: list_anchor, prev_label: prev_label,
list_item_value(li, c, depth, { list_anchor:, prev_label:,
refer_list: depth == 1 ? refer_list : nil })
li["id"] and @anchors[li["id"]] =
{ label: bare_label, bare_xref: "#{label})",
xref: "#{label})",
type: "listitem", refer_list: refer_list,
type: "listitem", refer_list:,
container: list_anchor[:container] }
(li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
list_item_anchor_names(ol, list_anchor, depth + 1, label, refer_list)
list_item_anchor_names(ol, list_anchor, depth + 1, label,
refer_list)
end
end
end
Expand Down Expand Up @@ -227,7 +228,7 @@ def bookmark_container(parent)
def bookmark_anchor_names(xml)
xml.xpath(ns(".//bookmark")).noblank.each do |n|
_parent, id = id_ancestor(n)
#container = bookmark_container(parent)
# container = bookmark_container(parent)
@anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
xref: @anchors.dig(id, :xref) || "???",
container: @anchors.dig(id, :container) }
Expand Down
87 changes: 45 additions & 42 deletions spec/isodoc/blocks_notes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@
</body>
</html>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
expect(xmlpp(IsoDoc::WordConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to xmlpp(doc)
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to Xml::C14n.format(html)
expect(Xml::C14n.format(IsoDoc::WordConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to Xml::C14n.format(doc)
end

it "processes sequences of notes" do
Expand Down Expand Up @@ -169,10 +169,10 @@
</body>
</html>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to Xml::C14n.format(output)
end

it "processes multi-para notes" do
Expand Down Expand Up @@ -205,8 +205,8 @@
</body>
</html>
OUTPUT
expect(xmlpp(IsoDoc::HtmlConvert.new({})
.convert("test", input, true))).to be_equivalent_to xmlpp(output)
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
.convert("test", input, true))).to be_equivalent_to Xml::C14n.format(output)
end

it "processes non-para notes" do
Expand Down Expand Up @@ -280,10 +280,10 @@
</body>
</html>
OUTPUT
expect(xmlpp(IsoDoc::HtmlConvert.new({})
.convert("test", input, true))).to be_equivalent_to xmlpp(html)
expect(xmlpp(IsoDoc::WordConvert.new({})
.convert("test", input, true))).to be_equivalent_to xmlpp(doc)
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
.convert("test", input, true))).to be_equivalent_to Xml::C14n.format(html)
expect(Xml::C14n.format(IsoDoc::WordConvert.new({})
.convert("test", input, true))).to be_equivalent_to Xml::C14n.format(doc)
end

it "processes paragraphs containing notes" do
Expand Down Expand Up @@ -367,10 +367,10 @@
</body>
</html>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({})
.convert("test", input, true)))).to be_equivalent_to xmlpp(html)
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
.convert("test", input, true)))).to be_equivalent_to xmlpp(doc)
expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({})
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(html)
expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({})
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(doc)
end

it "converts notes and admonitions intended for coverpage" do
Expand Down Expand Up @@ -467,12 +467,12 @@
</body>
</html>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(strip_guid(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true)))).to be_equivalent_to xmlpp(html)
expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
.convert("test", presxml, true)))).to be_equivalent_to xmlpp(doc)
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true)))).to be_equivalent_to Xml::C14n.format(html)
expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({})
.convert("test", presxml, true)))).to be_equivalent_to Xml::C14n.format(doc)
end

it "numbers notes in tables and figures separately from notes outside them" do
Expand Down Expand Up @@ -517,8 +517,8 @@
</preface>
</iso-standard>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(output)
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(output)
end

it "processes admonitions" do
Expand Down Expand Up @@ -567,10 +567,10 @@
</body>
</html>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to Xml::C14n.format(output)
end

it "processes empty admonitions" do
Expand All @@ -596,8 +596,8 @@
</preface>
</iso-standard>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
end

it "processes admonitions with titles" do
Expand Down Expand Up @@ -651,10 +651,10 @@
</body>
</html>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to Xml::C14n.format(output)
end

it "processes box admonitions" do
Expand Down Expand Up @@ -708,9 +708,12 @@
</body>
</html>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true))))
.to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({})
.convert("test", presxml, true)))
.to be_equivalent_to Xml::C14n.format(output)
end
end
Loading

0 comments on commit cfb96ef

Please sign in to comment.