From 084e820e467eff8c537d059a0809de7f593d3ae3 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 13 Nov 2024 19:03:45 +1100 Subject: [PATCH 01/78] Caption refactor Presentation XML: https://github.com/metanorma/isodoc/issues/617 --- lib/isodoc/function/blocks.rb | 16 +-- lib/isodoc/function/blocks_example_note.rb | 20 +-- lib/isodoc/function/cleanup.rb | 2 +- lib/isodoc/function/inline.rb | 31 ++-- lib/isodoc/function/lists.rb | 8 +- lib/isodoc/function/references.rb | 8 +- lib/isodoc/function/reqt.rb | 4 +- lib/isodoc/function/section.rb | 50 +++---- lib/isodoc/function/section_titles.rb | 22 +-- lib/isodoc/function/table.rb | 2 +- lib/isodoc/function/terms.rb | 4 +- lib/isodoc/function/to_word_html.rb | 3 + lib/isodoc/html_function/footnotes.rb | 2 +- lib/isodoc/html_function/html.rb | 6 +- lib/isodoc/presentation_function/autonum.rb | 53 +++++++ lib/isodoc/presentation_function/block.rb | 52 +++---- lib/isodoc/presentation_function/docid.rb | 23 --- lib/isodoc/presentation_function/image.rb | 5 +- lib/isodoc/presentation_function/reqt.rb | 2 +- lib/isodoc/presentation_function/section.rb | 44 ++++-- .../presentation_function/sourcecode.rb | 5 +- lib/isodoc/presentation_function/terms.rb | 7 +- lib/isodoc/word_function/body.rb | 12 +- lib/isodoc/word_function/footnotes.rb | 2 +- lib/isodoc/word_function/lists.rb | 22 +-- lib/isodoc/word_function/table.rb | 4 +- lib/isodoc/xref/xref_anchor.rb | 33 +++-- lib/isodoc/xref/xref_gen.rb | 31 ++-- lib/isodoc/xref/xref_gen_seq.rb | 33 ++--- lib/isodoc/xref/xref_sect_gen.rb | 17 ++- lib/nokogiri/xml/node.rb | 1 + spec/isodoc/blocks_notes_spec.rb | 136 +++++++++++------- spec/isodoc/postproc_spec.rb | 70 ++++----- spec/isodoc/postproc_word_spec.rb | 74 +++++----- spec/isodoc/xref_format_spec.rb | 2 +- spec/spec_helper.rb | 1 + 36 files changed, 461 insertions(+), 346 deletions(-) create mode 100644 lib/isodoc/presentation_function/autonum.rb diff --git a/lib/isodoc/function/blocks.rb b/lib/isodoc/function/blocks.rb index d6ff41c2..eff94292 100644 --- a/lib/isodoc/function/blocks.rb +++ b/lib/isodoc/function/blocks.rb @@ -25,9 +25,9 @@ def figure_parse(node, out) def figure_parse1(node, out) out.div **figure_attrs(node) do |div| node.children.each do |n| - parse(n, div) unless n.name == "name" + parse(n, div) unless n.name == "fmt-name" end - figure_name_parse(node, div, node.at(ns("./name"))) + figure_name_parse(node, div, node.at(ns("./fmt-name"))) end end @@ -37,9 +37,9 @@ def pseudocode_attrs(node) def pseudocode_parse(node, out) @in_figure = true - name = node.at(ns("./name")) + name = node.at(ns("./fmt-name")) out.div **pseudocode_attrs(node) do |div| - node.children.each { |n| parse(n, div) unless n.name == "name" } + node.children.each { |n| parse(n, div) unless n.name == "fmt-name" } sourcecode_name_parse(node, div, name) end @in_figure = false @@ -57,7 +57,7 @@ def sourcecode_attrs(node) end def sourcecode_parse(node, out) - name = node.at(ns("./name")) + name = node.at(ns("./fmt-name")) out.p **sourcecode_attrs(node) do |div| sourcecode_parse1(node, div) end @@ -71,7 +71,7 @@ def sourcecode_parse1(node, div) node.at("./ancestor::xmlns:table[@class = 'rouge-line-table']") and @sourcecode = "table" node.children.each do |n| - %w(name dl).include?(n.name) and next + %w(fmt-name dl).include?(n.name) and next parse(n, div) end @sourcecode = false @@ -93,7 +93,7 @@ def formula_parse1(node, out) out.div **attr_code(class: "formula") do |div| div.p do |_p| parse(node.at(ns("./stem")), div) - if lbl = node&.at(ns("./name"))&.text + if lbl = node&.at(ns("./fmt-name"))&.text insert_tab(div, 1) div << lbl end @@ -109,7 +109,7 @@ def formula_parse(node, out) out.div **formula_attrs(node) do |div| formula_parse1(node, div) node.children.each do |n| - %w(stem name).include? n.name and next + %w(stem fmt-name).include? n.name and next parse(n, div) end end diff --git a/lib/isodoc/function/blocks_example_note.rb b/lib/isodoc/function/blocks_example_note.rb index bae0b76f..a7f51e76 100644 --- a/lib/isodoc/function/blocks_example_note.rb +++ b/lib/isodoc/function/blocks_example_note.rb @@ -19,9 +19,9 @@ def example_div_attr(node) # used if we are boxing examples def example_div_parse(node, out) out.div **example_div_attr(node) do |div| - example_label(node, div, node.at(ns("./name"))) + example_label(node, div, node.at(ns("./fmt-name"))) node.children.each do |n| - parse(n, div) unless n.name == "name" + parse(n, div) unless n.name == "fmt-name" end end end @@ -39,10 +39,10 @@ def example_table_parse(node, out) out.table **example_table_attr(node) do |t| t.tr do |tr| tr.td **EXAMPLE_TBL_ATTR do |td| - example_label(node, td, node.at(ns("./name"))) + example_label(node, td, node.at(ns("./fmt-name"))) end tr.td **EXAMPLE_TD_ATTR do |td| - node.children.each { |n| parse(n, td) unless n.name == "name" } + node.children.each { |n| parse(n, td) unless n.name == "fmt-name" } end end end @@ -53,7 +53,7 @@ def example_parse(node, out) end def note_p_parse(node, div) - name = node.at(ns("./name"))&.remove + name = node.at(ns("./fmt-name"))&.remove div.p do |p| name and p.span class: "note_label" do |s| name.children.each { |n| parse(n, s) } @@ -65,7 +65,7 @@ def note_p_parse(node, div) end def note_parse1(node, div) - name = node.at(ns("./name")) and div.p do |p| + name = node.at(ns("./fmt-name")) and div.p do |p| p.span class: "note_label" do |s| name.remove.children.each { |n| parse(n, s) } end @@ -94,7 +94,7 @@ def note_attrs(node) def note_parse(node, out) @note = true out.div **note_attrs(node) do |div| - if node&.at(ns("./*[local-name() != 'name'][1]"))&.name == "p" + if node&.at(ns("./*[local-name() != 'fmt-name'][1]"))&.name == "p" note_p_parse(node, div) else note_parse1(node, div) @@ -114,7 +114,7 @@ def admonition_class(_node) end def admonition_name(node, _type) - node&.at(ns("./name")) + node&.at(ns("./fmt-name")) end def admonition_attrs(node) @@ -124,7 +124,7 @@ def admonition_attrs(node) def admonition_parse(node, out) out.div **admonition_attrs(node) do |div| - if node&.at(ns("./*[local-name() != 'name'][1]"))&.name == "p" + if node&.at(ns("./*[local-name() != 'fmt-name'][1]"))&.name == "p" admonition_p_parse(node, div) else admonition_parse1(node, div) @@ -158,7 +158,7 @@ def admonition_parse1(node, div) if name admonition_name_parse(node, div, name) end - node.children.each { |n| parse(n, div) unless n.name == "name" } + node.children.each { |n| parse(n, div) unless n.name == "fmt-name" } end end end diff --git a/lib/isodoc/function/cleanup.rb b/lib/isodoc/function/cleanup.rb index c0a8a516..63d3b424 100644 --- a/lib/isodoc/function/cleanup.rb +++ b/lib/isodoc/function/cleanup.rb @@ -28,7 +28,7 @@ def cleanup(docxml) # todo PRESENTATION XML def admonition_cleanup(docxml) docxml.xpath("//div[@class = 'Admonition'][title]").each do |d| - title = d.at("./title") + title = d.at("./fmt-title") n = title.next_element n&.children&.first &.add_previous_sibling("#{title.remove.text}—") diff --git a/lib/isodoc/function/inline.rb b/lib/isodoc/function/inline.rb index aedb28ba..54c8956c 100644 --- a/lib/isodoc/function/inline.rb +++ b/lib/isodoc/function/inline.rb @@ -17,13 +17,18 @@ def link_parse(node, out) def location_parse(node, out); end + # Presentation XML classes which we need not pass on to HTML or DOC + SPAN_UNWRAP_CLASSES = + %w[fmt-caption-label fmt-label-delim fmt-element-name].freeze + def span_parse(node, out) - if node["style"] || node["class"] + klass = node["style"] || node["class"] + if klass && !SPAN_UNWRAP_CLASSES.include?(klass) out.span **attr_code(style: node["style"], class: node["class"]) do |s| - node.children.each { |n| parse(n, s) } + children_parse(node, s) end - else node.children.each { |n| parse(n, out) } + else children_parse(node, out) end end @@ -48,9 +53,8 @@ def xref_parse(node, out) end def suffix_url(url) - return url if url.nil? || %r{^https?://|^#}.match?(url) - return url unless File.extname(url).empty? - + url.nil? || %r{^https?://|^#}.match?(url) and return url + File.extname(url).empty? or return url url.sub(/#{File.extname(url)}$/, ".html") end @@ -136,8 +140,7 @@ def smallcap_parse(node, xml) end def text_parse(node, out) - return if node.nil? || node.text.nil? - + node.nil? || node.text.nil? and return text = node.to_s @sourcecode == "pre" and text = text.gsub("\n", "
").gsub("
", "
 ") @@ -184,8 +187,20 @@ def rb_parse(node, out) end def author_parse(node, out) + children_parse(node, out) + end + + def semx_parse(node, out) + children_parse(node, out) + end + + def children_parse(node, out) node.children.each { |n| parse(n, out) } end + + def xref_label_parse(node, out); end + + def name_parse(node, out); end end end end diff --git a/lib/isodoc/function/lists.rb b/lib/isodoc/function/lists.rb index 823a1e61..b23d43fc 100644 --- a/lib/isodoc/function/lists.rb +++ b/lib/isodoc/function/lists.rb @@ -2,7 +2,7 @@ module IsoDoc module Function module Lists def list_title_parse(node, out) - name = node.at(ns("./name")) or return + name = node.at(ns("./fmt-name")) or return out.p class: "ListTitle" do |p| name.children&.each { |n| parse(n, p) } end @@ -16,7 +16,7 @@ def ul_parse(node, out) out.div **attr_code(class: "ul_wrap") do |div| list_title_parse(node, div) div.ul **attr_code(ul_attrs(node)) do |ul| - node.children.each { |n| n.name == "name" or parse(n, ul) } + node.children.each { |n| n.name == "fmt-name" or parse(n, ul) } end end end @@ -57,7 +57,7 @@ def ol_parse(node, out) out.div **attr_code(class: "ol_wrap") do |div| list_title_parse(node, div) div.ol **attr_code(ol_attrs(node)) do |ol| - node.children.each { |n| n.name == "name" or parse(n, ol) } + node.children.each { |n| n.name == "fmt-name" or parse(n, ol) } end end end @@ -106,7 +106,7 @@ def dl_parse(node, out) end def dl_parse_notes(node, out) - node.elements.reject { |n| dt_dd?(n) || n.name == "name" } + node.elements.reject { |n| dt_dd?(n) || n.name == "fmt-name" } .each { |n| parse(n, out) } end diff --git a/lib/isodoc/function/references.rb b/lib/isodoc/function/references.rb index 12042dc0..6233a537 100644 --- a/lib/isodoc/function/references.rb +++ b/lib/isodoc/function/references.rb @@ -41,9 +41,9 @@ def norm_ref_xpath def norm_ref(node, out) node["hidden"] != "true" or return out.div do |div| - clause_name(node, node.at(ns("./title")), div, nil) + clause_name(node, node.at(ns("./fmt-title")), div, nil) if node.name == "clause" - node.elements.each { |e| parse(e, div) unless e.name == "title" } + node.elements.each { |e| parse(e, div) unless e.name == "fmt-title" } else biblio_list(node, div, false) end end @@ -60,7 +60,7 @@ def bibliography(node, out) page_break(out) out.div do |div| div.h1 class: "Section3" do |h1| - node.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) } + node.at(ns("./fmt-title"))&.children&.each { |c2| parse(c2, h1) } end biblio_list(node, div, true) end @@ -69,7 +69,7 @@ def bibliography(node, out) def bibliography_parse(node, out) node["hidden"] != true or return out.div do |div| - clause_parse_title(node, div, node.at(ns("./title")), out, + clause_parse_title(node, div, node.at(ns("./fmt-title")), out, { class: "Section3" }) biblio_list(node, div, true) end diff --git a/lib/isodoc/function/reqt.rb b/lib/isodoc/function/reqt.rb index d4563e4b..5688a034 100644 --- a/lib/isodoc/function/reqt.rb +++ b/lib/isodoc/function/reqt.rb @@ -20,9 +20,9 @@ def recommendation_parse(node, out) end def recommendation_parse1(node, out) - recommendation_name(node.at(ns("./name")), out) + recommendation_name(node.at(ns("./fmt-name")), out) node.children.each do |n| - parse(n, out) unless n.name == "name" + parse(n, out) unless n.name == "fmt-name" end end diff --git a/lib/isodoc/function/section.rb b/lib/isodoc/function/section.rb index a35f386f..08095a6a 100644 --- a/lib/isodoc/function/section.rb +++ b/lib/isodoc/function/section.rb @@ -10,8 +10,8 @@ def clause_attrs(node) # used for subclauses def clause_parse(node, out) out.div **attr_code(clause_attrs(node)) do |div| - clause_parse_title(node, div, node.at(ns("./title")), out) - node.children.reject { |c1| c1.name == "title" }.each do |c1| + clause_parse_title(node, div, node.at(ns("./fmt-title")), out) + node.children.reject { |c1| c1.name == "fmt-title" }.each do |c1| parse(c1, div) end end @@ -19,8 +19,8 @@ def clause_parse(node, out) def clause(node, out) out.div **attr_code(clause_attrs(node)) do |s| - clause_name(node, node.at(ns("./title")), s, nil) - node.elements.reject { |c1| c1.name == "title" }.each do |c1| + clause_name(node, node.at(ns("./fmt-title")), s, nil) + node.elements.reject { |c1| c1.name == "fmt-title" }.each do |c1| parse(c1, s) end end @@ -34,7 +34,7 @@ def annex(node, out) page_break(out) out.div **attr_code(annex_attrs(node)) do |s| node.elements.each do |c1| - if c1.name == "title" then annex_name(node, c1, s) + if c1.name == "fmt-title" then annex_name(node, c1, s) else parse(c1, s) end end @@ -47,9 +47,9 @@ def indexsect(node, out) def scope(node, out) out.div **attr_code(id: node["id"]) do |div| - clause_name(node, node.at(ns("./title")), div, nil) + clause_name(node, node.at(ns("./fmt-title")), div, nil) node.elements.each do |e| - parse(e, div) unless e.name == "title" + parse(e, div) unless e.name == "fmt-title" end end end @@ -59,9 +59,9 @@ def scope(node, out) def terms_defs(node, out) out.div **attr_code(id: node["id"]) do |div| - clause_name(node, node.at(ns("./title")), div, nil) + clause_name(node, node.at(ns("./fmt-title")), div, nil) node.elements.each do |e| - parse(e, div) unless %w{title source}.include? e.name + parse(e, div) unless %w{fmt-title source}.include? e.name end end end @@ -73,9 +73,9 @@ def terms_parse(isoxml, out) def symbols_abbrevs(node, out) out.div **attr_code(id: node["id"], class: "Symbols") do |div| - clause_name(node, node.at(ns("./title")), div, nil) + clause_name(node, node.at(ns("./fmt-title")), div, nil) node.elements.each do |e| - parse(e, div) unless e.name == "title" + parse(e, div) unless e.name == "fmt-title" end end end @@ -88,10 +88,10 @@ def symbols_parse(isoxml, out) def introduction(clause, out) page_break(out) out.div class: "Section3", id: clause["id"] do |div| - clause_name(clause, clause.at(ns("./title")), div, + clause_name(clause, clause.at(ns("./fmt-title")), div, { class: "IntroTitle" }) clause.elements.each do |e| - parse(e, div) unless e.name == "title" + parse(e, div) unless e.name == "fmt-title" end end end @@ -99,9 +99,9 @@ def introduction(clause, out) def foreword(clause, out) page_break(out) out.div **attr_code(id: clause["id"]) do |s| - clause_name(clause, clause.at(ns("./title")), s, + clause_name(clause, clause.at(ns("./fmt-title")), s, { class: "ForewordTitle" }) - clause.elements.each { |e| parse(e, s) unless e.name == "title" } + clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" } end end @@ -109,9 +109,9 @@ def acknowledgements(clause, out) title_attr = { class: "IntroTitle" } page_break(out) out.div class: "Section3", id: clause["id"] do |div| - clause_name(clause, clause.at(ns("./title")), div, title_attr) + clause_name(clause, clause.at(ns("./fmt-title")), div, title_attr) clause.elements.each do |e| - parse(e, div) unless e.name == "title" + parse(e, div) unless e.name == "fmt-title" end end end @@ -119,9 +119,9 @@ def acknowledgements(clause, out) def abstract(clause, out) page_break(out) out.div **attr_code(id: clause["id"]) do |s| - clause_name(clause, clause.at(ns("./title")), s, + clause_name(clause, clause.at(ns("./fmt-title")), s, { class: "AbstractTitle" }) - clause.elements.each { |e| parse(e, s) unless e.name == "title" } + clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" } end end @@ -141,10 +141,10 @@ def preface(clause, out) def preface_normal(clause, out) page_break(out) out.div **attr_code(preface_attrs(clause)) do |div| - clause_name(clause, clause.at(ns("./title")), div, + clause_name(clause, clause.at(ns("./fmt-title")), div, { class: "IntroTitle" }) clause.elements.each do |e| - parse(e, div) unless e.name == "title" + parse(e, div) unless e.name == "fmt-title" end end end @@ -153,10 +153,10 @@ def table_of_contents(clause, out) @bare and return page_break(out) out.div **attr_code(preface_attrs(clause)) do |div| - clause_name(clause, clause.at(ns("./title")), div, + clause_name(clause, clause.at(ns("./fmt-title")), div, { class: "IntroTitle" }) clause.elements.each do |e| - parse(e, div) unless e.name == "title" + parse(e, div) unless e.name == "fmt-title" end end end @@ -165,10 +165,10 @@ def colophon(node, out) @seen_colophon or page_break(out) @seen_colophon = true out.div class: "Section3", id: node["id"] do |div| - clause_name(node, node.at(ns("./title")), div, + clause_name(node, node.at(ns("./fmt-title")), div, { class: "IntroTitle" }) node.elements.each do |e| - parse(e, div) unless e.name == "title" + parse(e, div) unless e.name == "fmt-title" end end end diff --git a/lib/isodoc/function/section_titles.rb b/lib/isodoc/function/section_titles.rb index 3b99f5a3..c53d47c2 100644 --- a/lib/isodoc/function/section_titles.rb +++ b/lib/isodoc/function/section_titles.rb @@ -18,18 +18,23 @@ def inline_header_title(out, node, title) end end + SECTIONS_NAMES = + %w[clause annex terms references definitions + acknowledgements introduction abstract foreword appendix].freeze + def freestanding_title(node, out) - parents = node.ancestors("clause, annex, terms, references, " \ - "definitions, acknowledgements, introduction, " \ - "foreword") + # node.parent.at(ns("./fmt-title[@source = '#{node['id']}']")) and + # return # this title is already being rendered as fmt-title + # For testing convenience, let's just go by parent + SECTIONS_NAMES.include?(node.parent.name) and return + parents = node.ancestors(SECTIONS_NAMES.join(", ")) clause_parse_title(parents.empty? ? node : parents.first, out, node, out) end # used for subclauses def clause_parse_title(node, div, title, out, header_class = {}) - return if title.nil? - + title.nil? and return if node["inline-header"] == "true" inline_header_title(out, node, title) else @@ -46,9 +51,7 @@ def clause_parse_title1(node, div, title, _out, header_class = {}) end def clause_title_depth(node, title) - depth = node.ancestors("clause, annex, terms, references, " \ - "definitions, acknowledgements, introduction, " \ - "foreword").size + 1 + depth = node.ancestors(SECTIONS_NAMES.join(", ")).size + 1 depth = title["depth"] if title && title["depth"] depth end @@ -76,8 +79,7 @@ def clause_name(_node, title, div, header_class) end def annex_name(_annex, name, div) - return if name.nil? - + name.nil? and return div.h1 class: "Annex" do |t| name.children.each { |c2| parse(c2, t) } clause_parse_subtitle(name, t) diff --git a/lib/isodoc/function/table.rb b/lib/isodoc/function/table.rb index 74df4cbc..8e75bcf2 100644 --- a/lib/isodoc/function/table.rb +++ b/lib/isodoc/function/table.rb @@ -2,7 +2,7 @@ module IsoDoc module Function module Table def table_title_parse(node, out) - name = node.at(ns("./name")) or return + name = node.at(ns("./fmt-name")) or return out.p class: "TableTitle", style: "text-align:center;" do |p| name&.children&.each { |n| parse(n, p) } end diff --git a/lib/isodoc/function/terms.rb b/lib/isodoc/function/terms.rb index c5fc2c07..cd6de2ce 100644 --- a/lib/isodoc/function/terms.rb +++ b/lib/isodoc/function/terms.rb @@ -38,7 +38,7 @@ def para_then_remainder(first, node, para, div) end def termnote_parse(node, out) - name = node&.at(ns("./name"))&.remove + name = node&.at(ns("./fmt-name"))&.remove out.div **note_attrs(node) do |div| div.p do |p| name&.children&.each { |n| parse(n, p) } @@ -60,7 +60,7 @@ def termdomain_parse(node, out) end def termdef_parse(node, out) - name = node.at(ns("./name"))&.remove + name = node.at(ns("./fmt-name"))&.remove out.p class: "TermNum", id: node["id"] do |p| name&.children&.each { |n| parse(n, p) } end diff --git a/lib/isodoc/function/to_word_html.rb b/lib/isodoc/function/to_word_html.rb index 5ae1bb4c..8dfec61a 100644 --- a/lib/isodoc/function/to_word_html.rb +++ b/lib/isodoc/function/to_word_html.rb @@ -262,6 +262,9 @@ def parse(node, out) when "ruby" then ruby_parse(node, out) when "rt" then rt_parse(node, out) when "rb" then rb_parse(node, out) + when "semx" then semx_parse(node, out) + when "name" then name_parse(node, out) + when "fmt-xref-label" then xref_label_parse(node, out) else error_parse(node, out) end end diff --git a/lib/isodoc/html_function/footnotes.rb b/lib/isodoc/html_function/footnotes.rb index 5977396b..2b611bc5 100644 --- a/lib/isodoc/html_function/footnotes.rb +++ b/lib/isodoc/html_function/footnotes.rb @@ -68,7 +68,7 @@ def table_footnote_parse(node, out) def footnote_parse(node, out) return table_footnote_parse(node, out) if (@in_table || @in_figure) && - !node.ancestors.map(&:name).include?("name") + !node.ancestors.map(&:name).include?("fmt-name") fn = node["reference"] || UUIDTools::UUID.random_create.to_s attrs = { class: "FootnoteRef", href: "#fn:#{fn}" } diff --git a/lib/isodoc/html_function/html.rb b/lib/isodoc/html_function/html.rb index 78d92ece..23a77d96 100644 --- a/lib/isodoc/html_function/html.rb +++ b/lib/isodoc/html_function/html.rb @@ -15,10 +15,6 @@ def convert1(docxml, filename, dir) end.join("\n") end - def preprocess_xslt(docxml) - super - end - def make_body1(body, _docxml) return if @bare @@ -78,7 +74,7 @@ def html_main(docxml) end def sourcecode_parse(node, out) - name = node.at(ns("./name")) + name = node.at(ns("./fmt-name")) tag = node.at(ns(".//sourcecode | .//table")) ? "div" : "pre" attr = sourcecode_attrs(node).merge(class: "sourcecode") out.send tag, **attr do |div| diff --git a/lib/isodoc/presentation_function/autonum.rb b/lib/isodoc/presentation_function/autonum.rb new file mode 100644 index 00000000..7a45a8cf --- /dev/null +++ b/lib/isodoc/presentation_function/autonum.rb @@ -0,0 +1,53 @@ +module IsoDoc + class PresentationXMLConvert < ::IsoDoc::Convert + def prefix_name(node, delims, label, elem) + label&.empty? and label = nil + name, ins, ids, number = prefix_name_prep(node, elem) + label and ins.next = fmt_label(label, number, ids) + number and node["autonum"] = number + c = fmt_caption(label, elem, name, ids, delims) and ins.next = c + node.at(ns("./sentinel"))&.remove + end + + def prefix_name_prep(node, elem) + lbls = prefix_name_labels(node) + name = node.at(ns("./#{elem}")) and name["id"] = lbls[:name] + ins = name || node.add_first_child("").elements.first + node["unnumbered"] or + number = @xrefs.anchor(node["id"], :value, false)&.strip + [name, ins, lbls, number] + end + + def prefix_name_labels(node) + { elem: node["id"], + name: "_#{UUIDTools::UUID.random_create}" } + end + + def autonum(id, num) + "#{num}" + end + + def fmt_label(label, _number, ids) + x = @xrefs.anchor(ids[:elem], :xref, false) and + return "#{x}" + "" + #label = cleanup_entities(label.strip) + #<<~XML + ##{label}#{xref} + #XML + end + + def fmt_caption(label, elem, name, ids, delims) + c = if name && !name.children.empty? + label.blank? or + d = "#{delims[:caption]}" + attr = " element='#{elem}' source='#{ids[:name]}'" + "#{label}#{d}#{to_xml(name.children)}" + elsif label then label + else return + end + f = "#{delims[:label]}" + "#{c}#{f}" + end + end +end diff --git a/lib/isodoc/presentation_function/block.rb b/lib/isodoc/presentation_function/block.rb index 25898fad..5c38e91a 100644 --- a/lib/isodoc/presentation_function/block.rb +++ b/lib/isodoc/presentation_function/block.rb @@ -1,5 +1,6 @@ require_relative "image" require_relative "sourcecode" +require_relative "autonum" require "rouge" module IsoDoc @@ -13,17 +14,6 @@ def block_delim " — " end - def prefix_name(node, delim, number, elem) - number.nil? || number.empty? and return - unless name = node.at(ns("./#{elem}")) - node.add_first_child "<#{elem}>" - name = node.children.first - end - if name.children.empty? then name.add_child(cleanup_entities(number.strip)) - else (name.children.first.previous = "#{number.strip}#{delim}") - end - end - def formula(docxml) docxml.xpath(ns("//formula")).each { |f| formula1(f) } end @@ -31,7 +21,7 @@ def formula(docxml) def formula1(elem) formula_where(elem.at(ns("./dl"))) lbl = @xrefs.anchor(elem["id"], :label, false) - lbl.nil? || lbl.empty? or prefix_name(elem, "", "(#{lbl})", "name") + lbl.nil? || lbl.empty? or prefix_name(elem, {}, "(#{lbl})", "name") end def formula_where(dlist) @@ -47,11 +37,10 @@ def example(docxml) def example1(elem) n = @xrefs.get[elem["id"]] - lbl = if n.nil? || n[:label].nil? || n[:label].empty? - @i18n.example - else l10n("#{@i18n.example} #{n[:label]}") - end - prefix_name(elem, block_delim, lbl, "name") + lbl = "#{@i18n.example}" + (n.nil? || n[:label].nil? || n[:label].empty?) or + lbl = l10n("#{lbl} #{autonum(elem['id'], n[:label])}") + prefix_name(elem, { caption: block_delim}, lbl, "name") end def note(docxml) @@ -64,17 +53,16 @@ def note_delim(_elem) def note1(elem) %w(bibdata bibitem).include?(elem.parent.name) || - elem["notag"] == "true" and return - lbl = note_label(elem) - prefix_name(elem, "", lbl, "name") + elem["notag"] == "true" or lbl = note_label(elem) + prefix_name(elem, { label: note_delim(elem) }, lbl, "name") end def note_label(elem) n = @xrefs.get[elem["id"]] - lbl = @i18n.note + lbl = "#{@i18n.note}" (n.nil? || n[:label].nil? || n[:label].empty?) or - lbl = l10n("#{lbl} #{n[:label]}") - "#{lbl}#{note_delim(elem)}" + lbl = l10n("#{lbl} #{autonum(elem['id'], n[:label])}") + lbl end def admonition(docxml) @@ -85,23 +73,24 @@ def admonition1(elem) if elem["type"] == "box" admonition_numbered1(elem) elsif elem["notag"] == "true" || elem.at(ns("./name")) + prefix_name(elem, { label: admonition_delim(elem) }, nil, "name") else label = admonition_label(elem, nil) - prefix_name(elem, "", label, "name") + prefix_name(elem, { label: admonition_delim(elem) }, label, "name") end - n = elem.at(ns("./name")) and n << admonition_delim(elem) end def admonition_numbered1(elem) - elem["unnumbered"] && !elem.at(ns("./name")) and return + # elem["unnumbered"] && !elem.at(ns("./name")) and return label = admonition_label(elem, @xrefs.anchor(elem["id"], :label, false)) - prefix_name(elem, block_delim, label, "name") + prefix_name(elem, { caption: block_delim }, label, "name") end def admonition_label(elem, num) lbl = if elem["type"] == "box" then @i18n.box else @i18n.admonition[elem["type"]]&.upcase end - num and lbl = l10n("#{lbl} #{num}") + lbl &&= "#{lbl}" + num and lbl = l10n("#{lbl} #{autonum(elem['id'], num)}") lbl end @@ -117,10 +106,11 @@ def table(docxml) def table1(elem) table_fn(elem) labelled_ancestor(elem) and return - elem["unnumbered"] && !elem.at(ns("./name")) and return + # elem["unnumbered"] && !elem.at(ns("./name")) and return n = @xrefs.anchor(elem["id"], :label, false) - prefix_name(elem, block_delim, l10n("#{lower2cap @i18n.table} #{n}"), - "name") + lbl = "#{lower2cap @i18n.table} "\ + "#{autonum(elem['id'], n)}" + prefix_name(elem, { caption: block_delim }, l10n(lbl), "name") end def table_long_strings_cleanup(docxml) diff --git a/lib/isodoc/presentation_function/docid.rb b/lib/isodoc/presentation_function/docid.rb index ed052f69..29ab41ed 100644 --- a/lib/isodoc/presentation_function/docid.rb +++ b/lib/isodoc/presentation_function/docid.rb @@ -6,29 +6,6 @@ def docid_prefixes(docxml) end end -=begin - # This is highly specific to ISO, but it's not a bad precedent for - # references anyway; keeping here instead of in IsoDoc::Iso for now - def docid_l10n(text) - text.nil? and return text - @i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase) - text.size < 20 and text.gsub!(/ /, " ") - text - end - - def docid_prefix(prefix, docid) - docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) && - !/^#{prefix}\b/.match(docid) - docid_l10n(docid) - end - - def omit_docid_prefix(prefix) - prefix.nil? || prefix.empty? and return true - %w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal) - .include? prefix - end -=end - def pref_ref_code(bib) bib["suppress_identifier"] == "true" and return nil ret = bib.xpath(ns("./docidentifier[@scope = 'biblio-tag']")) diff --git a/lib/isodoc/presentation_function/image.rb b/lib/isodoc/presentation_function/image.rb index 022ff482..b4badb4b 100644 --- a/lib/isodoc/presentation_function/image.rb +++ b/lib/isodoc/presentation_function/image.rb @@ -51,8 +51,9 @@ def figure1(elem) figure_label?(elem) or return nil lbl = @xrefs.anchor(elem["id"], :label, false) or return # no xref, no label: this can be set in xref - prefix_name(elem, block_delim, - l10n("#{figure_label(elem)} #{lbl}"), "name") + a = autonum(elem["id"], lbl) + s = "#{figure_label(elem)} #{a}" + prefix_name(elem, { caption: block_delim }, l10n(s), "name") end # move footnotes into key, and get rid of footnote reference diff --git a/lib/isodoc/presentation_function/reqt.rb b/lib/isodoc/presentation_function/reqt.rb index 804d7fe8..3853a527 100644 --- a/lib/isodoc/presentation_function/reqt.rb +++ b/lib/isodoc/presentation_function/reqt.rb @@ -24,7 +24,7 @@ def permission(docxml) def recommendation1(elem, type) lbl = @reqt_models.model(elem["model"]) .recommendation_label(elem, type, xrefs) - prefix_name(elem, "", l10n(lbl), "name") + prefix_name(elem, {}, l10n(lbl), "name") end def requirement_render_preprocessing(docxml); end diff --git a/lib/isodoc/presentation_function/section.rb b/lib/isodoc/presentation_function/section.rb index 69307433..e1e6b255 100644 --- a/lib/isodoc/presentation_function/section.rb +++ b/lib/isodoc/presentation_function/section.rb @@ -20,7 +20,9 @@ def missing_title(docxml) end def clause(docxml) - docxml.xpath(ns("//clause | //terms | //definitions | //references")) + docxml.xpath(ns("//clause | //terms | //definitions | //references | " \ + "//introduction | //foreword | //preface/abstract | " \ + "//acknowledgements | //colophon | //indexsect ")) .each do |f| f.parent.name == "annex" && @xrefs.klass.single_term_clause?(f.parent) and next @@ -34,14 +36,25 @@ def unnumbered_clause?(elem) elem.at("./ancestor::*[@unnumbered = 'true']") end + def clausedelim + ret = super + ret && !ret.empty? or return ret + "#{ret}" + end + def clause1(elem) level = @xrefs.anchor(elem["id"], :level, false) || (elem.ancestors("clause, annex").size + 1) - t = elem.at(ns("./title")) and t["depth"] = level - unnumbered_clause?(elem) and return + # t = elem.at(ns("./title")) and t["depth"] = level + # unnumbered_clause?(elem) and return lbl = @xrefs.anchor(elem["id"], :label, - elem.parent.name != "sections") or return - prefix_name(elem, "", "#{lbl}#{clausedelim}", "title") + elem.parent.name != "sections") # or return + if unnumbered_clause?(elem) || !lbl + prefix_name(elem, {}, nil, "title") + else + prefix_name(elem, { caption: "" }, "#{lbl}#{clausedelim}", "title") + end + t = elem.at(ns("./fmt-title")) and t["depth"] = level end def floattitle(docxml) @@ -75,8 +88,12 @@ def annex1(elem) lbl = @xrefs.anchor(elem["id"], :label) t = elem.at(ns("./title")) and t.children = "#{to_xml(t.children)}" - unnumbered_clause?(elem) and return - prefix_name(elem, "

", lbl, "title") + # unnumbered_clause?(elem) and return + if unnumbered_clause?(elem) + prefix_name(elem, {}, nil, "title") + else + prefix_name(elem, { caption: "

" }, lbl, "title") + end end def single_term_clause_retitle(elem) @@ -91,7 +108,7 @@ def single_term_clause_unnest(elem) t = elem.at(ns("./terms | ./definitions | ./references")) t.xpath(ns(".//clause | .//terms | .//definitions | .//references")) .each do |c| - tit = c.at(ns("./title")) or return + tit = c.at(ns("./fmt-title")) or next tit["depth"] = tit["depth"].to_i - 1 unless tit["depth"] == "1" end end @@ -154,10 +171,10 @@ def cjk_search lang end - def cjk_extended_title(docxml) + def cjk_extended_title(doc) l = cjk_search - docxml.xpath(ns("//bibdata/title[#{l}] | //floating-title[#{l}] | " \ - "//title[@depth = '1' or not(@depth)][#{l}]")).each do |t| + doc.xpath(ns("//bibdata/title[#{l}] | //floating-title[#{l}] | " \ + "//fmt-title[@depth = '1' or not(@depth)][#{l}]")).each do |t| t.text.size < 4 or next t.elements.empty? or next # can't be bothered t.children = @i18n.cjk_extend(t.text) @@ -179,10 +196,9 @@ def preface_move(clause, after, _doc) clause or return preface = clause.parent float = preceding_floats(clause) - prev = nil xpath = after.map { |n| "./self::xmlns:#{n}" }.join(" | ") xpath.empty? and xpath = "./self::*[not(following-sibling::*)]" - preface_move1(clause, preface, float, prev, xpath) + preface_move1(clause, preface, float, nil, xpath) end def preface_move1(clause, preface, float, prev, xpath) @@ -220,7 +236,7 @@ def toc_title(docxml) ins = toc_title_insert_pt(docxml) or return id = UUIDTools::UUID.random_create.to_s ins.previous = <<~CLAUSE - #{@i18n.table_of_contents} + #{@i18n.table_of_contents} CLAUSE end diff --git a/lib/isodoc/presentation_function/sourcecode.rb b/lib/isodoc/presentation_function/sourcecode.rb index e91032fd..42a4e636 100644 --- a/lib/isodoc/presentation_function/sourcecode.rb +++ b/lib/isodoc/presentation_function/sourcecode.rb @@ -152,8 +152,9 @@ def source_lex(elem) def source_label(elem) labelled_ancestor(elem) and return lbl = @xrefs.anchor(elem["id"], :label, false) or return - prefix_name(elem, block_delim, - l10n("#{lower2cap @i18n.figure} #{lbl}"), "name") + a = autonum(elem["id"], lbl) + s = "#{lower2cap @i18n.figure} #{a}" + prefix_name(elem, { caption: block_delim }, l10n(s), "name") end end end diff --git a/lib/isodoc/presentation_function/terms.rb b/lib/isodoc/presentation_function/terms.rb index f795b910..b95e1128 100644 --- a/lib/isodoc/presentation_function/terms.rb +++ b/lib/isodoc/presentation_function/terms.rb @@ -115,12 +115,11 @@ def termnote_delim(_elem) def termnote1(elem) lbl = termnote_label(elem) - prefix_name(elem, "", lower2cap(lbl), "name") + prefix_name(elem, { label: termnote_delim(elem) }, lower2cap(lbl), "name") end def termnote_label(elem) - lbl = @xrefs.anchor(elem["id"], :label) || "???" - l10n "#{lbl}#{termnote_delim(elem)}" + @xrefs.anchor(elem["id"], :label) || "???" end def termdefinition(docxml) @@ -200,7 +199,7 @@ def term(docxml) def term1(elem) lbl = @xrefs.anchor(elem["id"], :label) or return - prefix_name(elem, "", "#{lbl}#{clausedelim}", "name") + prefix_name(elem, { label: clausedelim }, "#{lbl}#{clausedelim}", "name") end end end diff --git a/lib/isodoc/word_function/body.rb b/lib/isodoc/word_function/body.rb index 2c337c4b..5c888a04 100644 --- a/lib/isodoc/word_function/body.rb +++ b/lib/isodoc/word_function/body.rb @@ -103,7 +103,7 @@ def figure_aside_process(fig, aside, key) end def note_p_parse(node, div) - name = node.at(ns("./name"))&.remove + name = node.at(ns("./fmt-name"))&.remove div.p class: "Note" do |p| p.span class: "note_label" do |s| name&.children&.each { |n| parse(n, s) } @@ -115,7 +115,7 @@ def note_p_parse(node, div) end def note_parse1(node, div) - name = node.at(ns("./name"))&.remove + name = node.at(ns("./fmt-name"))&.remove div.p class: "Note" do |p| p.span class: "note_label" do |s| name&.children&.each { |n| parse(n, s) } @@ -126,7 +126,7 @@ def note_parse1(node, div) end def termnote_parse(node, out) - name = node&.at(ns("./name"))&.remove + name = node&.at(ns("./fmt-name"))&.remove out.div **note_attrs(node) do |div| div.p class: "Note" do |p| if name @@ -164,7 +164,7 @@ def formula_parse1(node, out) div.p do |_p| parse(node.at(ns("./stem")), div) insert_tab(div, 1) - if lbl = node&.at(ns("./name"))&.text + if lbl = node&.at(ns("./fmt-name"))&.text div << lbl end end @@ -185,10 +185,10 @@ def table_of_contents(clause, out) page_break(out) out.div **attr_code(preface_attrs(clause)) do |div| div.p class: "zzContents" do |p| - clause.at(ns("./title"))&.children&.each { |c| parse(c, p) } + clause.at(ns("./fmt-title"))&.children&.each { |c| parse(c, p) } end clause.elements.each do |e| - parse(e, div) unless e.name == "title" + parse(e, div) unless e.name == "fmt-title" end end end diff --git a/lib/isodoc/word_function/footnotes.rb b/lib/isodoc/word_function/footnotes.rb index 5e42d991..3479a236 100644 --- a/lib/isodoc/word_function/footnotes.rb +++ b/lib/isodoc/word_function/footnotes.rb @@ -83,7 +83,7 @@ def seen_footnote_parse(_node, out, footnote) def footnote_parse(node, out) return table_footnote_parse(node, out) if (@in_table || @in_figure) && - !node.ancestors.map(&:name).include?("name") + !node.ancestors.map(&:name).include?("fmt-name") fn = node["reference"] || UUIDTools::UUID.random_create.to_s return seen_footnote_parse(node, out, fn) if @seen_footnote.include?(fn) diff --git a/lib/isodoc/word_function/lists.rb b/lib/isodoc/word_function/lists.rb index b01540a0..4891abc4 100644 --- a/lib/isodoc/word_function/lists.rb +++ b/lib/isodoc/word_function/lists.rb @@ -25,13 +25,13 @@ def dl_parse(node, out) def dl_parse_nontable(node, out) out.div **attr_code(class: "figdl") do |div| - node["id"] and bookmark_parse(node, div) - list_title_parse(node, div) - node.elements.select { |n| dt_dd?(n) } - .each_slice(2) do |dt, dd| - dl_parse_nontable1(div, dt, dd) - end - dl_parse_notes(node, div) + node["id"] and bookmark_parse(node, div) + list_title_parse(node, div) + node.elements.select { |n| dt_dd?(n) } + .each_slice(2) do |dt, dd| + dl_parse_nontable1(div, dt, dd) + end + dl_parse_notes(node, div) end end @@ -58,13 +58,13 @@ def ddef_first_para(out, ddef) def ddef_other_paras(out, ddef) ddef.elements&.first&.name == "p" or return - ddef.children[1..-1].each { |n| parse(n, out) } + ddef.children[1..].each { |n| parse(n, out) } end def dl_parse_table(node, out) list_title_parse(node, out) out.table **attr_code(id: node["id"], - class: (node["class"] || "dl")) do |v| + class: node["class"] || "dl") do |v| node.elements.select { |n| dt_dd?(n) } .each_slice(2) do |dt, dd| dl_parse_table1(v, dt, dd) @@ -85,7 +85,9 @@ def dl_parse_table1(table, dterm, ddefn) end def dl_parse_table_notes(node, out) - remainder = node.elements.reject { |n| dt_dd?(n) || n.name == "name" } + remainder = node.elements.reject do |n| + dt_dd?(n) || n.name == "fmt-name" + end remainder.empty? and return out.tr do |tr| tr.td colspan: 2 do |td| diff --git a/lib/isodoc/word_function/table.rb b/lib/isodoc/word_function/table.rb index c5892237..0da24ee3 100644 --- a/lib/isodoc/word_function/table.rb +++ b/lib/isodoc/word_function/table.rb @@ -34,7 +34,7 @@ def make_tr_attr(cell, row, totalrows, header, bordered) def make_tr_attr_style(cell, row, rowmax, totalrows, opt) top = row.zero? ? "#{SW1} 1.5pt;" : "none;" bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;" - ret = <<~STYLE.gsub(/\n/, "") + ret = <<~STYLE.delete("\n") border-top:#{top}mso-border-top-alt:#{top} border-bottom:#{bottom}mso-border-bottom-alt:#{bottom} STYLE @@ -46,7 +46,7 @@ def make_tr_attr_style(cell, row, rowmax, totalrows, opt) def keep_rows_together(_cell, rowmax, totalrows, opt) opt[:header] and return true @table_line_count > 15 and return false - (totalrows <= 10 && rowmax < totalrows) + totalrows <= 10 && rowmax < totalrows end def tbody_parse(node, table) diff --git a/lib/isodoc/xref/xref_anchor.rb b/lib/isodoc/xref/xref_anchor.rb index 1406e5ce..647ab067 100644 --- a/lib/isodoc/xref/xref_anchor.rb +++ b/lib/isodoc/xref/xref_anchor.rb @@ -29,16 +29,23 @@ def get_anchors @anchors end - def anchor_struct_label(lbl, elem) + def anchor_struct_label(lbl, node, elem) case elem - when @labels["appendix"] then "#{elem} #{lbl}" + when @labels["appendix"] + s = "" \ + "#{lbl}" + "#{elem} #{s}" else lbl.to_s end end - def anchor_struct_xref(lbl, elem) - l10n("#{elem} #{anchor_struct_value(lbl, elem)}") + def anchor_struct_xref(lbl, node, elem) + lbl.blank? or s = <<~SEMX + #{' '}#{anchor_struct_value(lbl, elem)} + SEMX + l10n("#{elem}#{s}") + .gsub(/ $/, "") end def anchor_struct_value(lbl, elem) @@ -49,15 +56,15 @@ def anchor_struct_value(lbl, elem) end end - def anchor_struct(lbl, container, elem, type, unnumb = false) - ret = {} - ret[:label] = unnumb == "true" ? nil : anchor_struct_label(lbl, elem) - ret[:xref] = anchor_struct_xref(unnumb == "true" ? "(??)" : lbl, elem) - ret[:xref].gsub!(/ $/, "") - ret[:container] = @klass.get_clause_id(container) unless container.nil? - ret[:type] = type - ret[:elem] = elem - ret[:value] = anchor_struct_value(lbl, elem) + def anchor_struct(lbl, node, elem_name, type, opt = {}) + ret = { type: type, elem: elem_name, label: nil } + opt[:unnumb] != "true" and + ret[:label] = anchor_struct_label(lbl, node, elem_name) + ret[:xref] = + anchor_struct_xref(opt[:unnumb] == "true" ? "(??)" : lbl, node, + elem_name) + ret[:container] = @klass.get_clause_id(node) if opt[:container] + ret[:value] = anchor_struct_value(lbl, elem_name) ret end end diff --git a/lib/isodoc/xref/xref_gen.rb b/lib/isodoc/xref/xref_gen.rb index 06ded319..768baed8 100644 --- a/lib/isodoc/xref/xref_gen.rb +++ b/lib/isodoc/xref/xref_gen.rb @@ -35,7 +35,8 @@ def termnote_label(note) def increment_label(elems, node, counter, increment: true) elems.size == 1 && !node["number"] and return "" counter.increment(node) if increment - " #{counter.print}" + #" #{counter.print}" + counter.print end def termnote_anchor_names(docxml) @@ -47,7 +48,9 @@ def termnote_anchor_names(docxml) { label: termnote_label(c.print), type: "termnote", value: c.print, elem: @labels["termnote"], container: t["id"], - xref: "#{@labels['note_xref']} #{c.print}" } + #xref: "#{@labels['note_xref']} #{c.print}" + xref: anchor_struct_xref(c.print, n, @labels['note_xref']) + } end end end @@ -63,7 +66,9 @@ def termexample_anchor_names(docxml) { label: idx, type: "termexample", value: idx, elem: @labels["example_xref"], container: t["id"], - xref: "#{@labels['example_xref']} #{idx}" } + #xref: "#{@labels['example_xref']} #{idx}" } + xref: anchor_struct_xref(idx, n, @labels['example_xref']) + } end end end @@ -81,7 +86,7 @@ def note_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, - @labels["note_xref"], "note", false) + @labels["note_xref"], "note", { container: true, unnumb: false }) end end @@ -98,7 +103,7 @@ def admonition_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] ||= anchor_struct(increment_label(notes, n, counter), n, - @labels["box"], "admonition", n["unnumbered"]) + @labels["box"], "admonition", { container: true, unnumb: n["unnumbered"] }) end end @@ -114,7 +119,7 @@ def example_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] ||= anchor_struct(increment_label(notes, n, counter), n, - @labels["example_xref"], "example", n["unnumbered"]) + @labels["example_xref"], "example", { unnumb: n["unnumbered"], container: true }) end end @@ -125,7 +130,7 @@ def list_anchor_names(sections) c = list_counter notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n, - @labels["list"], "list", false) + @labels["list"], "list", { unnumb: false, container: true}) list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1) end list_anchor_names(s.xpath(ns(CHILD_SECTIONS))) @@ -140,7 +145,7 @@ def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) refer_list: depth == 1 ? refer_list : nil }) li["id"] and @anchors[li["id"]] = { label: bare_label, bare_xref: "#{label})", - xref: "#{label})", + xref: %[#{label})], type: "listitem", refer_list:, container: list_anchor[:container] } (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol| @@ -180,14 +185,14 @@ def deflist_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, - @labels["deflist"], "deflist", false) + @labels["deflist"], "deflist", { unnumb: false, container: true }) deflist_term_anchor_names(n, @anchors[n["id"]]) end end def deflist_term_anchor_names(list, list_anchor) list.xpath(ns("./dt")).each do |li| - label = "#{list_anchor[:xref]}: #{dt2xreflabel(li)}" + label = deflist_term_anchor_lbl(li, list_anchor) li["id"] and @anchors[li["id"]] = { xref: label, type: "deflistitem", container: list_anchor[:container] } @@ -197,6 +202,12 @@ def deflist_term_anchor_names(list, list_anchor) end end + def deflist_term_anchor_lbl(listitem, list_anchor) + <<~LABEL + #{list_anchor[:xref]}: #{dt2xreflabel(listitem)} + LABEL + end + def dt2xreflabel(dterm) label = dterm.dup label.xpath(ns(".//p")).each { |x| x.replace(x.children) } diff --git a/lib/isodoc/xref/xref_gen_seq.rb b/lib/isodoc/xref/xref_gen_seq.rb index 4a4d17df..f9a7a08d 100644 --- a/lib/isodoc/xref/xref_gen_seq.rb +++ b/lib/isodoc/xref/xref_gen_seq.rb @@ -57,9 +57,9 @@ def sequential_figure_body(subfig, counter, elem, klass, container: false) label = counter.print label &&= label + subfigure_label(subfig) @anchors[elem["id"]] = anchor_struct( - label, container ? elem : nil, + label, elem, @labels[klass] || klass.capitalize, klass, - elem["unnumbered"] + { unnumb: elem["unnumbered"], container: container } ) end @@ -68,8 +68,8 @@ def sequential_table_names(clause, container: false) clause.xpath(ns(".//table")).noblank.each do |t| # labelled_ancestor(t) and next @anchors[t["id"]] = anchor_struct( - c.increment(t).print, container ? t : nil, - @labels["table"], "table", t["unnumbered"] + c.increment(t).print, t, + @labels["table"], "table", { unnumb: t["unnumbered"], container: container } ) end end @@ -80,7 +80,7 @@ def sequential_formula_names(clause, container: false) @anchors[t["id"]] = anchor_struct( c.increment(t).print, t, t["inequality"] ? @labels["inequality"] : @labels["formula"], - "formula", t["unnumbered"] + "formula", { unnumb: t["unnumbered"], container: true } ) end end @@ -123,11 +123,11 @@ def sequential_permission_body(id, elem, label, klass, model, container: false) @anchors[elem["id"]] = model.postprocess_anchor_struct( elem, anchor_struct(id, elem, - label, klass, elem["unnumbered"]) + label, klass, { unnumb: elem["unnumbered"], container: true }) ) model.permission_parts(elem, id, label, klass).each do |n| @anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label], - n[:klass], false) + n[:klass], { unnumb: false, container: true }) end end @@ -183,8 +183,8 @@ def hierarchical_figure_body(num, subfignum, counter, block, klass) label = "#{num}#{hiersep}#{counter.print}" + subfigure_label(subfignum) @anchors[block["id"]] = - anchor_struct(label, nil, @labels[klass] || klass.capitalize, - klass, block["unnumbered"]) + anchor_struct(label, block, @labels[klass] || klass.capitalize, + klass, { unnumb: block["unnumbered"], container: false }) end def hierarchical_table_names(clause, num) @@ -193,7 +193,7 @@ def hierarchical_table_names(clause, num) # labelled_ancestor(t) and next @anchors[t["id"]] = anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", - nil, @labels["table"], "table", t["unnumbered"]) + t, @labels["table"], "table", { unnumb: t["unnumbered"], container: false }) end end @@ -208,9 +208,9 @@ def hierarchical_formula_names(clause, num) c = Counter.new clause.xpath(ns(".//formula")).noblank.each do |t| @anchors[t["id"]] = anchor_struct( - "#{num}#{hiersep}#{c.increment(t).print}", nil, + "#{num}#{hiersep}#{c.increment(t).print}", t, t["inequality"] ? @labels["inequality"] : @labels["formula"], - "formula", t["unnumbered"] + "formula", { unnumb: t["unnumbered"], container: false } ) end end @@ -239,12 +239,13 @@ def hierarchical_permission_children(block, lbl) def hierarchical_permission_body(id, block, label, klass, model) @anchors[block["id"]] = model.postprocess_anchor_struct( - block, anchor_struct(id, nil, - label, klass, block["unnumbered"]) + block, anchor_struct(id, block, + label, klass, { unnumb: block["unnumbered"], container: false }) ) model.permission_parts(block, id, label, klass).each do |n| - @anchors[n[:id]] = anchor_struct(n[:number], nil, n[:label], - n[:klass], false) + # we don't have an n["id"], so we allow n[:id] in anchor_struct + @anchors[n[:id]] = anchor_struct(n[:number], n, n[:label], + n[:klass], { unnumb: false, container: false }) end end end diff --git a/lib/isodoc/xref/xref_sect_gen.rb b/lib/isodoc/xref/xref_sect_gen.rb index 60686692..1ed78348 100644 --- a/lib/isodoc/xref/xref_sect_gen.rb +++ b/lib/isodoc/xref/xref_sect_gen.rb @@ -121,7 +121,7 @@ def preface_names1(clause, title, parent_title, level) def preface_name_anchors(clause, level, title) @anchors[clause["id"]] = { label: nil, level:, - xref: title, title: nil, + xref: "#{title}", title: nil, type: "clause", elem: @labels["clause"] } end @@ -162,9 +162,16 @@ def unnumbered_section_name?(clause) false end + def labelled_autonum(label, elem, autonum) + l10n(<<~SEMX) + #{label} #{autonum} + SEMX + end + def section_name_anchors(clause, num, level) + s = labelled_autonum(@labels["clause"], clause, num) @anchors[clause["id"]] = - { label: num, xref: "#{@labels['clause']} #{num}", + { label: num, xref: s, title: clause_title(clause), level:, type: "clause", elem: @labels["clause"] } end @@ -175,19 +182,21 @@ def annex_name_lbl(clause, num) obl = "(#{@labels['norm_annex']})" title = Common::case_with_markup(@labels["annex"], "capital", @script) - "#{title} #{num}
#{obl}" + s = labelled_autonum(title, clause, num) + "#{s}
#{obl}" end def annex_name_anchors(clause, num, level) label = num level == 1 && clause.name == "annex" and label = annex_name_lbl(clause, num) + s = labelled_autonum(@labels["annex"], clause, num) @anchors[clause["id"]] = { label:, elem: @labels["annex"], type: "clause", subtype: "annex", value: num.to_s, level:, title: clause_title(clause), - xref: "#{@labels['annex']} #{num}" } + xref: s } end def annex_names(clause, num) diff --git a/lib/nokogiri/xml/node.rb b/lib/nokogiri/xml/node.rb index 95b5985e..b0ec45d9 100644 --- a/lib/nokogiri/xml/node.rb +++ b/lib/nokogiri/xml/node.rb @@ -7,6 +7,7 @@ def add_first_child(content) else children.first.previous = content end + self end end end diff --git a/spec/isodoc/blocks_notes_spec.rb b/spec/isodoc/blocks_notes_spec.rb index 582b3c97..cf0d51d6 100644 --- a/spec/isodoc/blocks_notes_spec.rb +++ b/spec/isodoc/blocks_notes_spec.rb @@ -15,29 +15,39 @@ INPUT presxml = <<~OUTPUT - - - - - Table of contents - - Foreword - - NOTE 1 -

- These results are based on a study carried out on three different - types of kernel. -

-
- -

- These results are based on a study carried out on three different - types of kernel. -

-
-
-
-
+ + + + Table of contents + + + Foreword + + + Foreword + + + + + + + NOTE + 1 + + + + + Note + 1 + +

These results are based on a study carried out on three different types of kernel.

+
+ +

These results are based on a study carried out on three different types of kernel.

+
+
+
+
OUTPUT html = <<~OUTPUT #{HTML_HDR} @@ -173,10 +183,13 @@ 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(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) + .convert("test", presxml, true))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes multi-para notes" do @@ -184,11 +197,11 @@ - Table of contents + Table of contents - Foreword + Foreword - NOTE + NOTE

These results are based on a study carried out on three different types of kernel.

These results are based on a study carried out on three different types of kernel.

@@ -210,16 +223,17 @@ OUTPUT expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", input, true))).to be_equivalent_to Xml::C14n.format(output) + .convert("test", input, true))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes non-para notes" do input = <<~INPUT - Table of contents - Foreword - NOTE + Table of contents + Foreword + NOTE
A

B

@@ -294,11 +308,11 @@ input = <<~INPUT - Table of contents + Table of contents - Foreword -

ABC NOTE 1

XYZ

- NOTE 2

XYZ1

+ Foreword +

ABC NOTE 1

XYZ

+ NOTE 2

XYZ1

INPUT @@ -372,9 +386,11 @@ OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(html) + .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) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(doc) end it "converts notes and admonitions intended for coverpage" do @@ -471,12 +487,16 @@ 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(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) + .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) + .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 @@ -521,8 +541,10 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(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 @@ -571,10 +593,13 @@ 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(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) + .convert("test", presxml, true))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes empty admonitions" do @@ -600,8 +625,10 @@ 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(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 @@ -655,10 +682,13 @@ 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(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) + .convert("test", presxml, true))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes box admonitions" do diff --git a/spec/isodoc/postproc_spec.rb b/spec/isodoc/postproc_spec.rb index d1a8d28e..4d1da28d 100644 --- a/spec/isodoc/postproc_spec.rb +++ b/spec/isodoc/postproc_spec.rb @@ -17,9 +17,9 @@ ).convert("test", <<~INPUT, false) - test + test - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -44,9 +44,9 @@ ).convert("spec/assets/test", <<~INPUT, false) - test + test - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -65,9 +65,9 @@ input = <<~INPUT - test + test - Foreword + Foreword

{% elif %}These results are based on a study carried out on three different types of kernel.

@@ -93,7 +93,7 @@ IsoDoc::HtmlConvert.new({ wordstylesheet: "spec/assets/word.css" }) .convert("test", <<~INPUT, false) - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -117,7 +117,7 @@ htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~INPUT, false) - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -197,7 +197,7 @@ olstyle: "l2" }, ).convert("test", <<~INPUT, false) - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -234,7 +234,7 @@ olstyle: "l2" }, ).convert("test", <<~INPUT, false) - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -278,7 +278,7 @@ olstyle: "l2" }, ).convert("test", <<~INPUT, false) - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -316,7 +316,7 @@ olstyle: "l2" }, ).convert("test", <<~INPUT, false) - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -391,8 +391,8 @@ ).convert("test", <<~INPUT, false) - TOC - Foreword + TOC + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -434,16 +434,16 @@ IsoDoc::HtmlConvert.new({ htmlintropage: "spec/assets/htmlintro.html" }) .convert("test", <<~INPUT, false) - ForewordForeword + Foreword FORVORT - First Clause - First Subclause + First Clause + First Subclause SUBCLOZ - Second ClauseSubclause + Second ClauseSubclause INPUT @@ -482,15 +482,15 @@ ).convert("test", <<~INPUT, false) - Clause 4 + Clause 4

This is a footnote.

- Introduction to this<fn reference="2"> + <fmt-title>Introduction to this<fn reference="2"> Formerly denoted as 15 % (m/m). - </fn> +
- Clause 4.2 + Clause 4.2

A

Formerly denoted as 15 % (m/m).

@@ -537,7 +537,7 @@ htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~"INPUT", false) - Foreword + Foreword
Split-it-right sample divider @@ -601,7 +601,7 @@ htmlstylesheet: "html.scss" }, ).convert("test", <<~INPUT, false) - Foreword + Foreword
Split-it-right sample divider @@ -639,7 +639,7 @@ - Clause + Clause

x @@ -689,7 +689,7 @@ - Clause + Clause

@@ -798,7 +798,7 @@ htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~INPUT, false) - Foreword + Foreword
Split-it-right sample divider @@ -839,7 +839,7 @@ htmlstylesheet: "assets/html.scss") .convert("spec/test", <<~"INPUT", false) - Foreword + Foreword
Split-it-right sample divider @@ -879,7 +879,7 @@ .new(htmlstylesheet: "spec/assets/html.scss", datauriimage: true) .convert("test", <<~"INPUT", false) - Foreword + Foreword
Split-it-right sample divider @@ -914,7 +914,7 @@ .new({ htmlstylesheet: "assets/html.scss", datauriimage: true }) .convert("spec/test", <<~"INPUT", false) - Foreword + Foreword
Split-it-right sample divider @@ -949,7 +949,7 @@ .convert("test", <<~INPUT, false) - Terms and Definitions + Terms and Definitions 1.1.paddy

ricerice retaining its husk after threshing

@@ -1003,7 +1003,7 @@ FileUtils.rm_f "test.html" input = <<~INPUT - Foreword + Foreword XML code <xml> & @@ -1275,10 +1275,10 @@ - I am boilerplate + I am boilerplate - Foreword + Foreword

These results are based on a study carried out on three different types of kernel.

@@ -1359,7 +1359,7 @@ FileUtils.rm_f "test.html" input = <<~INPUT - Foreword + Foreword

<X>

diff --git a/spec/isodoc/postproc_word_spec.rb b/spec/isodoc/postproc_word_spec.rb index 7d896d10..9b7731be 100644 --- a/spec/isodoc/postproc_word_spec.rb +++ b/spec/isodoc/postproc_word_spec.rb @@ -13,7 +13,7 @@ htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~INPUT, false) - Foreword + Foreword
Term
Definition
@@ -56,7 +56,7 @@ FileUtils.rm_f "test.html" input = <<~INPUT - Foreword + Foreword
Term
Definition
@@ -124,18 +124,18 @@ input = <<~INPUT - Clause 4 - Introduction<bookmark id="Q"/> to this <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/> <fn reference="1"> + <clause id="A" inline-header="false" obligation="normative" displayorder="1"><fmt-title>Clause 4</fmt-title><clause id="N" inline-header="false" obligation="normative"> + <fmt-title>Introduction<bookmark id="Q"/> to this <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/> <fn reference="1"> <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p> - </fn> + - Clause 4.2 + Clause 4.2

A

Formerly denoted as 15 % (m/m).

- Clause 4.2.1 + Clause 4.2.1 SUBCLOZ
@@ -208,21 +208,21 @@ input = <<~INPUT - Table of Contents + Table of Contents - Clause 4 - Introduction<bookmark id="Q"/> to this <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/> <fn reference="1"> + <clause id="A" inline-header="false" obligation="normative" displayorder="1"><fmt-title>Clause 4</fmt-title><clause id="N" inline-header="false" obligation="normative"> + <fmt-title>Introduction<bookmark id="Q"/> to this <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/> <fn reference="1"> <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p> - </fn> + - Clause 4.2 + Clause 4.2

A

Formerly denoted as 15 % (m/m).

- Clause 4.2.1 + Clause 4.2.1 SUBCLOZ
@@ -285,18 +285,18 @@ - Clause 4 - Introduction<bookmark id="Q"/> to this<fn reference="1"> + <clause id="A" inline-header="false" obligation="normative" displayorder="1"><fmt-title>Clause 4</fmt-title><clause id="N" inline-header="false" obligation="normative"> + <fmt-title>Introduction<bookmark id="Q"/> to this<fn reference="1"> <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p> - </fn> + - Clause 4.2 + Clause 4.2

A

Formerly denoted as 15 % (m/m).

- Clause 4.2.1 + Clause 4.2.1
@@ -389,13 +389,13 @@ - Clause 4 - Introduction<bookmark id="Q"/> to this<fn reference="1"> + <clause id="A" inline-header="false" obligation="normative" displayorder="1"><fmt-title>Clause 4</fmt-title><clause id="N" inline-header="false" obligation="normative"> + <fmt-title>Introduction<bookmark id="Q"/> to this<fn reference="1"> <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p> - </fn> + - Clause 4.2 + Clause 4.2 /ogc/recommendation/wfs/3 @@ -411,7 +411,7 @@

Formerly denoted as 15 % (m/m).

- Clause 4.2.1 + Clause 4.2.1
@@ -459,9 +459,9 @@ toc_input = input.sub(%r{}, <<~MISC, - List of tables - List of figures - List of recommendations + List of tables + List of figures + List of recommendations MISC ) IsoDoc::WordConvert.new( @@ -575,7 +575,7 @@ IsoDoc::WordConvert.new(options) .convert("test", <<~INPUT, false) - Foreword + Foreword
  • A

    B

  • @@ -648,7 +648,7 @@ FileUtils.rm_f "test.html" IsoDoc::WordConvert.new(options).convert("test", <<~INPUT, false) - Foreword + Foreword

    ABC

    @@ -680,7 +680,7 @@ IsoDoc::WordConvert.new(options) .convert("test", <<~INPUT, false) - Foreword + Foreword
    Typical arrangement of the far-field scan set-up @@ -714,7 +714,7 @@ IsoDoc::WordConvert.new(options) .convert("test", <<~INPUT, false) - Foreword + Foreword + +

    Output wavelength (μm)

    @@ -762,7 +762,7 @@ IsoDoc::WordConvert.new(options) .convert("test", <<~INPUT, false) - Foreword + Foreword

    Output wavelength

    @@ -816,7 +816,7 @@ ).convert("test", <<~INPUT, false) - Document title + Document title 1.2 @@ -828,24 +828,24 @@ - Preface 1 + Preface 1

    This is a paragraph

    AB
    - Preface 1.1 + Preface 1.1

    On my side

    Upright again

    - Preface 1.3 + Preface 1.3

    And still upright

    - Foreword + Foreword

    For further information on the Foreword, see ISO/IEC Directives, Part 2, 2016, Clause 12.

    @@ -871,7 +871,7 @@
    - Annex 1 + Annex 1
    INPUT diff --git a/spec/isodoc/xref_format_spec.rb b/spec/isodoc/xref_format_spec.rb index 5ab2a015..ae3ffdaa 100644 --- a/spec/isodoc/xref_format_spec.rb +++ b/spec/isodoc/xref_format_spec.rb @@ -486,7 +486,7 @@ it "ignores locations in xrefs" do input = <<~INPUT - Foreword + Foreword

    6.4 List 1.a) to 2.b)

    diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e3f0c13f..614a70aa 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -64,6 +64,7 @@ def metadata(hash) def strip_guid(xml) xml.gsub(%r{ id="_[^"]+"}, ' id="_"') .gsub(%r{ target="_[^"]+"}, ' target="_"') + .gsub(%r{ source="_[^"]+"}, ' source="_"') .gsub(%r( href="#_?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12,13}"), ' href="#_"') .gsub(%r( id="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12,13}"), ' id="_"') .gsub(%r( id="ftn[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="ftn_"') From bab7aca7fe51068b02aa2561b8bd60bf5b69a09f Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 13 Nov 2024 21:21:40 +1100 Subject: [PATCH 02/78] rationalise note, admon processing: https://github.com/metanorma/isodoc/issues/617 --- lib/isodoc/function/blocks_example_note.rb | 54 ++- lib/isodoc/function/inline.rb | 3 +- lib/isodoc/function/section_titles.rb | 2 +- lib/isodoc/function/terms.rb | 20 +- lib/isodoc/presentation_function/autonum.rb | 18 +- lib/isodoc/word_function/body.rb | 36 +- spec/isodoc/blocks_notes_spec.rb | 436 +++++++++++++------- 7 files changed, 357 insertions(+), 212 deletions(-) diff --git a/lib/isodoc/function/blocks_example_note.rb b/lib/isodoc/function/blocks_example_note.rb index a7f51e76..dc768c2e 100644 --- a/lib/isodoc/function/blocks_example_note.rb +++ b/lib/isodoc/function/blocks_example_note.rb @@ -42,7 +42,9 @@ def example_table_parse(node, out) example_label(node, td, node.at(ns("./fmt-name"))) end tr.td **EXAMPLE_TD_ATTR do |td| - node.children.each { |n| parse(n, td) unless n.name == "fmt-name" } + node.children.each do |n| + parse(n, td) unless n.name == "fmt-name" + end end end end @@ -52,26 +54,40 @@ def example_parse(node, out) example_div_parse(node, out) end + def starts_with_para?(node) + node.elements.each do |n| + %w(title fmt-title fmt-xref-label fmt-name name).include?(n) and next + n.name == "p" and return true + end + false + end + + def note_p_class + nil + end + def note_p_parse(node, div) - name = node.at(ns("./fmt-name"))&.remove - div.p do |p| + name = node.at(ns("./fmt-name")) + para = node.at(ns("./p")) + div.p **attr_code(class: note_p_class) do |p| name and p.span class: "note_label" do |s| name.children.each { |n| parse(n, s) } end - insert_tab(p, 1) - node.first_element_child.children.each { |n| parse(n, p) } + insert_tab(p, 1) # TODO to Presentation XML + children_parse(para, p) end - node.element_children[1..].each { |n| parse(n, div) } + para.xpath("./following-sibling::*").each { |n| parse(n, div) } end def note_parse1(node, div) - name = node.at(ns("./fmt-name")) and div.p do |p| - p.span class: "note_label" do |s| - name.remove.children.each { |n| parse(n, s) } + name = node.at(ns("./fmt-name")) and + div.p **attr_code(class: note_p_class) do |p| + p.span class: "note_label" do |s| + name.remove.children.each { |n| parse(n, s) } + end + insert_tab(p, 1) # TODO to Presentation XML end - insert_tab(p, 1) - end - node.children.each { |n| parse(n, div) } + children_parse(node, div) end def keep_style(node) @@ -94,7 +110,7 @@ def note_attrs(node) def note_parse(node, out) @note = true out.div **note_attrs(node) do |div| - if node&.at(ns("./*[local-name() != 'fmt-name'][1]"))&.name == "p" + if starts_with_para?(node) note_p_parse(node, div) else note_parse1(node, div) @@ -105,7 +121,7 @@ def note_parse(node, out) def admonition_name_parse(_node, div, name) div.p class: "AdmonitionTitle", style: "text-align:center;" do |p| - name.children.each { |n| parse(n, p) } + children_parse(name, p) end end @@ -124,7 +140,7 @@ def admonition_attrs(node) def admonition_parse(node, out) out.div **admonition_attrs(node) do |div| - if node&.at(ns("./*[local-name() != 'fmt-name'][1]"))&.name == "p" + if starts_with_para?(node) admonition_p_parse(node, div) else admonition_parse1(node, div) @@ -139,14 +155,16 @@ def admonition_p_parse(node, div) # code to allow name and first paragraph to be rendered in same block def admonition_name_in_first_para(node, div) + name = node.at(ns("./fmt-name")) + para = node.at(ns("./p")) div.p do |p| if name = admonition_name(node, node["type"])&.remove name.children.each { |n| parse(n, p) } - admonition_name_para_delim(p) + admonition_name_para_delim(p) # TODO to Presentation XML end - node.first_element_child.children.each { |n| parse(n, p) } + para.children.each { |n| parse(n, p) } end - node.element_children[1..].each { |n| parse(n, div) } + para.xpath("./following-sibling::*").each { |n| parse(n, div) } end def admonition_name_para_delim(para) diff --git a/lib/isodoc/function/inline.rb b/lib/isodoc/function/inline.rb index 54c8956c..da3c2f8e 100644 --- a/lib/isodoc/function/inline.rb +++ b/lib/isodoc/function/inline.rb @@ -19,7 +19,8 @@ def location_parse(node, out); end # Presentation XML classes which we need not pass on to HTML or DOC SPAN_UNWRAP_CLASSES = - %w[fmt-caption-label fmt-label-delim fmt-element-name].freeze + %w[fmt-caption-label fmt-label-delim fmt-caption-delim fmt-autonum-delim + fmt-element-name].freeze def span_parse(node, out) klass = node["style"] || node["class"] diff --git a/lib/isodoc/function/section_titles.rb b/lib/isodoc/function/section_titles.rb index c53d47c2..b3b99b6a 100644 --- a/lib/isodoc/function/section_titles.rb +++ b/lib/isodoc/function/section_titles.rb @@ -71,7 +71,7 @@ def clause_name(_node, title, div, header_class) div.h1 **attr_code(header_class) do |h1| if title.is_a?(String) then h1 << title else - title&.children&.each { |c2| parse(c2, h1) } + children_parse(title, h1) clause_parse_subtitle(title, h1) end end diff --git a/lib/isodoc/function/terms.rb b/lib/isodoc/function/terms.rb index cd6de2ce..6c53b331 100644 --- a/lib/isodoc/function/terms.rb +++ b/lib/isodoc/function/terms.rb @@ -37,15 +37,21 @@ def para_then_remainder(first, node, para, div) end end - def termnote_parse(node, out) - name = node&.at(ns("./fmt-name"))&.remove - out.div **note_attrs(node) do |div| - div.p do |p| - name&.children&.each { |n| parse(n, p) } - p << " " - para_then_remainder(node.first_element_child, node, p, div) + def termnote_p_class + nil + end + + def termnote_parse(node, div) + name = node.at(ns("./fmt-name")) + para = node.at(ns("./p")) + div.p **attr_code(class: termnote_p_class) do |p| + name and p.span class: "note_label" do |s| + name.children.each { |n| parse(n, s) } end + p << " " # TODO to Presentation XML + para.children.each { |n| parse(n, p) } end + para.xpath("./following-sibling::*").each { |n| parse(n, div) } end def termref_parse(node, out) diff --git a/lib/isodoc/presentation_function/autonum.rb b/lib/isodoc/presentation_function/autonum.rb index 7a45a8cf..0248d00b 100644 --- a/lib/isodoc/presentation_function/autonum.rb +++ b/lib/isodoc/presentation_function/autonum.rb @@ -4,6 +4,7 @@ def prefix_name(node, delims, label, elem) label&.empty? and label = nil name, ins, ids, number = prefix_name_prep(node, elem) label and ins.next = fmt_label(label, number, ids) + # autonum can be empty, e.g single note in clause: "NOTE []" number and node["autonum"] = number c = fmt_caption(label, elem, name, ids, delims) and ins.next = c node.at(ns("./sentinel"))&.remove @@ -27,16 +28,17 @@ def autonum(id, num) "#{num}" end - def fmt_label(label, _number, ids) + def fmt_label(_label, _number, ids) x = @xrefs.anchor(ids[:elem], :xref, false) and return "#{x}" "" - #label = cleanup_entities(label.strip) - #<<~XML - ##{label}#{xref} - #XML + # label = cleanup_entities(label.strip) + # <<~XML + # #{label}#{xref} + # XML end + # Remove ".blank?" tests if we want empty delim placeholders for manipulation def fmt_caption(label, elem, name, ids, delims) c = if name && !name.children.empty? label.blank? or @@ -44,9 +46,9 @@ def fmt_caption(label, elem, name, ids, delims) attr = " element='#{elem}' source='#{ids[:name]}'" "#{label}#{d}#{to_xml(name.children)}" elsif label then label - else return - end - f = "#{delims[:label]}" + else return end + !delims[:label].blank? and + f = "#{delims[:label]}" "#{c}#{f}" end end diff --git a/lib/isodoc/word_function/body.rb b/lib/isodoc/word_function/body.rb index 5c888a04..43effad7 100644 --- a/lib/isodoc/word_function/body.rb +++ b/lib/isodoc/word_function/body.rb @@ -102,40 +102,12 @@ def figure_aside_process(fig, aside, key) end end - def note_p_parse(node, div) - name = node.at(ns("./fmt-name"))&.remove - div.p class: "Note" do |p| - p.span class: "note_label" do |s| - name&.children&.each { |n| parse(n, s) } - end - insert_tab(p, 1) - node.first_element_child.children.each { |n| parse(n, p) } - end - node.element_children[1..].each { |n| parse(n, div) } + def note_p_class + "Note" end - def note_parse1(node, div) - name = node.at(ns("./fmt-name"))&.remove - div.p class: "Note" do |p| - p.span class: "note_label" do |s| - name&.children&.each { |n| parse(n, s) } - end - insert_tab(p, 1) - end - node.children.each { |n| parse(n, div) } - end - - def termnote_parse(node, out) - name = node&.at(ns("./fmt-name"))&.remove - out.div **note_attrs(node) do |div| - div.p class: "Note" do |p| - if name - name.children.each { |n| parse(n, p) } - p << " " - end - para_then_remainder(node.first_element_child, node, p, div) - end - end + def termnote_p_class + "Note" end def para_attrs(node) diff --git a/spec/isodoc/blocks_notes_spec.rb b/spec/isodoc/blocks_notes_spec.rb index cf0d51d6..1be8b5d4 100644 --- a/spec/isodoc/blocks_notes_spec.rb +++ b/spec/isodoc/blocks_notes_spec.rb @@ -17,24 +17,22 @@ presxml = <<~OUTPUT - + Table of contents - Foreword - - - Foreword - - - + Foreword + + + Foreword + + NOTE 1 - Note @@ -100,7 +98,6 @@

    -   These results are based on a study carried out on three different types of kernel. @@ -115,15 +112,16 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(html) - expect(Xml::C14n.format(IsoDoc::WordConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(doc) end @@ -141,33 +139,50 @@ INPUT presxml = <<~OUTPUT - - - - - Table of contents - - Foreword - - NOTE 1 -

    - These results are based on a study carried out on three different - types of kernel. -

    - - - NOTE 2 -

    - These results are based on a study carried out on three different - types of kernel. -

    -
    - - - + + + + Table of contents + + + Foreword + + + Foreword + + + + + + NOTE + 1 + + + + Note + 1 + +

    These results are based on a study carried out on three different types of kernel.

    +
    + + + + NOTE + 2 + + + + Note + 2 + +

    These results are based on a study carried out on three different types of kernel.

    +
    +
    +
    +
    OUTPUT - output = <<~OUTPUT + html = <<~OUTPUT #{HTML_HDR}
    @@ -183,13 +198,14 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .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) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(html) end it "processes multi-para notes" do @@ -403,23 +419,40 @@ INPUT presxml = <<~OUTPUT - - - - Table of contents - - Foreword - - NOTE -

    XYZ

    -
    - - WARNING -

    XYZ

    -
    -
    -
    -
    + + + + Table of contents + + + Foreword + + + Foreword + + + + + + NOTE + + + + Note + +

    XYZ

    +
    + + + + WARNING + + +

    XYZ

    +
    +
    +
    +
    OUTPUT html = <<~OUTPUT #{HTML_HDR} @@ -487,15 +520,16 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .to be_equivalent_to Xml::C14n.format(presxml) expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true)))) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(html) expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({}) - .convert("test", presxml, true)))) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(doc) end @@ -510,36 +544,81 @@ INPUT output = <<~OUTPUT - + - - Table of contents - - Foreword -
    - Figure 1 - - NOTE -

    XYZ

    -
    -
    - - Table 1 - - NOTE -

    XYZ

    -
    -
    -

    - ABC - - NOTE -

    XYZ

    - -

    -
    + + Table of contents + + + Foreword + + + Foreword + + +
    + + + Figure + 1 + + + + Figure + 1 + + + + + NOTE + + + + Note + +

    XYZ

    +
    +
    + + + + Table + 1 + + + + Table + 1 + + + + + NOTE + + + + Note + +

    XYZ

    +
    +
    +

    + ABC + + + + NOTE + + + + Note + +

    XYZ

    + +

    +
    -
    +
    OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert .new(presxml_options) @@ -563,12 +642,22 @@ presxml = <<~INPUT - - Table of contents - - Foreword + + Table of contents + + + Foreword + + + Foreword + + - CAUTION + + + CAUTION + +

    Only use paddy or parboiled rice for the determination of husked rice yield.

    @@ -593,12 +682,13 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(output) end @@ -614,12 +704,22 @@ presxml = <<~OUTPUT - - Table of contents - - Foreword + + Table of contents + + + Foreword + + + Foreword + + - CAUTION + + + CAUTION + + @@ -647,22 +747,39 @@ INPUT presxml = <<~INPUT - + - Table of contents - - Foreword - - Title -

    Only use paddy or parboiled rice for the determination of husked rice yield.

    -
    - - Title -

    Only use paddy or parboiled rice for the determination of husked rice yield.

    -
    -
    -
    + Table of contents + + + Foreword + + + Foreword + + + + Title + + + Title + + +

    Only use paddy or parboiled rice for the determination of husked rice yield.

    +
    + + Title + + + Title + + +

    Only use paddy or parboiled rice for the determination of husked rice yield.

    +
    +
    +
    +
    INPUT output = <<~OUTPUT #{HTML_HDR} @@ -682,12 +799,13 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(output) end @@ -707,21 +825,48 @@ INPUT presxml = <<~INPUT - + - Table of contents - - Foreword - - Box 1 — Title -

    Only use paddy or parboiled rice for the determination of husked rice yield.

    -
    - - Box 2 -

    Only use paddy or parboiled rice for the determination of husked rice yield.

    -
    -
    -
    + Table of contents + + + Foreword + + + Foreword + + + + Title + + + Box + 1 +  — + Title + + + + Box + 1 + +

    Only use paddy or parboiled rice for the determination of husked rice yield.

    +
    + + + + Box + 2 + + + + Box + 2 + +

    Only use paddy or parboiled rice for the determination of husked rice yield.

    +
    +
    +
    INPUT output = <<~OUTPUT @@ -742,12 +887,13 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(output) end end From 941a9a2d28c26381e858d8493c9d3d19f1cd1d38 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 13 Nov 2024 22:56:34 +1100 Subject: [PATCH 03/78] formula label delims, figure and sourcecode label processing, ToC entry delimiters, clause label processing: https://github.com/metanorma/isodoc/issues/617 --- lib/isodoc/presentation_function/block.rb | 4 +- lib/isodoc/presentation_function/image.rb | 12 +- lib/isodoc/presentation_function/section.rb | 2 +- .../presentation_function/sourcecode.rb | 11 +- lib/isodoc/xref/xref_anchor.rb | 10 +- lib/isodoc/xref/xref_sect_gen.rb | 14 +- spec/isodoc/blocks_spec.rb | 953 ++++++++++++------ 7 files changed, 696 insertions(+), 310 deletions(-) diff --git a/lib/isodoc/presentation_function/block.rb b/lib/isodoc/presentation_function/block.rb index 5c38e91a..440914fb 100644 --- a/lib/isodoc/presentation_function/block.rb +++ b/lib/isodoc/presentation_function/block.rb @@ -21,7 +21,7 @@ def formula(docxml) def formula1(elem) formula_where(elem.at(ns("./dl"))) lbl = @xrefs.anchor(elem["id"], :label, false) - lbl.nil? || lbl.empty? or prefix_name(elem, {}, "(#{lbl})", "name") + lbl.nil? || lbl.empty? or prefix_name(elem, {}, lbl, "name") end def formula_where(dlist) @@ -40,7 +40,7 @@ def example1(elem) lbl = "#{@i18n.example}" (n.nil? || n[:label].nil? || n[:label].empty?) or lbl = l10n("#{lbl} #{autonum(elem['id'], n[:label])}") - prefix_name(elem, { caption: block_delim}, lbl, "name") + prefix_name(elem, { caption: block_delim }, lbl, "name") end def note(docxml) diff --git a/lib/isodoc/presentation_function/image.rb b/lib/isodoc/presentation_function/image.rb index b4badb4b..2100b5b1 100644 --- a/lib/isodoc/presentation_function/image.rb +++ b/lib/isodoc/presentation_function/image.rb @@ -48,12 +48,14 @@ def figure1(elem) return sourcecode1(elem) figure_fn(elem) figure_key(elem.at(ns("./dl"))) - figure_label?(elem) or return nil - lbl = @xrefs.anchor(elem["id"], :label, false) or return + #figure_label?(elem) or return nil + #lbl = @xrefs.anchor(elem["id"], :label, false) or return + lbl = @xrefs.anchor(elem["id"], :label, false) + lbl and a = autonum(elem["id"], lbl) # no xref, no label: this can be set in xref - a = autonum(elem["id"], lbl) - s = "#{figure_label(elem)} #{a}" - prefix_name(elem, { caption: block_delim }, l10n(s), "name") + lbl && figure_label?(elem) and + s = "#{figure_label(elem)} #{a}" + prefix_name(elem, { caption: block_delim }, l10n(s&.strip), "name") end # move footnotes into key, and get rid of footnote reference diff --git a/lib/isodoc/presentation_function/section.rb b/lib/isodoc/presentation_function/section.rb index e1e6b255..6dfc058b 100644 --- a/lib/isodoc/presentation_function/section.rb +++ b/lib/isodoc/presentation_function/section.rb @@ -256,7 +256,7 @@ def toc(docxml) def toc_refs(docxml) docxml.xpath(ns("//toc//xref[text()]")).each do |x| lbl = @xrefs.anchor(x["target"], :label) or next - x.add_first_child "#{lbl}" + x.add_first_child "#{lbl}" end end end diff --git a/lib/isodoc/presentation_function/sourcecode.rb b/lib/isodoc/presentation_function/sourcecode.rb index 42a4e636..7060b8fa 100644 --- a/lib/isodoc/presentation_function/sourcecode.rb +++ b/lib/isodoc/presentation_function/sourcecode.rb @@ -150,11 +150,12 @@ def source_lex(elem) end def source_label(elem) - labelled_ancestor(elem) and return - lbl = @xrefs.anchor(elem["id"], :label, false) or return - a = autonum(elem["id"], lbl) - s = "#{lower2cap @i18n.figure} #{a}" - prefix_name(elem, { caption: block_delim }, l10n(s), "name") + if !labelled_ancestor(elem) && # do not number if labelled_ancestor + lbl = @xrefs.anchor(elem["id"], :label, false) + a = autonum(elem["id"], lbl) + s = "#{lower2cap @i18n.figure} #{a}" + end + prefix_name(elem, { caption: block_delim }, l10n(s&.strip), "name") end end end diff --git a/lib/isodoc/xref/xref_anchor.rb b/lib/isodoc/xref/xref_anchor.rb index 647ab067..46d03a06 100644 --- a/lib/isodoc/xref/xref_anchor.rb +++ b/lib/isodoc/xref/xref_anchor.rb @@ -36,7 +36,7 @@ def anchor_struct_label(lbl, node, elem) "#{lbl}" "#{elem} #{s}" else - lbl.to_s + anchor_struct_value(lbl, elem) end end @@ -50,9 +50,11 @@ def anchor_struct_xref(lbl, node, elem) def anchor_struct_value(lbl, elem) case elem - when @labels["formula"], @labels["inequality"] then "(#{lbl})" + when @labels["formula"], @labels["inequality"] then <<~SPAN.strip + (#{lbl}) + SPAN else - lbl + lbl.to_s end end @@ -64,7 +66,7 @@ def anchor_struct(lbl, node, elem_name, type, opt = {}) anchor_struct_xref(opt[:unnumb] == "true" ? "(??)" : lbl, node, elem_name) ret[:container] = @klass.get_clause_id(node) if opt[:container] - ret[:value] = anchor_struct_value(lbl, elem_name) + ret[:value] = lbl ret end end diff --git a/lib/isodoc/xref/xref_sect_gen.rb b/lib/isodoc/xref/xref_sect_gen.rb index 1ed78348..ebee25d2 100644 --- a/lib/isodoc/xref/xref_sect_gen.rb +++ b/lib/isodoc/xref/xref_sect_gen.rb @@ -169,9 +169,10 @@ def labelled_autonum(label, elem, autonum) end def section_name_anchors(clause, num, level) - s = labelled_autonum(@labels["clause"], clause, num) + xref = labelled_autonum(@labels["clause"], clause, num) + label = "#{num}" @anchors[clause["id"]] = - { label: num, xref: s, + { label:, xref:, title: clause_title(clause), level:, type: "clause", elem: @labels["clause"] } end @@ -187,16 +188,15 @@ def annex_name_lbl(clause, num) end def annex_name_anchors(clause, num, level) - label = num + label = "#{num}" level == 1 && clause.name == "annex" and label = annex_name_lbl(clause, num) - s = labelled_autonum(@labels["annex"], clause, num) + xref = labelled_autonum(@labels["annex"], clause, num) @anchors[clause["id"]] = - { label:, + { label:, xref:, elem: @labels["annex"], type: "clause", subtype: "annex", value: num.to_s, level:, - title: clause_title(clause), - xref: s } + title: clause_title(clause) } end def annex_names(clause, num) diff --git a/spec/isodoc/blocks_spec.rb b/spec/isodoc/blocks_spec.rb index c21fcfb6..6a102f54 100644 --- a/spec/isodoc/blocks_spec.rb +++ b/spec/isodoc/blocks_spec.rb @@ -73,7 +73,7 @@
    -
    Figure
    +
    Imago

    This is not generalised further.

    @@ -84,85 +84,128 @@ INPUT presxml = <<~OUTPUT - - - Document title - en - - - published - - - 2020 - - - article - - - - - Table of contents - - - -

    Document title

    - - 1.<tab/>Change Clause -

    - - This table contains information on polygon cells which are not - included in ISO 10303-52. Remove table 2 completely and replace - with: - -

    - - - Table 2 — Edges of triangle and quadrilateral cells - - + + + Document title + en + + + published + + + 2020 + + + article + + + + + Table of contents + + + +

    Document title

    + + Change Clause + + + 1 + . + + + + Change Clause + + + + Clause + 1 + +

    + + This table contains information on polygon cells which are not + included in ISO 10303-52. Remove table 2 completely and replace + with: + +

    + +
    + Edges of triangle and quadrilateral cells + + + Table + 2 +  — + Edges of triangle and quadrilateral cells + + + + Table + 2 + + + - - + + - - + + - - + + - - + + - - + + - - -
    triangle quadrilateral
    edge vertices edge vertices
    1 1, 2 1 1, 2
    2 2, 3 2 2, 3
    3 3, 1 3 3, 4
    4 4, 1
    -
    Figure
    - EXAMPLE A.7 -

    This is not generalised further.

    -
    -
    -
    -
    -
    +
    +
    + Imago + + + Imago + + +
    + + + + EXAMPLE + A.7 + + + + Example + A.7 + +

    This is not generalised further.

    +
    + + + + OUTPUT html = <<~OUTPUT @@ -232,7 +275,7 @@
    -

    Figure

    +

    Imago

    EXAMPLE A.7

    @@ -244,12 +287,15 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) - .convert("test", input, true)) - .sub(%r{.*}m, ""))) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + .sub(%r{.*}m, "") + expect(Xml::C14n.format(strip_guid(pres_output))) .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(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(html) end it "processes examples" do @@ -267,18 +313,38 @@ INPUT presxml = <<~OUTPUT - - Table of contents + Table of contents - Foreword - - EXAMPLE — Title + + Foreword + + + Foreword + + + + Title + + + EXAMPLE +  — + Title + + + + Example +

    Hello

    - Sample + Sample + + + Sample + +
    @@ -294,12 +360,12 @@

    EXAMPLE — Title

    Hello

    -
    -          
    -           -
    -         -
    +
    +                         
    +   +
    +   +

    Sample

    @@ -307,7 +373,7 @@ OUTPUT - doc = <<~OUTPUT + word = <<~OUTPUT @@ -333,12 +399,12 @@

    EXAMPLE — Title

    Hello

    -

    -
    -           -
    -         -

    +

    +
    +   +
    +   +

    Sample

    @@ -352,12 +418,17 @@ 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(html) - expect(Xml::C14n.format(IsoDoc::WordConvert.new({}) - .convert("test", presxml, true))).to be_equivalent_to Xml::C14n.format(doc) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) + .to be_equivalent_to Xml::C14n.format(presxml) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(html) + expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(word) end it "processes sequences of examples" do @@ -378,31 +449,67 @@
    INPUT output = <<~OUTPUT - - - + + - Table of contents - - Foreword - - EXAMPLE 1 -

    Hello

    -
    - - EXAMPLE 2 — Title -

    Hello

    -
    - - EXAMPLE -

    Hello

    -
    -
    -
    -
    + Table of contents + + + Foreword + + + Foreword + + + + + + EXAMPLE + 1 + + + + Example + 1 + +

    Hello

    +
    + + Title + + + EXAMPLE + 2 +  — + Title + + + + Example + 2 + +

    Hello

    +
    + + + + EXAMPLE + + + + Example + (??) + +

    Hello

    +
    +
    +
    +
    OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(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 formulae" do @@ -433,9 +540,15 @@ - Table of contents + Table of contents - Foreword + + Foreword + + + Foreword + + r = 1 %

    where

    @@ -447,12 +560,34 @@

    is the repeatability limit.

- - NOTE + + + + NOTE + + + + Note +

[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.

- (1) + + + + ( + 1 + ) + + + + Formula + + ( + 1 + ) + + r = 1 %
@@ -555,12 +690,17 @@ 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(html) - expect(Xml::C14n.format(IsoDoc::WordConvert.new({}) - .convert("test", presxml, true))).to be_equivalent_to Xml::C14n.format(word) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) + .to be_equivalent_to Xml::C14n.format(presxml) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(html) + expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(word) end it "processes paragraph attributes" do @@ -568,9 +708,9 @@ - Table of contents + Table of contents - Foreword + Foreword

Vache Equipment
Fictitious
World

@@ -649,9 +789,15 @@ - Table of contents + Table of contents - Foreword + + Foreword + + + Foreword + +

This International Standard gives the minimum specifications for rice (Oryza sativa L.) which is subject to international trade. It is applicable to the following types: husked rice and milled rice, parboiled or not, intended for direct human consumption. It is neither applicable to other products derived from rice, nor to waxy rice (glutinous rice).

ISO, @@ -665,7 +811,7 @@ INPUT - html = <<~OUTPUT + output = <<~OUTPUT #{HTML_HDR}

@@ -680,20 +826,21 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .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(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes permissions" do input = <<~INPUT - + /ogc/recommendation/wfs/2 /ss/584/2015/level/1 RFC 2616 (HTTP/1.1) @@ -723,20 +870,20 @@

The measurement target shall be measured as:

- + r/1 = 0

The following code will be run for verification:

- CoreRoot(success): HttpResponse + CoreRoot(success): HttpResponse if (success) recommendation(label: success-response) end
- success-response() + success-response()

Hello

@@ -753,10 +900,17 @@ - Table of contents + Table of contents - Foreword - Permission 1:
/ogc/recommendation/wfs/2

Subject: user
+ + Foreword + + + Foreword + + + + Permission 1:
/ogc/recommendation/wfs/2

Subject: user
Subject: non-user
Inherits: /ss/584/2015/level/1
Inherits: RFC 2616 (HTTP/1.1)
@@ -769,12 +923,27 @@

As for the measurement targets,

The measurement target shall be measured as:

- (1) + + + + ( + 1 + ) + + + + Formula + + ( + 1 + ) + + r/1 = 0

The following code will be run for verification:

- CoreRoot(success): HttpResponse + CoreRoot(success): HttpResponse if (success) recommendation(label: success-response) end @@ -784,7 +953,12 @@
- Bibliography + Bibliography + + + Bibliography + + R. FIELDING, J. GETTYS, J. MOGUL, H. FRYSTYK, L. MASINTER, P. LEACH and T. BERNERS-LEE. Hypertext Transfer Protocol — HTTP/1.1. In: RFC. 1999. Fremont, CA. [1] IETF RFC 2616 @@ -796,7 +970,7 @@
OUTPUT - html = <<~OUTPUT + output = <<~OUTPUT #{HTML_HDR}
@@ -837,26 +1011,31 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .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(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(output) - presxml = presxml.sub("

The following code will be run for verification:

- CoreRoot(success): HttpResponse + CoreRoot(success): HttpResponse if (success) recommendation(label: success-response) end
- success-response() + success-response()

Hello

@@ -917,9 +1096,15 @@ - Table of contents + Table of contents - Foreword + + Foreword + + + Foreword + + Requirement:
/ogc/recommendation/wfs/2. A New Requirement

Subject: user
Inherits: /ss/584/2015/level/1

I recommend this.

@@ -927,12 +1112,27 @@

As for the measurement targets,

The measurement target shall be measured as:

- (1) + + + + ( + 1 + ) + + + + Formula + + ( + 1 + ) + + r/1 = 0

The following code will be run for verification:

- CoreRoot(success): HttpResponse + CoreRoot(success): HttpResponse if (success) recommendation(label: success-response) end @@ -972,34 +1172,36 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(output) presxml = presxml .sub(" - + /ogc/recommendation/wfs/2 /ss/584/2015/level/1 typetext @@ -1028,20 +1230,20 @@

The measurement target shall be measured as:

- + r/1 = 0

The following code will be run for verification:

- CoreRoot(success): HttpResponse + CoreRoot(success): HttpResponse if (success) recommendation(label: success-response) end
- success-response() + success-response()

Hello

@@ -1054,25 +1256,53 @@ - Table of contents + Table of contents - Foreword - Recommendation 1:
/ogc/recommendation/wfs/2

Obligation: shall,could
+ + Foreword + + + Foreword + + + + Recommendation 1:
/ogc/recommendation/wfs/2
+ + Recommendation + 1 + +

Obligation: shall,could
Subject: user
Inherits: /ss/584/2015/level/1
Type: text
- Language: BASIC

+ Language: BASIC

+

I recommend this.

As for the measurement targets,

The measurement target shall be measured as:

- (1) + + + + ( + 1 + ) + + + + Formula + + ( + 1 + ) + + r/1 = 0

The following code will be run for verification:

- CoreRoot(success): HttpResponse + CoreRoot(success): HttpResponse if (success) recommendation(label: success-response) end @@ -1112,25 +1342,27 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(output) presxml = presxml .sub(" - Table of contents + Table of contents - Foreword + Foreword + + + Foreword + + <A> Hello </A> @@ -1211,14 +1448,14 @@ - Table of contents + Table of contents - Foreword + Foreword <A> INPUT - output = <<~OUTPUT + html = <<~OUTPUT #{HTML_HDR}
@@ -1228,12 +1465,13 @@ OUTPUT - presxml = IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options.merge(output_formats: { html: "html", rfc: "rfc" })) .convert("test", input, true) expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true)))) - .to be_equivalent_to Xml::C14n.format(output) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(html) + end it "ignores columnbreak" do @@ -1241,10 +1479,10 @@ - Table of contents + Table of contents - Foreword + Foreword INPUT @@ -1343,91 +1581,231 @@ INPUT presxml = <<~INPUT - - - Document title - en - - - published - - - 2021 - - - article - - - - - Table of contents - - - -

Document title

- - 1.<tab/>Clause 1 - - 1.1.<tab/>Clause 1A - - 1.1.1.<tab/>Clause 1Aa + + + Document title + en + + + published + + + 2021 + + + article + + + + + Table of contents - - 1.1.2.<tab/>Clause 1Ab + + +

Document title

+ + Clause 1 + + + 1 + . + + + + Clause 1 + + + + Clause + 1 + + + Clause 1A + + + 1.1 + . + + + + Clause 1A + + + + Clause + 1.1 + + + Clause 1Aa + + + 1.1.1 + . + + + + Clause 1Aa + + + + Clause + 1.1.1 + + + + Clause 1Ab + + + 1.1.2 + . + + + + Clause 1Ab + + + + Clause + 1.1.2 + + + + + Clause 1B + + + 1.2 + . + + + + Clause 1B + + + + Clause + 1.2 + + + Clause 1Ba + + + 1.2.1 + . + + + + Clause 1Ba + + + + Clause + 1.2.1 + + + -
- - 1.2.<tab/>Clause 1B - - 1.2.1.<tab/>Clause 1Ba + + Clause 2 + + + 2 + . + + + + Clause 2 + + + + Clause + 2 + +

And introducing:

+ +
    +
  • + + 1.1 + + + + Clause 1A + +
  • +
  • +
      +
    • + + 1.1.1 + + + + Clause 1Aa + +
    • +
    • + + 1.1.2 + + + + Clause 1Ab + +
    • +
    +
  • +
  • + + 1.2 + + + + Clause 1B + +
  • +
  • +
      +
    • + + 1.2.1 + + + + Clause 1Ba + +
    • +
    +
  • +
+
+ +
    +
  • + + 1.1 + + + + Clause 1A + +
  • +
  • + + 1.2 + + + + Clause 1B + +
  • +
+
-
-
- - 2.<tab/>Clause 2 -

And introducing:

- -
    -
  • - 1.1Clause 1A -
  • -
  • -
      -
    • - 1.1.1Clause 1Aa -
    • -
    • - 1.1.2Clause 1Ab -
    • -
    -
  • -
  • - 1.2Clause 1B -
  • -
  • -
      -
    • - 1.2.1Clause 1Ba -
    • -
    -
  • -
-
- -
    -
  • - 1.1Clause 1A -
  • -
  • - 1.2Clause 1B -
  • -
-
-
-
-
+ + INPUT - output = <<~OUTPUT + html = <<~OUTPUT #{HTML_HDR}

Document title

@@ -1501,11 +1879,14 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) - .convert("test", input, true) - .sub(%r{.*}m, "")))) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + .sub(%r{.*}m, "") + expect(Xml::C14n.format(strip_guid(pres_output))) .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) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(html) end end From b40ded7e2b9939a287772395cb679ff4eac48a62 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Thu, 14 Nov 2024 01:51:02 +1100 Subject: [PATCH 04/78] semantic annotation of complex xrefs: https://github.com/metanorma/isodoc/issues/617 --- lib/isodoc/presentation_function/xrefs.rb | 6 +- lib/isodoc/xref/xref_anchor.rb | 7 +- lib/isodoc/xref/xref_gen.rb | 47 +- lib/isodoc/xref/xref_sect_gen.rb | 4 +- spec/isodoc/blocks_spec.rb | 56 +- spec/isodoc/xref_format_spec.rb | 480 +++--- spec/isodoc/xref_lists_spec.rb | 882 ++++++++-- spec/isodoc/xref_numbering_spec.rb | 461 ++++-- spec/isodoc/xref_spec.rb | 1801 ++++++++++++++++----- 9 files changed, 2872 insertions(+), 872 deletions(-) diff --git a/lib/isodoc/presentation_function/xrefs.rb b/lib/isodoc/presentation_function/xrefs.rb index b09dbd15..979b5ba8 100644 --- a/lib/isodoc/presentation_function/xrefs.rb +++ b/lib/isodoc/presentation_function/xrefs.rb @@ -12,8 +12,8 @@ def prefix_container(container, linkend, node, target) end def anchor_value(id) - @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :value) || - @xrefs.anchor(id, :label) || @xrefs.anchor(id, :xref) + @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :label) || + @xrefs.anchor(id, :value) || @xrefs.anchor(id, :xref) end def anchor_linkend(node, linkend) @@ -55,7 +55,7 @@ def anchor_xref(node, target, container: false) def anchor_xref_short(node, target, container) if (l = node["label"]) && !container - @i18n.l10n("#{l} #{anchor_value(target)}") + @i18n.l10n(%[#{l} #{anchor_value(target)}]) else @xrefs.anchor(target, :xref) end end diff --git a/lib/isodoc/xref/xref_anchor.rb b/lib/isodoc/xref/xref_anchor.rb index 46d03a06..4afda4cb 100644 --- a/lib/isodoc/xref/xref_anchor.rb +++ b/lib/isodoc/xref/xref_anchor.rb @@ -41,9 +41,10 @@ def anchor_struct_label(lbl, node, elem) end def anchor_struct_xref(lbl, node, elem) - lbl.blank? or s = <<~SEMX - #{' '}#{anchor_struct_value(lbl, elem)} - SEMX + unless lbl.blank? + lbl = "#{lbl}" + s = " #{anchor_struct_value(lbl, elem)}" + end l10n("#{elem}#{s}") .gsub(/ $/, "") end diff --git a/lib/isodoc/xref/xref_gen.rb b/lib/isodoc/xref/xref_gen.rb index 768baed8..753900cc 100644 --- a/lib/isodoc/xref/xref_gen.rb +++ b/lib/isodoc/xref/xref_gen.rb @@ -35,7 +35,6 @@ def termnote_label(note) def increment_label(elems, node, counter, increment: true) elems.size == 1 && !node["number"] and return "" counter.increment(node) if increment - #" #{counter.print}" counter.print end @@ -48,9 +47,7 @@ def termnote_anchor_names(docxml) { label: termnote_label(c.print), type: "termnote", value: c.print, elem: @labels["termnote"], container: t["id"], - #xref: "#{@labels['note_xref']} #{c.print}" - xref: anchor_struct_xref(c.print, n, @labels['note_xref']) - } + xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) } end end end @@ -66,9 +63,7 @@ def termexample_anchor_names(docxml) { label: idx, type: "termexample", value: idx, elem: @labels["example_xref"], container: t["id"], - #xref: "#{@labels['example_xref']} #{idx}" } - xref: anchor_struct_xref(idx, n, @labels['example_xref']) - } + xref: anchor_struct_xref(idx, n, @labels["example_xref"]) } end end end @@ -86,7 +81,8 @@ def note_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, - @labels["note_xref"], "note", { container: true, unnumb: false }) + @labels["note_xref"], "note", + { container: true, unnumb: false }) end end @@ -103,7 +99,8 @@ def admonition_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] ||= anchor_struct(increment_label(notes, n, counter), n, - @labels["box"], "admonition", { container: true, unnumb: n["unnumbered"] }) + @labels["box"], "admonition", + { container: true, unnumb: n["unnumbered"] }) end end @@ -119,7 +116,8 @@ def example_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] ||= anchor_struct(increment_label(notes, n, counter), n, - @labels["example_xref"], "example", { unnumb: n["unnumbered"], container: true }) + @labels["example_xref"], "example", + { unnumb: n["unnumbered"], container: true }) end end @@ -129,23 +127,31 @@ def list_anchor_names(sections) s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol")) c = list_counter notes.noblank.each do |n| - @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n, - @labels["list"], "list", { unnumb: false, container: true}) + @anchors[n["id"]] = + anchor_struct(increment_label(notes, n, c), n, + @labels["list"], "list", + { unnumb: false, container: true }) list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1) end list_anchor_names(s.xpath(ns(CHILD_SECTIONS))) end end - def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) + def list_item_delim + ')' + end + + def list_item_anchor_names(list, list_anchor, depth, prev_label, +refer_list) c = list_counter(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:, prev_label:, - refer_list: depth == 1 ? refer_list : nil }) + 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})], + xref: %[#{label}#{list_item_delim}], type: "listitem", refer_list:, container: list_anchor[:container] } (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol| @@ -157,14 +163,16 @@ def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list) def list_item_value(entry, counter, depth, opts) label = counter.increment(entry).listlabel(entry.parent, depth) + semx = %(#{label}) [label, - list_item_anchor_label(label, opts[:list_anchor], opts[:prev_label], + list_item_anchor_label(semx, opts[:list_anchor], opts[:prev_label], opts[:refer_list])] end def list_item_anchor_label(label, list_anchor, prev_label, refer_list) prev_label.empty? or - label = @i18n.list_nested_xref.sub("%1", "#{prev_label})") + label = @i18n.list_nested_xref + .sub("%1", %[#{prev_label}#{list_item_delim}]) .sub("%2", label) refer_list and label = @i18n.list_nested_xref.sub("%1", list_anchor[:xref]) @@ -185,7 +193,8 @@ def deflist_anchor_names1(notes, counter) notes.noblank.each do |n| @anchors[n["id"]] = anchor_struct(increment_label(notes, n, counter), n, - @labels["deflist"], "deflist", { unnumb: false, container: true }) + @labels["deflist"], "deflist", + { unnumb: false, container: true }) deflist_term_anchor_names(n, @anchors[n["id"]]) end end diff --git a/lib/isodoc/xref/xref_sect_gen.rb b/lib/isodoc/xref/xref_sect_gen.rb index ebee25d2..96791711 100644 --- a/lib/isodoc/xref/xref_sect_gen.rb +++ b/lib/isodoc/xref/xref_sect_gen.rb @@ -119,9 +119,11 @@ def preface_names1(clause, title, parent_title, level) end def preface_name_anchors(clause, level, title) + xref = "#{title}" @anchors[clause["id"]] = { label: nil, level:, - xref: "#{title}", title: nil, + xref:, title: nil, type: "clause", elem: @labels["clause"] } end diff --git a/spec/isodoc/blocks_spec.rb b/spec/isodoc/blocks_spec.rb index 6a102f54..974de133 100644 --- a/spec/isodoc/blocks_spec.rb +++ b/spec/isodoc/blocks_spec.rb @@ -580,14 +580,12 @@ ) - - Formula - - ( - 1 - ) - - + + Formula + ( + 1 + ) + r = 1 % @@ -931,14 +929,12 @@ ) - - Formula - - ( - 1 - ) - - + + Formula + ( + 1 + ) + r/1 = 0
@@ -1120,14 +1116,12 @@ ) - - Formula - - ( - 1 - ) - - + + Formula + ( + 1 + ) + r/1 = 0
@@ -1290,14 +1284,12 @@ ) - - Formula - - ( - 1 - ) - - + + Formula + ( + 1 + ) + r/1 = 0
diff --git a/spec/isodoc/xref_format_spec.rb b/spec/isodoc/xref_format_spec.rb index ae3ffdaa..e4155df1 100644 --- a/spec/isodoc/xref_format_spec.rb +++ b/spec/isodoc/xref_format_spec.rb @@ -47,19 +47,24 @@ - - - - Table of contents - - Foreword -

- a#b -

-
-
-
+ + + + Table of contents + + + Foreword + + + Foreword + + +

+ a#b +

+
+
+
OUTPUT html = <<~OUTPUT #{HTML_HDR} @@ -117,40 +122,52 @@ INPUT output = <<~OUTPUT - - - - Table of contents - - - - - 1. - - (1) - - - - 2. -

- This is - klaŭzo 1 - and - klaŭzo 1, Formula (1) - . This is - 1 - and - (1) - . -

-
-
-
+ + + + 2 + . + + + + klaŭzo + 2 + +

+ This is + + klaŭzo + 1 + + and + + klaŭzo + 1 + , + Formula + ( + 1 + ) + + . This is + + 1 + + and + + ( + 1 + ) + + . +

+
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert - .new({ i18nyaml: "spec/assets/i18n.yaml" } - .merge(presxml_options)) - .convert("test", input, true)))) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert + .new({ i18nyaml: "spec/assets/i18n.yaml" } + .merge(presxml_options)) + .convert("test", input, true)) + .at("//xmlns:clause[@id = 'C']").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -169,36 +186,42 @@ INPUT output = <<~OUTPUT - - - - Table of contents - - - - - 1. - - (1) - - - - 2. -

- This is - Klauze 1 - and - klaŭzo 1, Formulen (1) - . -

-
-
-
+ + + + 2 + . + + + + klaŭzo + 2 + +

+ This is + + Klauze + 1 + + and + + klaŭzo + 1 + , + Formulen + ( + 1 + ) + + . +

+
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ i18nyaml: "spec/assets/i18n.yaml" } .merge(presxml_options)) - .convert("test", input, true)))) + .convert("test", input, true)) + .at("//xmlns:clause[@id = 'C']").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -222,23 +245,6 @@ INPUT output = <<~OUTPUT - - - - Table of contents - - - - - - 1. - <tab/> - My section - - - (1) - - 2.

This is @@ -286,12 +292,11 @@ .

-
-
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)))) + .convert("test", input, true)) + .at("//xmlns:clause[@id = 'C']").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -327,97 +332,110 @@ INPUT output = <<~OUTPUT - - - Table of contents - - Introduction - - - - - 1. - - Tabelo 1 -
-
- Figur-etikedo duvorta 1 -
- - Ekzempl-etikedo Duvorta - -
- - 2. -

- This is - klaŭzo 1 - and - tabelo 1 - . This is - Klaŭzo 1 - and - tabelo 1 - . This is - klaŭzo 1 - and - Tabelo 1 - . Downcasing an xref affects only the first letter: - klaŭzo 1, Example - . Capitalising an xref affects only the first letter: - Figur-etikedo duvorta 1 - . - Klaŭzo 1 - is clause - initial. -
- Klaŭzo 1 - is too. -

-

- Klaŭzo 1 - is also. -

-

- Annex has formatting, and crossreferences ignore it when determining - casing. - + + + + 2 + . + + + + klaŭzo + 2 + +

+ This is + + klaŭzo + 1 + + and + + tabelo + 1 + + . This is + + Klaŭzo + 1 + + and + + tabelo + 1 + + . This is + + klaŭzo + 1 + + and + + Tabelo + 1 + + . Downcasing an xref affects only the first letter: + + klaŭzo + 1 + , + Example + + . Capitalising an xref affects only the first letter: + + Figur-etikedo duvorta + 1 + + . + + Klaŭzo + 1 + + is clause + initial. +
+ + Klaŭzo + 1 + + is too. +

+

+ + Klaŭzo + 1 + + is also. +

+

+ Annex has formatting, and crossreferences ignore it when determining casing. + + Aldono - A - - . -

-

- Labels are not subject to casing: - Introduction -

-
- - - <strong> - <strong>Aldono</strong> - A - </strong> - <br/> - (informa) - - - A.1. - - -
-
+ + A + + . +

+

+ Labels are not subject to casing: + + Introduction + +

+ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ i18nyaml: "spec/assets/i18n.yaml" } .merge(presxml_options)) - .convert("test", input, true)))) + .convert("test", input, true)) + .at("//xmlns:clause[@id = 'C']").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end it "ignores casing of xrefs in unicameral scripts" do input = <<~INPUT - + @@ -435,51 +453,77 @@ INPUT output = <<~OUTPUT - - - Table of contents - - - 1. -
- Tabelo 1 -
-
- - 2. -

- This is - klaŭzo 1 - and - tabelo 1 - . This is - klaŭzo 1 - and - tabelo 1 - . This is - klaŭzo 1 - and - tabelo 1 - . - klaŭzo 1 - is clause - initial. -
- klaŭzo 1 - is too. -

-

- klaŭzo 1 - is also. -

-
-
-
+ + + + 2 + . + + + + klaŭzo + 2 + +

+ This is + + klaŭzo + 1 + + and + + tabelo + 1 + + . This is + + klaŭzo + 1 + + and + + tabelo + 1 + + . This is + + klaŭzo + 1 + + and + + tabelo + 1 + + . + + klaŭzo + 1 + + is clause + initial. +
+ + klaŭzo + 1 + + is too. +

+

+ + klaŭzo + 1 + + is also. +

+
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + # We pretend this is Chinese—so no capitalisation is applied + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ i18nyaml: "spec/assets/i18n.yaml", script: "Hans" } .merge(presxml_options)) - .convert("test", input, true)))) + .convert("test", input, true)) + .at("//xmlns:clause[@id = 'C']").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end diff --git a/spec/isodoc/xref_lists_spec.rb b/spec/isodoc/xref_lists_spec.rb index 2a929363..93bcfe7c 100644 --- a/spec/isodoc/xref_lists_spec.rb +++ b/spec/isodoc/xref_lists_spec.rb @@ -70,24 +70,76 @@
INPUT output = <<~OUTPUT - Foreword -

- Introduction, List - Preparatory, List - Clause 1, List - Clause 3.1, List 1 - Clause 3.1, List 2 - Annex A.1, List - Annex A.2, List 1 - Annex A.2, List 2 - Bibliographical Section, List -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + List + + + Preparatory + , + List + + + Clause + 1 + , + List + + + Clause + 3.1 + , + List + 1 + + + Clause + 3.1 + , + List + 2 + + + Annex + A.1 + , + List + + + Annex + A.2 + , + List + 1 + + + Annex + A.2 + , + List + 2 + + + Bibliographical Section + , + List + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -168,49 +220,218 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, a) - Introduction, a) 1) - Introduction, a) 1) i) - Preparatory, 1) - Clause 1, i) - Clause 3.1, List 1 a) - Clause 3.1, List 2 I) - Annex A.1, A) - Annex A.2, List 1 iv) - Annex A.2, List 2 a) - Bibliographical Section, a) -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + a + ) + + + Introduction + , + a + ) + 1 + ) + + + Introduction + , + a + ) + 1 + ) + i + ) + + + Preparatory + , + 1 + ) + + + Clause + 1 + , + i + ) + + + Clause + 3.1 + , + List + 1 + a + ) + + + Clause + 3.1 + , + List + 2 + I + ) + + + Annex + A.1 + , + A + ) + + + Annex + A.2 + , + List + 1 + iv + ) + + + Annex + A.2 + , + List + 2 + a + ) + + + Bibliographical Section + , + a + ) + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) input1 = input.sub(%r{en}, "ja") output = <<~OUTPUT - まえがき -

- 序文のa) - 序文のa)の1) - 序文のa)の1)のi) - Preparatoryの1) - 箇条1のi) - 箇条3.1のリスト 1のa) - 箇条3.1のリスト 2のI) - 附属書 A.1のA) - 附属書 A.2のリスト 1のiv) - 附属書 A.2のリスト 2のa) - Bibliographical Sectionのa) -

+ + まえがき + + + まえがき + + +

+ + 序文 + の + a + + + + 序文 + の + a + + の + 1 + + + + 序文 + の + a + + の + 1 + + の + i + + + + Preparatory + の + 1 + + + + 箇条 + 1 + の + i + + + + 箇条 + 3.1 + の + リスト + 1 + の + a + + + + 箇条 + 3.1 + の + リスト + 2 + の + I + + + + 附属書 + A.1 + の + A + + + + 附属書 + A.2 + の + リスト + 1 + の + iv + + + + 附属書 + A.2 + の + リスト + 2 + の + a + + + + Bibliographical Section + の + a + + +

OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input1, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -281,49 +502,323 @@ INPUT output = <<~OUTPUT - Foreword -

- Clause 1, a) - Clause 1, a) 1) - Clause 1, a) 1) i) - Clause 1, a) 1) i) A) - Clause 1, a) 1) i) A) I) - Clause 1, a) 1) i) A) I) a) - Clause 2, List 1 a) - Clause 2, List 1 a) 1) - Clause 2, List 1 a) 1) i) - Clause 2, List 1 a) 1) i) A) - Clause 2, List 2 a) -

-
+ + Foreword + + + Foreword + + +

+ + Clause + 1 + , + a + ) + + + Clause + 1 + , + a + ) + 1 + ) + + + Clause + 1 + , + a + ) + 1 + ) + i + ) + + + Clause + 1 + , + a + ) + 1 + ) + i + ) + A + ) + + + Clause + 1 + , + a + ) + 1 + ) + i + ) + A + ) + I + ) + + + Clause + 1 + , + a + ) + 1 + ) + i + ) + A + ) + I + ) + a + ) + + + Clause + 2 + , + List + 1 + a + ) + + + Clause + 2 + , + List + 1 + a + ) + 1 + ) + + + Clause + 2 + , + List + 1 + a + ) + 1 + ) + i + ) + + + Clause + 2 + , + List + 1 + a + ) + 1 + ) + i + ) + A + ) + + + Clause + 2 + , + List + 2 + a + ) + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) input1 = input.sub(%r{en}, "ja") output = <<~OUTPUT - まえがき -

- 箇条1のa) - 箇条1のa)の1) - 箇条1のa)の1)のi) - 箇条1のa)の1)のi)のA) - 箇条1のa)の1)のi)のA)のI) - 箇条1のa)の1)のi)のA)のI)のa) - 箇条2のリスト 1のa) - 箇条2のリスト 1のa)の1) - 箇条2のリスト 1のa)の1)のi) - 箇条2のリスト 1のa)の1)のi)のA) - 箇条2のリスト 2のa) -

+ + まえがき + + + まえがき + + +

+ + 箇条 + 1 + の + a + + + + 箇条 + 1 + の + a + + の + 1 + + + + 箇条 + 1 + の + a + + の + 1 + + の + i + + + + 箇条 + 1 + の + a + + の + 1 + + の + i + + の + A + + + + 箇条 + 1 + の + a + + の + 1 + + の + i + + の + A + + の + I + + + + 箇条 + 1 + の + a + + の + 1 + + の + i + + の + A + + の + I + + の + a + + + + 箇条 + 2 + の + リスト + 1 + の + a + + + + 箇条 + 2 + の + リスト + 1 + の + a + + の + 1 + + + + 箇条 + 2 + の + リスト + 1 + の + a + + の + 1 + + の + i + + + + 箇条 + 2 + の + リスト + 1 + の + a + + の + 1 + + の + i + + の + A + + + + 箇条 + 2 + の + リスト + 2 + の + a + + +

OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input1, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -396,24 +891,76 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, Definition List - Preparatory, Definition List - Clause 1, Definition List - Clause 3.1, Definition List 1 - Clause 3.1, Definition List 2 - Annex A.1, Definition List - Annex A.2, Definition List 1 - Annex A.2, Definition List 2 - Bibliographical Section, Definition List -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + Definition List + + + Preparatory + , + Definition List + + + Clause + 1 + , + Definition List + + + Clause + 3.1 + , + Definition List + 1 + + + Clause + 3.1 + , + Definition List + 2 + + + Annex + A.1 + , + Definition List + + + Annex + A.2 + , + Definition List + 1 + + + Annex + A.2 + , + Definition List + 2 + + + Bibliographical Section + , + Definition List + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -486,24 +1033,94 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, Definition List: A - Preparatory, Definition List: A - Clause 1, Definition List: A - Clause 3.1, Definition List 1: A - Clause 3.1, Definition List 2: A - Annex A.1, Definition List: A - Annex A.2, Definition List 1: A - Annex A.2, Definition List 2: A - Bibliographical Section, Definition List: A -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + Definition List + : + A + + + Preparatory + , + Definition List + : + A + + + Clause + 1 + , + Definition List + : + A + + + Clause + 3.1 + , + Definition List + 1 + : + A + + + Clause + 3.1 + , + Definition List + 2 + : + A + + + Annex + A.1 + , + Definition List + : + A + + + Annex + A.2 + , + Definition List + 1 + : + A + + + Annex + A.2 + , + Definition List + 2 + : + A + + + Bibliographical Section + , + Definition List + : + A + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -546,16 +1163,47 @@ INPUT output = <<~OUTPUT - Foreword -

Introduction, Definition List: e^rhat(e)_(r) - + + Foreword + + + Foreword + + +

+ + Introduction + , + Definition List + : + + + + + + + + e + + ^ + + + + r + + + + hat(e)_(r) + + +

-
+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end end diff --git a/spec/isodoc/xref_numbering_spec.rb b/spec/isodoc/xref_numbering_spec.rb index 6f5eee24..c1c7b825 100644 --- a/spec/isodoc/xref_numbering_spec.rb +++ b/spec/isodoc/xref_numbering_spec.rb @@ -46,23 +46,53 @@ INPUT output = <<~OUTPUT - Foreword -

- Figure 1 - Figure 2a - Figure 2b - Figure 3a - Figure 3b - Figure 3c - Figure 4 - Figure 5 -

-
+ + Foreword + + + Foreword + + +

+ + Figure + 1 + + + Figure + 2a + + + Figure + 2b + + + Figure + 3a + + + Figure + 3b + + + Figure + 3c + + + Figure + 4 + + + Figure + 5 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -233,53 +263,165 @@ INPUT output = <<~OUTPUT - Foreword -

- Figure 1 - Figure A - Figure B - Figure 7 - Figure 8 - Figure 9a - Figure 9c - Figure 9d - Figure 20f - Figure 20g - Figure A.1 - Figure A.2 - Figure 100 -

-

- Clause 1bis - Clause 2bis - Clause 3bis - Clause 3bis.4bis - Clause 12bis - Clause 13bis - Clause 13bis.14bis - Clause 13bis.14bit - Clause 13bis.14biu - Clause 13bis.0 - Clause 13bis.1 - Clause 13bis.2 - Clause 13bis.a - Clause 13bis.b - Clause 13bis.B - Clause 13bis.C - Clause 16bis - Annex A - Annex 17bis - Annex 17bis.18bis - Annex 17bit - Bibliography - Bibliography Subsection -

-
+ + Foreword + + + Foreword + + +

+ + Figure + 1 + + + Figure + A + + + Figure + B + + + Figure + 7 + + + Figure + 8 + + + Figure + 9a + + + Figure + 9c + + + Figure + 9d + + + Figure + 20f + + + Figure + 20g + + + Figure + A.1 + + + Figure + A.2 + + + Figure + 100 + +

+

+ + Clause + 1bis + + + Clause + 2bis + + + Clause + 3bis + + + Clause + 3bis.4bis + + + Clause + 12bis + + + Clause + 13bis + + + Clause + 13bis.14bis + + + Clause + 13bis.14bit + + + Clause + 13bis.14biu + + + Clause + 13bis.0 + + + Clause + 13bis.1 + + + Clause + 13bis.2 + + + Clause + 13bis.a + + + Clause + 13bis.b + + + Clause + 13bis.B + + + Clause + 13bis.C + + + Clause + 16bis + + + Annex + A + + + Annex + 17bis + + + Annex + 17bis.18bis + + + Annex + 17bit + + + Bibliography + + + Bibliography Subsection + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -376,41 +518,125 @@ INPUT output = <<~OUTPUT - Foreword -

- Clause 1 - Clause 1.1 - Clause 123 - Clause 1.2 - Clause 3 - Clause 124 - Clause 124.1 - Clause 3.1 - Clause 125 - Clause 126 - Clause 125.1 - Clause 2 - Clause 3bis - Clause 4bis - Clause 3bis.4bis - Clause 3bis.4bit - Clause 12bis - Annex A - Annex A.1 - Annex 123 - Annex A.2 - Annex B - Annex B.1 - Annex 123 - Annex B.2 - Clause 2bis -

-
+ + Foreword + + + Foreword + + +

+ + Clause + 1 + + + Clause + 1.1 + + + Clause + 123 + + + Clause + 1.2 + + + Clause + 3 + + + Clause + 124 + + + Clause + 124.1 + + + Clause + 3.1 + + + Clause + 125 + + + Clause + 126 + + + Clause + 125.1 + + + Clause + 2 + + + Clause + 3bis + + + Clause + 4bis + + + Clause + 3bis.4bis + + + Clause + 3bis.4bit + + + Clause + 12bis + + + Annex + A + + + Annex + A.1 + + + Annex + 123 + + + Annex + A.2 + + + Annex + B + + + Annex + B.1 + + + Annex + 123 + + + Annex + B.2 + + + Clause + 2bis + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -492,22 +718,51 @@ INPUT output = <<~OUTPUT - Foreword - - NOTE - - - NOTE 1 - - - NOTE - - + + Foreword + + + Foreword + + + + + + NOTE + + + + Note + + + + + + NOTE + 1 + + + + Note + 1 + + + + + + NOTE + + + + Note + + + OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end end diff --git a/spec/isodoc/xref_spec.rb b/spec/isodoc/xref_spec.rb index ab9cd346..1dac31f6 100644 --- a/spec/isodoc/xref_spec.rb +++ b/spec/isodoc/xref_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" RSpec.describe IsoDoc do - it "selects sets to crossreference" do + it "selects sets of assets to process crossreference for" do input = Nokogiri::XML(<<~INPUT) @@ -13,17 +13,26 @@ INPUT xrefs = new_xrefs xrefs.parse(input) - expect(xrefs.anchor("A", :xref)).to eq "Clause 1" - expect(xrefs.anchor("B", :xref)).to eq "Note" - expect(xrefs.anchor("C", :xref)).to eq "[C]" + expect(xrefs.anchor("A", :xref)) + .to be_equivalent_to "Clause 1" + expect(xrefs.anchor("B", :xref)) + .to be_equivalent_to "Note" + expect(xrefs.anchor("C", :xref)) + .to be_equivalent_to "[C]" + xrefs = new_xrefs.parse_inclusions(clauses: true) xrefs.parse(input) - expect(xrefs.anchor("A", :xref)).to eq "Clause 1" - expect(xrefs.anchor("B", :xref)).to eq "[B]" + expect(xrefs.anchor("A", :xref)) + .to be_equivalent_to "Clause 1" + expect(xrefs.anchor("B", :xref)) + .to be_equivalent_to "[B]" + xrefs = new_xrefs.parse_inclusions(assets: true) xrefs.parse(input) - expect(xrefs.anchor("A", :xref)).to eq "[A]" - expect(xrefs.anchor("B", :xref)).to eq "Note" + expect(xrefs.anchor("A", :xref)) + .to be_equivalent_to "[A]" + expect(xrefs.anchor("B", :xref)) + .to be_equivalent_to "Note" end it "cross-references notes" do @@ -97,24 +106,76 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, Note - Preparatory, Note - Clause 1, Note - Clause 3.1, Note 1 - Clause 3.1, Note 2 - Annex A.1, Note - Annex A.2, Note 1 - Annex A.2, Note 2 - Bibliographical Section, Note -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + Note + + + Preparatory + , + Note + + + Clause + 1 + , + Note + + + Clause + 3.1 + , + Note + 1 + + + Clause + 3.1 + , + Note + 2 + + + Annex + A.1 + , + Note + + + Annex + A.2 + , + Note + 1 + + + Annex + A.2 + , + Note + 2 + + + Bibliographical Section + , + Note + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -194,48 +255,153 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, Box - Preparatory, Box - [N3] - Clause 1, Box - Clause 3.1, Box 1 - Clause 3.1, Box 2 - Annex A.1, Box - Annex A.2, Box 1 - Annex A.2, Box 2 - Bibliographical Section, Box -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + Box + + + Preparatory + , + Box + + [N3] + + Clause + 1 + , + Box + + + Clause + 3.1 + , + Box + 1 + + + Clause + 3.1 + , + Box + 2 + + + Annex + A.1 + , + Box + + + Annex + A.2 + , + Box + 1 + + + Annex + A.2 + , + Box + 2 + + + Bibliographical Section + , + Box + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) + input1 = input.sub(%r{en}, "ja") output = <<~OUTPUT - まえがき -

- 序文のBox - PreparatoryのBox - [N3] - 箇条1のBox - 箇条3.1のBox 1 - 箇条3.1のBox 2 - 附属書 A.1のBox - 附属書 A.2のBox 1 - 附属書 A.2のBox 2 - Bibliographical SectionのBox -

-
+ + まえがき + + + まえがき + + +

+ + 序文 + の + Box + + + Preparatory + の + Box + + [N3] + + 箇条 + 1 + の + Box + + + 箇条 + 3.1 + の + Box + 1 + + + 箇条 + 3.1 + の + Box + 2 + + + 附属書 + A.1 + の + Box + + + 附属書 + A.2 + の + Box + 1 + + + 附属書 + A.2 + の + Box + 2 + + + Bibliographical Section + の + Box + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input1, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -337,28 +503,72 @@ INPUT output = <<~OUTPUT - Foreword -

- Figure 1 - Figure (??) - Figure 2 - Figure 3 - Figure 4 - Figure 5 - Figure 6 - [note51] - Figure A.1 - Figure (??) - Figure A.2 - Figure A.3 - Bibliographical Section, Figure 1 -

-
+ + Foreword + + + Foreword + + +

+ + Figure + 1 + + + Figure + (??) + + + Figure + 2 + + + Figure + 3 + + + Figure + 4 + + + Figure + 5 + + + Figure + 6 + + [note51] + + Figure + A.1 + + + Figure + (??) + + + Figure + A.2 + + + Figure + A.3 + + + Bibliographical Section + , + Figure + 1 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -460,28 +670,75 @@ INPUT output = <<~OUTPUT - Foreword -

- Figure 1 - Figure (??) - Diagram 1 - Plate 1 - Figure 2 - Figure 3 - Diagram 2 - Figure 4 - Diagram A.1 - Plate (??) - Figure A.1 - Figure A.2 - Bibliographical Section, Figure 1 -

-
+ + Foreword + + + Foreword + + +

+ + Figure + 1 + + + Figure + (??) + + + Diagram + 1 + + + Plate + 1 + + + Figure + 2 + + + Figure + 3 + + + Diagram + 2 + + + Figure + 4 + + + Diagram + A.1 + + + Plate + (??) + + + Figure + A.1 + + + Figure + A.2 + + + Bibliographical Section + , + Figure + 1 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -554,24 +811,63 @@ INPUT output = <<~OUTPUT - Foreword -

- Figure 1 - Figure 1-1 - Figure 1-2 - Figure A.1 - Figure A.1-1 - Figure A.1-2 - Bibliographical Section, Figure 1 - Bibliographical Section, Figure 1-1 - Bibliographical Section, Figure 1-2 -

-
+ + Foreword + + + Foreword + + +

+ + Figure + 1 + + + Figure + 1-1 + + + Figure + 1-2 + + + Figure + A.1 + + + Figure + A.1-1 + + + Figure + A.1-2 + + + Bibliographical Section + , + Figure + 1 + + + Bibliographical Section + , + Figure + 1-1 + + + Bibliographical Section + , + Figure + 1-2 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -647,50 +943,138 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, Example - Preparatory, Example (??) - Clause 1, Example - Clause 3.1, Example 1 - Clause 3.1, Example (??) - Annex A.1, Example - Annex A.2, Example (??) - Annex A.2, Example 1 - Bibliographical Section, Example -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + Example + + + Preparatory + , + Example + (??) + + + Clause + 1 + , + Example + + + Clause + 3.1 + , + Example + 1 + + + Clause + 3.1 + , + Example + (??) + + + Annex + A.1 + , + Example + + + Annex + A.2 + , + Example + (??) + + + Annex + A.2 + , + Example + 1 + + + Bibliographical Section + , + Example + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) output = <<~OUTPUT - - 3.1. - - EXAMPLE 1 -

Hello

-
- - EXAMPLE + + + + 3.1 + . + + + + Clause + 3.1 + + + + + EXAMPLE + 1 + + + + Example + 1 + +

Hello

+
+ + + + EXAMPLE + + + + Example + (??) + +

+ Hello + + Example + 1 + +

+

- Hello - Example 1 + + Example + 1 + + + Example + (??) +

-
-

- Example 1 - Example (??) -

-
+ OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:clause[@id='widgets1']").to_xml)) + .at("//xmlns:clause[@id='widgets1']").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -765,24 +1149,90 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, Formula (1) - Preparatory, Formula ((??)) - Clause 1, Formula (2) - Clause 3.1, Formula (3) - Clause 3.1, Formula (4) - Formula (A.1) - Formula ((??)) - Formula (A.2) - Bibliographical Section, Formula (1) -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + Formula + ( + 1 + ) + + + Preparatory + , + Formula + ( + (??) + ) + + + Clause + 1 + , + Formula + ( + 2 + ) + + + Clause + 3.1 + , + Formula + ( + 3 + ) + + + Clause + 3.1 + , + Formula + ( + 4 + ) + + + Formula + ( + A.1 + ) + + + Formula + ( + (??) + ) + + + Formula + ( + A.2 + ) + + + Bibliographical Section + , + Formula + ( + 1 + ) + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -865,26 +1315,86 @@ INPUT output = <<~OUTPUT - Foreword + + Foreword + + + Foreword + +

- Introduction, Requirement 1 - Preparatory, Requirement (??) - Clause 1, Requirement 2 - Clause 1, provision 1 - Clause 3.1, Requirement 3 - Clause 3.1, Requirement 4 - Clause 3.1, provision 2 - Requirement A.1 - Requirement (??) - Requirement A.2 - Bibliographical Section, Requirement 1 + + Introduction + , + Requirement + 1 + + + Preparatory + , + Requirement + (??) + + + Clause + 1 + , + Requirement + 2 + + + Clause + 1 + , + provision + 1 + + + Clause + 3.1 + , + Requirement + 3 + + + Clause + 3.1 + , + Requirement + 4 + + + Clause + 3.1 + , + provision + 2 + + + Requirement + A.1 + + + Requirement + (??) + + + Requirement + A.2 + + + Bibliographical Section + , + Requirement + 1 +

OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -959,24 +1469,72 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, Recommendation 1 - Preparatory, Recommendation (??) - Clause 1, Recommendation 2 - Clause 3.1, Recommendation 3 - Clause 3.1, Recommendation 4 - Recommendation A.1 - Recommendation (??) - Recommendation A.2 - Bibliographical Section, Recommendation 1 -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + Recommendation + 1 + + + Preparatory + , + Recommendation + (??) + + + Clause + 1 + , + Recommendation + 2 + + + Clause + 3.1 + , + Recommendation + 3 + + + Clause + 3.1 + , + Recommendation + 4 + + + Recommendation + A.1 + + + Recommendation + (??) + + + Recommendation + A.2 + + + Bibliographical Section + , + Recommendation + 1 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1051,24 +1609,72 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction, Permission 1 - Preparatory, Permission (??) - Clause 1, Permission 2 - Clause 3.1, Permission 3 - Clause 3.1, Permission 4 - Permission A.1 - Permission (??) - Permission A.2 - Bibliographical Section, Permission 1 -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + , + Permission + 1 + + + Preparatory + , + Permission + (??) + + + Clause + 1 + , + Permission + 2 + + + Clause + 3.1 + , + Permission + 3 + + + Clause + 3.1 + , + Permission + 4 + + + Permission + A.1 + + + Permission + (??) + + + Permission + A.2 + + + Bibliographical Section + , + Permission + 1 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1137,30 +1743,106 @@ INPUT output = <<~OUTPUT - Foreword -

- Clause 1, Permission 1 - Clause 1, Permission 1-1 - Clause 1, Permission 1-1-1 - Clause 1, Requirement 1-1 - Clause 1, Recommendation 1-1 - Permission A.1 - Permission A.1-1 - Permission A.1-1-1 - Requirement A.1-1 - Recommendation A.1-1 - Bibliographical Section, Permission 1 - Bibliographical Section, Permission 1-1 - Bibliographical Section, Permission 1-1-1 - Bibliographical Section, Requirement 1-1 - Bibliographical Section, Recommendation 1-1 -

-
+ + Foreword + + + Foreword + + +

+ + Clause + 1 + , + Permission + 1 + + + Clause + 1 + , + Permission + 1-1 + + + Clause + 1 + , + Permission + 1-1-1 + + + Clause + 1 + , + Requirement + 1-1 + + + Clause + 1 + , + Recommendation + 1-1 + + + Permission + A.1 + + + Permission + A.1-1 + + + Permission + A.1-1-1 + + + Requirement + A.1-1 + + + Recommendation + A.1-1 + + + Bibliographical Section + , + Permission + 1 + + + Bibliographical Section + , + Permission + 1-1 + + + Bibliographical Section + , + Permission + 1-1-1 + + + Bibliographical Section + , + Requirement + 1-1 + + + Bibliographical Section + , + Recommendation + 1-1 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1298,24 +1980,59 @@ INPUT output = <<~OUTPUT - Foreword -

- Table 1 - Table (??) - Table 2 - Table 3 - Table 4 - Table A.1 - Table (??) - Table A.2 - Bibliographical Section, Table 1 -

-
+ + Foreword + + + Foreword + + +

+ + Table + 1 + + + Table + (??) + + + Table + 2 + + + Table + 3 + + + Table + 4 + + + Table + A.1 + + + Table + (??) + + + Table + A.2 + + + Bibliographical Section + , + Table + 1 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1352,20 +2069,69 @@ INPUT output = <<~OUTPUT - Foreword -

- Clause 2.1, Note 1 - Clause 2.2, Note 1 - Clause 2.2, Note 2 - Clause 2.1, Note 1 and Clause 2.2, Note 1 - Clause 2.2, Note 1 and Note 2 -

-
+ + Foreword + + + Foreword + + +

+ + Clause + 2.1 + , + Note + 1 + + + Clause + 2.2 + , + Note + 1 + + + Clause + 2.2 + , + Note + 2 + + + Clause + 2.1 + , + Note + 1 + + and + + Clause + 2.2 + , + Note + 1 + + Clause + 2.2 + , + + Note + 1 + + and + + Note + 2 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1400,18 +2166,42 @@ INPUT output = <<~OUTPUT - Foreword -

- Clause 2.1, Note 1 - Clause 2.1.1, Note 1 - Clause 2.1.1, Note 2 -

-
+ + Foreword + + + Foreword + + +

+ + Clause + 2.1 + , + Note + 1 + + + Clause + 2.1.1 + , + Note + 1 + + + Clause + 2.1.1 + , + Note + 2 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1446,18 +2236,41 @@ INPUT output = <<~OUTPUT - Foreword -

- Clause 2.1, Example - Clause 2.2, Example 1 - Clause 2.2, Example 2 -

-
+ + Foreword + + + Foreword + + +

+ + Clause + 2.1 + , + Example + + + Clause + 2.2 + , + Example + 1 + + + Clause + 2.2 + , + Example + 2 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1492,18 +2305,41 @@ INPUT output = <<~OUTPUT - Foreword -

- Clause 2.1, Example - Clause 2.1.1, Example 1 - Clause 2.1.1, Example 2 -

-
+ + Foreword + + + Foreword + + +

+ + Clause + 2.1 + , + Example + + + Clause + 2.1.1 + , + Example + 1 + + + Clause + 2.1.1 + , + Example + 2 + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1605,79 +2441,213 @@ INPUT output = <<~OUTPUT - - Foreword -

- This is a preamble - Foreword - Introduction - Introduction Subsection - Introduction, 2 - Acknowledgements - Acknowledgements, 1 - Clause 1 - Clause 3 - Clause 3.1 - Clause 3.1.1 - Clause 3.2 - Clause 4 - Clause 5 - Clause 5.1 - Clause 5.2 - Annex A - Annex A.1 - Annex A.1.1 - Annex B - Annex B - Annex B.1 - Clause 2 - Bibliography -

-
+ + Foreword + + + Foreword + + +

+ This is a preamble + + Foreword + + + Introduction + + + Introduction Subsection + + + Introduction, 2 + + + Acknowledgements + + + Acknowledgements, 1 + + + Clause + 1 + + + Clause + 3 + + + Clause + 3.1 + + + Clause + 3.1.1 + + + Clause + 3.2 + + + Clause + 4 + + + Clause + 5 + + + Clause + 5.1 + + + Clause + 5.2 + + + Annex + A + + + Annex + A.1 + + + Annex + A.1.1 + + + Annex + B + + + Annex + B + + + Annex + B.1 + + + Clause + 2 + + + Bibliography + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) output = <<~OUTPUT - - Foreword -

- This is a preamble - Foreword - Введение - Introduction Subsection - Введение, 2 - Подтверждения - Подтверждения, 1 - Пункт 1 - Пункт 3 - Пункт 3.1 - Пункт 3.1.1 - Пункт 3.2 - Пункт 4 - Пункт 5 - Пункт 5.1 - Пункт 5.2 - Дополнение A - Дополнение A.1 - Дополнение A.1.1 - Дополнение B - Дополнение B - Дополнение B.1 - Пункт 2 - Bibliography -

-
+ + Foreword + + + Foreword + + +

+ This is a preamble + + Foreword + + + Введение + + + Introduction Subsection + + + Введение, 2 + + + Подтверждения + + + Подтверждения, 1 + + + Пункт + 1 + + + Пункт + 3 + + + Пункт + 3.1 + + + Пункт + 3.1.1 + + + Пункт + 3.2 + + + Пункт + 4 + + + Пункт + 5 + + + Пункт + 5.1 + + + Пункт + 5.2 + + + Дополнение + A + + + Дополнение + A.1 + + + Дополнение + A.1.1 + + + Дополнение + B + + + Дополнение + B + + + Дополнение + B.1 + + + Пункт + 2 + + + Bibliography + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input.sub("", "ru"), true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1775,34 +2745,80 @@ INPUT output = <<~OUTPUT - Foreword -

This is a preamble - Scope - Terms, definitions, symbols and abbreviated terms - Normal Terms - Normal Terms 1 - Symbols - Symbols - Clause A - Introduction - Clause 1 - Clause B - Clause 2 - Annex - Annex1 - Annex1a - Annex - Annex, 1 - Annex, 1 1 - Normative References - Bibliography -

-
+ Foreword + + + Foreword + + +

+ This is a preamble + + Scope + + + Terms, definitions, symbols and abbreviated terms + + + Normal Terms + + + Normal Terms 1 + + + Symbols + + + Symbols + + + Clause A + + + Introduction + + + Clause + 1 + + + Clause B + + + Clause + 2 + + + Annex + + + Annex1 + + + Annex1a + + + Annex + + + Annex, 1 + + + Annex, 1 1 + + + Normative References + + + Bibliography + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri.XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri.XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end @@ -1876,24 +2892,57 @@ INPUT output = <<~OUTPUT - Foreword -

- Introduction - Preparatory - Clause 1 - Clause 3.1, Note 2 - Clause 3.1 - Annex A.1 - Figure A.1 - Annex A.2 - Bibliographical Section -

-
+ + Foreword + + + Foreword + + +

+ + Introduction + + + Preparatory + + + Clause + 1 + + + Clause + 3.1 + , + Note + 2 + + + Clause + 3.1 + + + Annex + A.1 + + + Figure + A.1 + + + Annex + A.2 + + + Bibliographical Section + +

+
OUTPUT - expect(Xml::C14n.format(Nokogiri::XML(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .at("//xmlns:foreword").to_xml)) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end end From 8412745cf39be34534c7987aa94f16480821e92a Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Thu, 14 Nov 2024 02:12:07 +1100 Subject: [PATCH 05/78] rspec --- lib/isodoc/function/cleanup.rb | 2 +- spec/isodoc/figures_spec.rb | 6 +- spec/isodoc/footnotes_spec.rb | 98 ++++++++++++++++++---- spec/isodoc/presentation_xml_maths_spec.rb | 43 +++++++--- spec/isodoc/presentation_xml_spec.rb | 23 +++-- spec/isodoc/ref_spec.rb | 12 ++- spec/isodoc/section_spec.rb | 11 +-- spec/isodoc/section_title_spec.rb | 2 +- spec/isodoc/sourcecode_spec.rb | 2 +- spec/isodoc/table_spec.rb | 26 +++--- 10 files changed, 163 insertions(+), 62 deletions(-) diff --git a/lib/isodoc/function/cleanup.rb b/lib/isodoc/function/cleanup.rb index 63d3b424..c0a8a516 100644 --- a/lib/isodoc/function/cleanup.rb +++ b/lib/isodoc/function/cleanup.rb @@ -28,7 +28,7 @@ def cleanup(docxml) # todo PRESENTATION XML def admonition_cleanup(docxml) docxml.xpath("//div[@class = 'Admonition'][title]").each do |d| - title = d.at("./fmt-title") + title = d.at("./title") n = title.next_element n&.children&.first &.add_previous_sibling("#{title.remove.text}—") diff --git a/spec/isodoc/figures_spec.rb b/spec/isodoc/figures_spec.rb index 49bd98fd..d8f4bcf8 100644 --- a/spec/isodoc/figures_spec.rb +++ b/spec/isodoc/figures_spec.rb @@ -765,12 +765,12 @@ - Table of contents + Table of contents - Foreword + Foreword LabelA B C -
Label

  A

+
Label

  A

A B C

  A

diff --git a/spec/isodoc/footnotes_spec.rb b/spec/isodoc/footnotes_spec.rb index 74a4444a..8cb150d0 100644 --- a/spec/isodoc/footnotes_spec.rb +++ b/spec/isodoc/footnotes_spec.rb @@ -4,12 +4,26 @@ RSpec.describe IsoDoc do it "processes IsoXML footnotes" do input = <<~INPUT - + - - Table of contents - - Foreword + Foreword +

A. +

Formerly denoted as 15 % (m/m).

+

+

B. +

Formerly denoted as 15 % (m/m).

+

+

C. +

Hello! denoted as 15 % (m/m).

+

+
+
+
+ INPUT + presxml = <<~INPUT + + + Foreword

A.

Formerly denoted as 15 % (m/m).

@@ -57,7 +71,7 @@ OUTPUT - word = <<~OUTPUT + doc = <<~OUTPUT - - -
-

 

+
+

admonition

-

-
+

+ + + OUTPUT + word = <<~OUTPUT + + + + + +
+

 

+
+

+
+

+
+

+

-
-
-

- -   -

- note -
-

-
-

-
-

abstract

-
-

-
-

-
-

introduction

-
-

 

+
+

abstract

-

-
+

+

-
-
-

admonition

+
+

introduction

+
+
note
+

 

+
+

+
+

+
+
+

admonition

+
+
+

Clause 4

+
+

Introduction

-
-

Clause 4

-
-

Introduction

-
-
- - - Clause 4.2 -   - - -
+
+ + + Clause 4.2 +   + +
- - - OUTPUT +
+ + + OUTPUT + 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(word) end it "processes indexsect" do input = <<~INPUT - Glossary + Glossary
  • A
@@ -162,7 +160,8 @@ OUTPUT expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", input, true))).to be_equivalent_to Xml::C14n.format(output) + .convert("test", input, true))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes annexes containing one, or more than one special sections" do @@ -214,122 +213,285 @@
INPUT presxml = <<~OUTPUT - - Table of contents - - - <strong>Annex A</strong> - <br/> - (normative) - <br/> - <br/> - <strong>Glossary</strong> - - - - A.1. - Glossary - - - - - - <strong>Annex B</strong> - <br/> - (normative) - <br/> - <br/> - <strong>Glossary</strong> - - - - B.1. - <tab/> - Term Collection - - - B.1.1. - Term - - - - - B.2. - <tab/> - Term Collection 2 - - - B.2.1. - Term - - - - - - <strong>Annex C</strong> - <br/> - (normative) - <br/> - <br/> - <strong>Glossary</strong> - - - - C.1. - <tab/> - Term Collection - - - C.1.1. - Term - - - - - C.2. - <tab/> - References - - - - - - <strong>Annex D</strong> - <br/> - (normative) - <br/> - <br/> - <strong>Term Collection</strong> - - - - D.1. - - Term - - - - - + + + + Table of contents + + + + + <strong>Glossary</strong> + + + + + Annex + A + +
+ (normative) + +
+
+
+ + Glossary + +
+
+ + Annex + A + + + + + + A.1 + . + + + + Annex + A.1 + + + Glossary + + + +
+ + + <strong>Glossary</strong> + + + + + Annex + B + +
+ (normative) + +
+
+
+ + Glossary + +
+
+ + Annex + B + + + Term Collection + + + B.1 + . + + + + Term Collection + + + + Annex + B.1 + + + + + B.1.1 + . + + + + Annex + B.1.1 + + + Term + + + + + Term Collection 2 + + + B.2 + . + + + + Term Collection 2 + + + + Annex + B.2 + + + + + B.2.1 + . + + + + Annex + B.2.1 + + + Term + + + +
+ + + <strong>Glossary</strong> + + + + + Annex + C + +
+ (normative) + +
+
+
+ + Glossary + +
+
+ + Annex + C + + + Term Collection + + + C.1 + . + + + + Term Collection + + + + Annex + C.1 + + + + + C.1.1 + . + + + + Annex + C.1.1 + + + Term + + + + + References + + + C.2 + . + + + + References + + + + Annex + C.2 + + +
+ + + <strong>Term Collection</strong> + + + + + Annex + D + +
+ (normative) + +
+
+
+ + Term Collection + +
+
+ + Annex + D + + + + + + D.1 + . + + + + Annex + D.1 + + + Term + + + +
+
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(strip_guid(IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true)))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "processes cross-align" do input = <<~INPUT - + - Title + Title

Para

- Iitre + Iitre

Alinée

@@ -371,6 +533,7 @@ OUTPUT expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", input, true))).to be_equivalent_to Xml::C14n.format(output) + .convert("test", input, true))) + .to be_equivalent_to Xml::C14n.format(output) end end diff --git a/spec/isodoc/section_title_spec.rb b/spec/isodoc/section_title_spec.rb index 65a300b5..3f209088 100644 --- a/spec/isodoc/section_title_spec.rb +++ b/spec/isodoc/section_title_spec.rb @@ -118,7 +118,7 @@ INPUT presxml = <<~PRESXML - + From d76b42d7e283f23c8319beb85c2663495e83997c Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Fri, 15 Nov 2024 01:33:45 +1100 Subject: [PATCH 14/78] rspec --- spec/isodoc/form_spec.rb | 6 +++--- spec/isodoc/postproc_spec.rb | 22 +++++++++++----------- spec/isodoc/postproc_word_spec.rb | 22 +++++++++++----------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/spec/isodoc/form_spec.rb b/spec/isodoc/form_spec.rb index 0f79c052..9f86353c 100644 --- a/spec/isodoc/form_spec.rb +++ b/spec/isodoc/form_spec.rb @@ -3,11 +3,11 @@ RSpec.describe IsoDoc do it "renders form" do input = <<~INPUT - + - Table of contents - + Table of contents + diff --git a/spec/isodoc/postproc_spec.rb b/spec/isodoc/postproc_spec.rb index 4d1da28d..b9b9dfde 100644 --- a/spec/isodoc/postproc_spec.rb +++ b/spec/isodoc/postproc_spec.rb @@ -17,7 +17,7 @@ ).convert("test", <<~INPUT, false) - test + test Foreword @@ -44,7 +44,7 @@ ).convert("spec/assets/test", <<~INPUT, false) - test + test</fmt> </bibdata> <preface><foreword displayorder="1"><fmt-title>Foreword</fmt-title> <note> @@ -539,7 +539,7 @@ <iso-standard xmlns="http://riboseinc.com/isoxml"> <preface><foreword displayorder="1"><fmt-title>Foreword</fmt-title> <figure id="_"> - <name>Split-it-right sample divider</name> + <fmt-name>Split-it-right sample divider</fmt-name> <svg xmlns="http://www.w3.org/2000/svg" src="spec/assets/rice_image1.png" id="_" width="20000" height="300000"/> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1275.0000" height="1275.0000"> <g transform="translate(-0.0000, -0.0000)"> @@ -603,7 +603,7 @@ <iso-standard xmlns="http://riboseinc.com/isoxml"> <preface><foreword displayorder="1"><fmt-title>Foreword</fmt-title> <figure id="_"> - <name>Split-it-right sample divider</name> + <fmt-name>Split-it-right sample divider</fmt-name> <image src="rice_image1.png" id="_" mimetype="image/png"/> </figure> </foreword></preface> @@ -800,7 +800,7 @@ <iso-standard xmlns="http://riboseinc.com/isoxml"> <preface><foreword displayorder="1"><fmt-title>Foreword</fmt-title> <figure id="_"> - <name>Split-it-right sample divider</name> + <fmt-name>Split-it-right sample divider</fmt-name> <image src="spec/assets/rice_image1" id="_" mimetype="image/png"/> <image src="spec/assets/rice_image1" id="_" mimetype="image/*"/> <image src="data:image/*;base64,iVBORw0KGgoAAAANSUhEUgAAB9AAAAfQCAAAAAC/U5ulAAAjo0lEQVR4nOzVMQ0AMAzAsPInvYHoMS2yEeTLHADge/M6AADYM3QACDB0AAgwdAAIMHQACDB0AAgwdAAIMHQACDB0AAgwdAAIMHQACDB0AAgwdAAIMHQACDB0AAgwdAAIMHQACDB0AAgwdAAIMHQACDB0AAgwdAAIMHQACDB0AAgwdAAIMHQACDB0AAgwdAAIuAAAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMCB0ABgIAAP//7NWBDAAAAMAgf+t7fCWR0AFgQOgAMCB0ABgQOgAMCB0ABoQOAANCB4ABoQPAgNABYEDoADAgdAAYEDoADAgdAAaEDgADQgeAAaEDwIDQAWBA6AAwIHQAGBA6AAwIHQAGhA4AA0IHgAGhA8CA0AFgQOgAMCB0ABgQOgAMBAAA//8DAE/7hyLdS2yEAAAAAElFTkSuQmCC" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f3" mimetype="image/png"/> @@ -841,7 +841,7 @@ <iso-standard xmlns="http://riboseinc.com/isoxml"> <preface><foreword displayorder="1"><fmt-title>Foreword</fmt-title> <figure id="_"> - <name>Split-it-right sample divider</name> + <fmt-name>Split-it-right sample divider</fmt-name> <image src="#{File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets/rice_image1.png'))}" id="_" mimetype="image/png"/> <image src="assets/rice_image1.png" id="_" mimetype="image/png"/> <image src="assets/rice_image1.png" id="_" width="20000" height="300000" mimetype="image/png"/> @@ -881,7 +881,7 @@ <iso-standard xmlns="http://riboseinc.com/isoxml"> <preface><foreword displayorder="1"><fmt-title>Foreword</fmt-title> <figure id="_"> - <name>Split-it-right sample divider</name> + <fmt-name>Split-it-right sample divider</fmt-name> <image src="#{File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets/rice_image1.png'))}" id="_" mimetype="image/png"/> <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/> </figure> @@ -916,7 +916,7 @@ <iso-standard xmlns="http://riboseinc.com/isoxml"> <preface><foreword displayorder="1"><fmt-title>Foreword</fmt-title> <figure id="_"> - <name>Split-it-right sample divider</name> + <fmt-name>Split-it-right sample divider</fmt-name> <image src="#{File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets/rice_image1.png'))}" id="_" mimetype="image/png"/> <image src="assets/rice_image1.png" id="_" mimetype="image/png"/> </figure> @@ -950,7 +950,7 @@ <iso-standard xmlns="http://riboseinc.com/isoxml"> <sections> <terms id="_terms_and_definitions" obligation="normative" displayorder="1"><fmt-title>Terms and Definitions</fmt-title> - <term id="paddy1"><name>1.1.</name><preferred>paddy</preferred> + <term id="paddy1"><fmt-name>1.1.</fmt-name><preferred>paddy</preferred> <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f"><domain>rice</domain>rice retaining its husk after threshing</p></definition> <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892"> <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p> @@ -969,7 +969,7 @@ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p> </modification> </termsource></term> - <term id="paddy"><name>1.2.</name><preferred>paddy</preferred><admitted>paddy rice</admitted> + <term id="paddy"><fmt-name>1.2.</fmt-name><preferred>paddy</preferred><admitted>paddy rice</admitted> <admitted>rough rice</admitted> <deprecates>cargo rice</deprecates> <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition> @@ -1005,7 +1005,7 @@ <iso-standard xmlns="http://riboseinc.com/isoxml"> <preface><foreword displayorder="1"><fmt-title>Foreword</fmt-title> <sourcecode id="samplecode"> - <name>XML code</name> + <fmt-name>XML code</fmt-name> <xml> & </sourcecode> </foreword></preface> diff --git a/spec/isodoc/postproc_word_spec.rb b/spec/isodoc/postproc_word_spec.rb index 9b7731be..9e06f4c1 100644 --- a/spec/isodoc/postproc_word_spec.rb +++ b/spec/isodoc/postproc_word_spec.rb @@ -397,16 +397,16 @@ <clause id="O" inline-header="false" obligation="normative" displayorder="2"> <fmt-title>Clause 4.2</fmt-title> <recommendation id="AC" type="abstracttest" model="default"> - <name>/ogc/recommendation/wfs/3</name> + <fmt-name>/ogc/recommendation/wfs/3</fmt-name> </recommendation> <recommendation id="AA" model="default"> - <name>/ogc/recommendation/wfs/2</name> + <fmt-name>/ogc/recommendation/wfs/2</fmt-name> </recommendation> <recommendation id="AB" type="abstracttest" model="default"> - <name>/ogc/recommendation/wfs/3</name> + <fmt-name>/ogc/recommendation/wfs/3</fmt-name> </recommendation> - <figure id="BA"><name>First figure</name></figure> - <table id="CA"><name>First table</name></table> + <figure id="BA"><fmt-name>First figure</fmt-name></figure> + <table id="CA"><fmt-name>First table</fmt-name></table> <p>A<fn reference="1"> <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p> </fn></p> @@ -459,9 +459,9 @@ toc_input = input.sub(%r{<metanorma-extension>}, <<~MISC, <metanorma-extension> - <toc type="table"><fmt-title>List of tables</fmt-title></toc> - <toc type="figure"><fmt-title>List of figures</fmt-title></toc> - <toc type="recommendation"><fmt-title>List of recommendations</fmt-title></toc> + <toc type="table"><title>List of tables + List of figures + List of recommendations MISC ) IsoDoc::WordConvert.new( @@ -682,7 +682,7 @@ Foreword
- Typical arrangement of the far-field scan set-up + Typical arrangement of the far-field scan set-up
@@ -935,7 +935,7 @@

Foreword

-

  For further information on the Foreword, see ISO/IEC Directives, Part 2, 2016, Clause 12.

+

  For further information on the Foreword, see ISO/IEC Directives, Part 2, 2016, Clause 12.


@@ -963,7 +963,7 @@ From 85add8ac2fca486643e58e71ca47946098d6392d Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Fri, 15 Nov 2024 21:03:36 +1100 Subject: [PATCH 15/78] rspec --- spec/isodoc/ref_spec.rb | 579 ++++++++++++++++++++++++++++++++-------- spec/spec_helper.rb | 4 +- 2 files changed, 464 insertions(+), 119 deletions(-) diff --git a/spec/isodoc/ref_spec.rb b/spec/isodoc/ref_spec.rb index 100cc08a..048d77ec 100644 --- a/spec/isodoc/ref_spec.rb +++ b/spec/isodoc/ref_spec.rb @@ -137,8 +137,16 @@ en - Table of contents - Foreword + #{' '} + Table of contents + + + Foreword + + + Foreword + +

[110] [1] @@ -153,7 +161,21 @@ - 1.<tab/>Normative References + Normative References + + + 1 + . + + + + Normative References + + + + Clause + 1 +

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. @@ -199,7 +221,11 @@ ICC/167, - NOTE + + + NOTE + +

This is an annotation of ISO 20483:2013-2014

@@ -211,7 +237,12 @@ - Bibliography + Bibliography + + + Bibliography + + Chemicals for analytical laboratory use. n.p.: n.d. ISBN: ISBN. [1] @@ -225,11 +256,19 @@ [2] - NOTE + + + NOTE + +

This is an annotation of document ISSN.

- NOTE + + + NOTE + +

This is another annotation of document ISSN.

@@ -378,6 +417,9 @@ +
@@ -419,7 +461,7 @@ amendments) applies.

[110], ISO 712, International Organization for Standardization. Cereals and cereal products.

-

ISO 16634:-- (all parts), Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs.

+

ISO 16634:-- (all parts), Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs.

ISO 20483:2013-2014, International Organization for Standardization. Cereals and pulses. 2013–2014.

ICC/167, Standard No I.C.C 167 @@ -451,7 +493,15 @@

-

[3]  ISO 3696 NOTEREF _Ref \\f \\h_, Water for analytical laboratory use.

+

[3]  ISO 3696 + + + + + + + + , Water for analytical laboratory use.

[4]  Standard No I.C.C 167 . @@ -475,23 +525,36 @@

-

Under preparation. (Stage at the time of publication ISO/DIS 16634)

+

Under preparation. (Stage at the time of publication ISO/DIS 16634)

+
+

+ + + + + + Under preparation. (Stage at the time of publication ISO/DIS 3696) +

+
OUTPUT FileUtils.rm_rf("test.doc") - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) - .convert("test", input, true)) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output) .sub(%r{.*}m, "") .gsub(%r{[0-9a-f-]+}, "_")))) .to be_equivalent_to Xml::C14n.format(html) IsoDoc::WordConvert.new({}) - .convert("test", presxml, false) + .convert("test", pres_output, false) expect(File.exist?("test.doc")).to be true html = File.read("test.doc") .sub(/^.* INPUT presxml = <<~PRESXML - - Table of contents + + #{' '} + Table of contents + + PRESXML - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) + expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + .new(presxml_options) .convert("test", input, true) .sub(%r{.*}m, "")))) .to be_equivalent_to Xml::C14n.format(presxml) @@ -562,7 +634,9 @@ en
- Table of contents + #{' '} + Table of contents +

[110] @@ -578,7 +652,7 @@

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. @@ -738,7 +812,13 @@ en - Foreword + + Foreword + + + Foreword + +

[110] [1] @@ -751,12 +831,26 @@

- Table of contents + Table of contents
@@ -813,7 +914,12 @@
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) + expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + .new(presxml_options) .convert("test", input, true) .sub(%r{.*}m, "")))) .to be_equivalent_to Xml::C14n.format(presxml) @@ -942,19 +1063,44 @@ en - Foreword + + Foreword + + + Foreword + +

[110] ISO 16634:-- (all parts)

- Table of contents + Table of contents + + + Table of contents + +
- 1.<tab/>Normative References + Normative References + + + 1 + . + + + + Normative References + + + + Clause + 1 +

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. @@ -995,9 +1141,10 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) - .convert("test", input, true) - .sub(%r{.*}m, "")))) + expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + .sub(%r{.*}m, "")))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1029,8 +1176,14 @@ INPUT presxml = <<~PRESXML - Foreword -

+ + Foreword + + + Foreword + + +

IEC 217

@@ -1053,7 +1206,22 @@

- Normative References + + Normative References + + + 1 + . + + + + Normative References + + + + Clause + 1 +

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

Cereals or cereal products @@ -1070,16 +1238,22 @@
INPUT presxml = <<~PRESXML - Foreword -

+ + Foreword + + + Foreword + + +

ISO 712 / IEC 217

PRESXML - expect(Xml::C14n.format(Nokogiri::XML( + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true), - ).at("//xmlns:foreword").to_xml)) + ).at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1106,8 +1280,13 @@ INPUT presxml = <<~PRESXML - - Bibliography + + Bibliography + + + Bibliography + + Cereals or cereal products. [1] @@ -1130,10 +1309,10 @@ PRESXML - expect(Xml::C14n.format(Nokogiri::XML( + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true), - ).at("//xmlns:bibliography").to_xml)) + ).at("//xmlns:bibliography").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1160,8 +1339,13 @@ INPUT presxml = <<~PRESXML - - Bibliography + + Bibliography + + + Bibliography + + Cereals or cereal products. [1] @@ -1178,10 +1362,10 @@ PRESXML - expect(Xml::C14n.format(Nokogiri::XML( + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true), - ).at("//xmlns:bibliography").to_xml)) + ).at("//xmlns:bibliography").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1208,8 +1392,13 @@ INPUT presxml = <<~PRESXML - - Bibliography + + Bibliography + + + Bibliography + + Cereals or cereal products. [1] @@ -1232,10 +1421,10 @@ PRESXML - expect(Xml::C14n.format(Nokogiri::XML( + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true), - ).at("//xmlns:bibliography").to_xml)) + ).at("//xmlns:bibliography").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1269,11 +1458,21 @@ INPUT presxml = <<~PRESXML - - 1. - <tab/> - Normative References - + Normative References + + + 1 + . + + + + Normative References + + + + Clause + 1 +

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. @@ -1342,13 +1541,14 @@ OUTPUT - doc = IsoDoc::PresentationXMLConvert.new(presxml_options) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) .convert("test", input, true) - expect(Xml::C14n.format(strip_guid(Nokogiri::XML(doc) - .at("//xmlns:references").to_xml))) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(pres_output) + .at("//xmlns:references").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) - .convert("test", doc, true)))) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(html) end @@ -1380,7 +1580,21 @@ INPUT presxml = <<~PRESXML - 1.<tab/>Normative References + Normative References + + + 1 + . + + + + Normative References + + + + Clause + 1 +

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

International Organization for Standardization and International Electrotechnical Commission. International vocabulary of metrology — Basic and general concepts and associated terms (VIM). First edition. 2007. https://www.iso.org/standard/45324.html. [viewed: #{Date.today.strftime('%B %-d, %Y')}]. @@ -1409,13 +1623,14 @@ OUTPUT - doc = IsoDoc::PresentationXMLConvert.new(presxml_options) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) .convert("test", input, true) - expect(strip_guid(Xml::C14n.format(Nokogiri::XML(doc) - .at("//xmlns:references").to_xml))) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(pres_output) + .at("//xmlns:references").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(strip_guid(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", doc, true)))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(html) end @@ -1484,12 +1699,26 @@ - Table of contents + Table of contents - 1.<tab/>Normative References + Normative References + + + 1 + . + + + + Normative References + + + + Clause + 1 +

Text

@@ -1504,7 +1733,21 @@

More text

- 1.1.<tab/>Normative 1 + Normative 1 + + + 1.1 + . + + + + Normative 1 + + + + Clause + 1.1 + Standard @@ -1519,7 +1762,12 @@
- Bibliography + Bibliography + + + Bibliography + +

Text

@@ -1534,7 +1782,12 @@

More text

- Bibliography 1 + Bibliography 1 + + + Bibliography 1 + + Standard @@ -1606,14 +1859,14 @@ OUTPUT - doc = IsoDoc::PresentationXMLConvert.new(presxml_options) + pres_output = IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true) - xml = Nokogiri::XML(doc) + xml = Nokogiri::XML(pres_output) xml.at("//xmlns:localized-strings").remove expect(strip_guid(Xml::C14n.format(xml.to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) expect(strip_guid(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", doc, true)))) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(html) end @@ -1641,10 +1894,11 @@

OUTPUT - xml = Nokogiri::XML(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)) - expect(strip_guid(Xml::C14n.format(xml.at("//xmlns:foreword").to_xml))) + .convert("test", input, true) + expect(strip_guid(Xml::C14n.format(Nokogiri::XML(pres_output) + .at("//xmlns:foreword").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1675,33 +1929,90 @@ INPUT presxml = <<~OUTPUT - - - Table of contents - - - - - 1.<tab/>First References - - 1.1.<tab/>Normative References 1 - - - 1.2.<tab/>Normative References 2 - - - - - - Bibliography - - Bibliography Subsection 1 - - - Bibliography Subsection 2 - - - + + + Table of contents + + + + + First References + + + 1 + . + + + + First References + + + + Clause + 1 + + + Normative References 1 + + + 1.1 + . + + + + Normative References 1 + + + + Clause + 1.1 + + + + Normative References 2 + + + 1.2 + . + + + + Normative References 2 + + + + Clause + 1.2 + + + + + + + Bibliography + + + Bibliography + + + + Bibliography Subsection 1 + + + Bibliography Subsection 1 + + + + + Bibliography Subsection 2 + + + Bibliography Subsection 2 + + + + + OUTPUT @@ -1730,10 +2041,14 @@ 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(html) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output))) + .to be_equivalent_to Xml::C14n.format(presxml) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) + .to be_equivalent_to Xml::C14n.format(html) end it "sets NO ID to nil" do @@ -1758,12 +2073,26 @@ - Table of contents + Table of contents - 1.<tab/>Normative References 2 + Normative References 2 + + + 1 + . + + + + Normative References 2 + + + + Clause + 1 + Reference 2 (NO ID), @@ -1776,7 +2105,7 @@ OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .sub(%r{.*}m, ""))) .to be_equivalent_to Xml::C14n.format(presxml) mock_i18n @@ -1787,12 +2116,26 @@ - + <fmt-title depth="1"/> </clause> </preface> <sections> <references id="C" obligation="informative" normative="true" displayorder="2"> - <title depth="1">1.<tab/>Normative References 2 + Normative References 2 + + + 1 + . + + + + Normative References 2 + + + + klaŭzo + 1 + Reference 2 @@ -1805,7 +2148,7 @@ OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input.sub(">en<", ">eo<"), true)) - .sub(%r{.*}m, ""))) + .sub(%r{.*}m, ""))) .to be_equivalent_to Xml::C14n.format(presxml) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 614a70aa..03b1ef06 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -66,9 +66,11 @@ def strip_guid(xml) .gsub(%r{ target="_[^"]+"}, ' target="_"') .gsub(%r{ source="_[^"]+"}, ' source="_"') .gsub(%r( href="#_?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12,13}"), ' href="#_"') + .gsub(%r( href="#fn:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12,13}"), ' href="#fn:_"') .gsub(%r( id="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12,13}"), ' id="_"') .gsub(%r( id="ftn[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="ftn_"') - .gsub(%r( id="fn:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' id="fn:_"') + .gsub(%r( id="fn:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12,13}"), ' id="fn:_"') + .gsub(%r( name="_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12,13}"), ' name="_"') .gsub(%r( reference="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"), ' reference="_"') .gsub(%r[ src="([^/]+)/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.], ' src="\\1/_.') end From 4656410e04527b0e8872c51674cfa35443764f20 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Sat, 16 Nov 2024 10:28:59 +1100 Subject: [PATCH 16/78] ensure that anchors are preemptively inserted in ol/li in xrefs processing, to guarantee labels are assigned: https://github.com/metanorma/isodoc/issues/617 --- lib/isodoc/presentation_function/block.rb | 3 - lib/isodoc/xref/xref_gen.rb | 10 +- spec/isodoc/presentation_xml_metadata_spec.rb | 120 +- spec/isodoc/presentation_xml_spec.rb | 1272 +++++++++++------ spec/isodoc/xref_lists_spec.rb | 534 +++---- 5 files changed, 1149 insertions(+), 790 deletions(-) diff --git a/lib/isodoc/presentation_function/block.rb b/lib/isodoc/presentation_function/block.rb index f769cd1c..1fa88d95 100644 --- a/lib/isodoc/presentation_function/block.rb +++ b/lib/isodoc/presentation_function/block.rb @@ -185,9 +185,6 @@ def ol_depth(node) def ol1(elem) elem["type"] ||= ol_depth(elem).to_s - elem.xpath(ns("./li")).each do |li| - li["id"] ||= "_#{UUIDTools::UUID.random_create}" - end elem.at(ns("./name")) and prefix_name(elem, {}, "", "name") # copy name to fmt-name end diff --git a/lib/isodoc/xref/xref_gen.rb b/lib/isodoc/xref/xref_gen.rb index dc609ce2..998124bb 100644 --- a/lib/isodoc/xref/xref_gen.rb +++ b/lib/isodoc/xref/xref_gen.rb @@ -149,11 +149,11 @@ def list_item_anchor_names(list, list_anchor, depth, 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}#{list_item_delim}], - type: "listitem", refer_list:, - container: list_anchor[:container] } + li["id"] ||= "_#{UUIDTools::UUID.random_create}" + @anchors[li["id"]] = + { label: bare_label, bare_xref: "#{label})", type: "listitem", + xref: %[#{label}#{list_item_delim}], 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) diff --git a/spec/isodoc/presentation_xml_metadata_spec.rb b/spec/isodoc/presentation_xml_metadata_spec.rb index dcb62ba4..2a137f5c 100644 --- a/spec/isodoc/presentation_xml_metadata_spec.rb +++ b/spec/isodoc/presentation_xml_metadata_spec.rb @@ -43,23 +43,46 @@ - - Table of contents - Foreword -

- - xmlns:sodipodi - - Figure 1 -

-
- -
- Figure 1 — Split-it-right sample divider - -
-
-
+ + + Table of contents + + + Foreword + + + Foreword + + +

+ + xmlns:sodipodi + + + Figure + 1 + +

+
+ +
+ Split-it-right sample divider + + + Figure + 1 +  — + Split-it-right sample divider + + + + Figure + 1 + + +
+
+
OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert @@ -81,22 +104,26 @@
INPUT output = <<~OUTPUT - - - - - - user-css - .green { background-color: green } - - - .green { background-color: green } - - + + + + + user-css + + + user-css + + + .green { background-color: green } + + + .green { background-color: green } + + OUTPUT - expect(Xml::C14n.format(IsoDoc::PresentationXMLConvert.new(presxml_options) + expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, "")) + .sub(%r{.*}m, ""))) .to be_equivalent_to Xml::C14n.format(output) end @@ -122,17 +149,17 @@ List of recommendations - Table of contents - OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + xml = Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ tocfigures: true, toctables: true, tocrecommendations: true } .merge(presxml_options)) - .convert("test", input, true))) - .sub(%r{.*}m, "")) + .convert("test", input, true)) + xml.xpath("//xmlns:preface | //xmlns:localized-strings | //xmlns:sections") + .each(&:remove) + expect(Xml::C14n.format(strip_guid(xml.to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -167,26 +194,15 @@ font1 - Table of contents - - - - 1. - <tab/> - Section - -
- Figure 1 — First -
-
-
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + xml = Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ fonts: "font1; font2", fontlicenseagreement: "no-install-fonts" } .merge(presxml_options)) - .convert("test", input, true))) - .sub(%r{.*}m, "")) + .convert("test", input, true)) + xml.xpath("//xmlns:preface | //xmlns:localized-strings | //xmlns:sections") + .each(&:remove) + expect(Xml::C14n.format(strip_guid(xml.to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end diff --git a/spec/isodoc/presentation_xml_spec.rb b/spec/isodoc/presentation_xml_spec.rb index f2c52cc4..05a1ed1e 100644 --- a/spec/isodoc/presentation_xml_spec.rb +++ b/spec/isodoc/presentation_xml_spec.rb @@ -32,19 +32,38 @@ INPUT output = <<~OUTPUT - - Table of contents - - - A - - B - - C - + + + + Table of contents - - + + + + A + + + A + + + + B + + + B + + + + C + + + C + + + + + + OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert @@ -158,64 +177,110 @@ INPUT presxml = <<~OUTPUT - - - Table of contents - - - - <strong>Annex A</strong> - <br/> - (normative). - <tab/> - Clause - -

Text

- - - <strong>Annex A</strong> - <br/> - (normative). - <tab/> - Subclause - - “A” ‘B’ - - Clause - A - - - x - - x - - -

Text

+ + + + + Table of contents + + + + + Clause + + + + Annex + A + +
+ (normative) + . + + + + Clause +
+
+ + Annex + A + +

Text

+ + Subclause + + + + Annex + A + +
+ (normative) + . + + + + Subclause +
+
+ + Annex + A + + “A” ‘B’ + + Clause + A + + + x + + x + + +

Text

-
-
- - - <strong>Annex A</strong> - <br/> - (normative) - <br/> - <br/> + </clause> + </sections> + <annex id="_" inline-header="false" obligation="normative" autonum="A" displayorder="3"> + <title id="_"> <strong>Clause</strong> - - - Clause - A - - - x - - x - - -

Text

-
-
+ + + + + Annex + A + +
+ (normative) + +
+
+
+ + Clause + +
+
+ + Annex + A + + + Clause + A + + + x + + x + + +

Text

+ +
OUTPUT html = <<~OUTPUT #{HTML_HDR} @@ -223,14 +288,14 @@

Annex A
- (normative).   Clause + (normative).  Clause

Text

Annex A
- (normative).   Subclause + (normative).  Subclause

“A” ‘B’ @@ -333,16 +398,17 @@ OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + pres_output = IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(pres_output + .sub(%r{.*}m, "")))) .to be_equivalent_to Xml::C14n.format(presxml) - expect(Xml::C14n.format(IsoDoc::HtmlConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(html) - expect(Xml::C14n.format(IsoDoc::WordConvert.new({}) - .convert("test", presxml, true))) + expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({}) + .convert("test", pres_output, true)))) .to be_equivalent_to Xml::C14n.format(doc) end @@ -364,14 +430,17 @@ INPUT output = <<~OUTPUT - - - - Table of contents - - - 1.<tab/>Clause -
Figure 1 +
+ + + Figure + 1 + + + + Figure + 1 + 1 2 @@ -395,14 +464,11 @@
- - - OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options.merge(output_formats: { html: "html", doc: "doc" })) - .convert("test", input, true) - .sub(%r{.*}m, "") + .convert("test", input, true)) + .at("//xmlns:figure[@id = 'B']").to_xml .sub(%r{.*}m, "") .gsub(%r{"data:image/emf;base64,[^"]+"}, '"data:image/emf;base64"') @@ -411,56 +477,52 @@ .to be_equivalent_to (Xml::C14n.format(output)) output = <<~OUTPUT - - - - - Table of contents - - - - - 1.<tab/>Clause -
- Figure 1 - 1 - 2 - - - - - - +
+ +
+ Figure + 1 + + + + Figure + 1 + + 1 + 2 + + + + + - - - - 3 - - - - - - 4 - - - - - - + + + + + 3 + + + + + + 4 + + + + + - - - -
-
-
-
+ + + + +
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options.merge(output_formats: { html: "html" })) - .convert("test", input, true) - .sub(%r{.*}m, "") + .convert("test", input, true)) + .at("//xmlns:figure[@id = 'B']").to_xml .sub(%r{.*}m, "") .gsub(%r{"data:image/emf;base64,[^"]+"}, '"data:image/emf;base64"') @@ -683,24 +745,24 @@
INPUT output = <<~OUTPUT - - - - Table of contents - - - 1.<tab/>Clause -
Figure 1 - 3 -
-
-
-
+
+ + + Figure + 1 + + + + Figure + 1 + + 3 +
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true) - .sub(%r{.*}m, "") + .convert("test", input, true)) + .at("//xmlns:figure[@id = 'B']").to_xml .gsub(%r{src="[^"]+?\.emf"}, 'src="_.emf"') .gsub(%r{src="[^"]+?\.svg"}, 'src="_.svg"')))) .to be_equivalent_to (output) @@ -721,24 +783,24 @@ INPUT output = <<~OUTPUT - - - - Table of contents - - - 1.<tab/>Clause -
Figure 1 - 3 -
-
-
-
+
+ + + Figure + 1 + + + + Figure + 1 + + 3 +
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) - .convert("test", input, true) - .sub(%r{.*}m, "") + .convert("test", input, true)) + .at("//xmlns:figure[@id = 'B']").to_xml .gsub(%r{src="[^"]+?\.svg"}, 'src="_.svg"')))) .to be_equivalent_to(output) end @@ -785,72 +847,59 @@ INPUT presxml = <<~OUTPUT - - - Table of contents - - - - 1. - <tab/> - Clause - -
    -
  1. - A1 -
      -
    1. - A2 -
        -
      1. - A3 -
          -
        1. - A4 -
            -
          1. - A5 -
              -
            1. - A6 -
                -
              1. - A7 -
                  -
                1. - A8 -
                    -
                  1. - A9 -
                      -
                    1. A0
                    2. -
                    -
                  2. -
                  -
                2. -
                -
              2. -
              -
            2. -
            -
          2. -
          -
        2. -
        -
      2. -
      -
    2. -
    -
  2. -
-
-
-
+
    +
  1. + A1 +
      +
    1. + A2 +
        +
      1. + A3 +
          +
        1. + A4 +
            +
          1. + A5 +
              +
            1. + A6 +
                +
              1. + A7 +
                  +
                1. + A8 +
                    +
                  1. + A9 +
                      +
                    1. A0
                    2. +
                    +
                  2. +
                  +
                2. +
                +
              2. +
              +
            2. +
            +
          2. +
          +
        2. +
        +
      2. +
      +
    2. +
    +
  2. +
OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:ol[@id = 'B1']").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -860,7 +909,21 @@ - Clause + Clause + + + 1 + . + + + + Clause + + + + Clause + 1 +
  1. A1
      @@ -875,38 +938,24 @@ INPUT presxml = <<~OUTPUT - - - - Table of contents - - - - 1. - <tab/> - Clause - -
        -
      1. - A1 -
          -
        • - A2 -
            -
          1. A3
          2. -
          -
        • -
        -
      2. -
      -
      -
      -
      +
        +
      1. + A1 +
          +
        • + A2 +
            +
          1. A3
          2. +
          +
        • +
        +
      2. +
      OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:ol[@id = 'B1']").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -952,25 +1001,112 @@ INPUT presxml = <<~OUTPUT - Section -

      Clauses 1 to 2 - text - Clauses 1 and 2 - Clauses 1, 2, and 3 - text - Clauses 1 or 2 - Clauses 1, 2, or 3 - Clauses 1 to 2 and 3 to 4 - Clause 5, a) 1) to b) 1) + Section + + + Section + + +

      + + Clauses + 1 + + to + + 2 + + + + + text + + + Clauses + 1 + + and + + 2 + + + Clauses + 1 + + , + + 2 + + , and + + 3 + + + + + text + + + Clauses + 1 + + or + + 2 + + + Clauses + 1 + + , + + 2 + + , or + + 3 + + + Clauses + 1 + + to + + 2 + + and + + 3 + + to + + 4 + + Clause + 5 + , + + a + ) + 1 + ) + + to + + b + ) + 1 + ) +

      -
      + OUTPUT - expect(Xml::C14n.format(Nokogiri::XML( + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true), ) .at("//xmlns:foreword") - .to_xml)) + .to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1015,24 +1151,120 @@ INPUT presxml = <<~OUTPUT - - Section -

      箇条1箇条2text箇条1 and 箇条2 - 箇条1箇条2, and 箇条3 - text - 箇条1 or 箇条2 - 箇条1箇条2, or 箇条3 - 箇条1箇条2 and 箇条3箇条4 - 箇条5のa)の1)箇条5のb)の1) -

      -
      +

      + + 箇条 + 1 + + ~ + + 箇条 + 2 + + + + + text + + + 箇条 + 1 + + and + + 箇条 + 2 + + + 箇条 + 1 + + , + + 箇条 + 2 + + , and + + 箇条 + 3 + + + + + text + + + 箇条 + 1 + + or + + 箇条 + 2 + + + 箇条 + 1 + + , + + 箇条 + 2 + + , or + + 箇条 + 3 + + + 箇条 + 1 + + ~ + + 箇条 + 2 + + and + + 箇条 + 3 + + ~ + + 箇条 + 4 + + + 箇条 + 5 + の + a + ) + の + 1 + ) + + ~ + + 箇条 + 5 + の + b + ) + の + 1 + ) + +

      OUTPUT - expect(Xml::C14n.format(Nokogiri::XML( + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true), ) - .at("//xmlns:foreword") - .to_xml)) + .at("//xmlns:p[@id = 'A']") + .to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1082,30 +1314,15 @@ INPUT presxml = <<~OUTPUT - - - Table of contents - - - - 2. - <tab/> - Section - -

      - A - to - B -

      -
      -
      -
      +

      + A + to + B +

      OUTPUT xml = Nokogiri::XML(IsoDoc::PresentationXMLConvert.new(presxml_options) .convert("test", input, true)) - xml.at("//xmlns:localized-strings")&.remove - xml.at("//xmlns:bibliography")&.remove - xml.at("//xmlns:references")&.remove + xml = xml.at("//xmlns:p[@id = 'A2']") expect(Xml::C14n.format(strip_guid(xml.to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1138,43 +1355,105 @@ INPUT presxml = <<~OUTPUT - - - - Table of contents - - - - 1. - <tab/> - Section - -
      - Figure 1 — First + + Section + + + 1 + . + + + + Section + + + + Clause + 1 + +
      + First + + + Figure + 1 +  — + First + + + + Figure + 1 + +
      + + + + EXAMPLE + 1 + + + + Example + 1 + +
      + Second + + + Figure + 2 +  — + Second + + + + Figure + 2 +
      - - EXAMPLE 1 -
      - Figure 2 — Second -
      -
      - - EXAMPLE 2 -
      - Unnamed -
      -
      -
      - Figure 3 — Third + + + + + EXAMPLE + 2 + + + + Example + 2 + +
      + Unnamed + + + Unnamed + +
      - - - +
      +
      + Third + + + Figure + 3 +  — + Third + + + + Figure + 3 + +
      + OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:clause[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1200,34 +1479,63 @@ INPUT presxml = <<~OUTPUT - - Table of contents - - - - 1. - <tab/> - Scope - -

      A

      -

      - ISO 639-2 -

      -
      - - - 2. - <tab/> - Terms and definitions - -

      No terms and definitions are listed in this document.

      -
      - -
      - - + + + + Table of contents + + + + + Scope + + + 1 + . + + + + Scope + + + + Clause + 1 + +

      A

      +

      + ISO 639-2 +

      +
      + + Terms and definitions + + + 2 + . + + + + Terms and definitions + + + + Clause + 2 + +

      No terms and definitions are listed in this document.

      +
      + +
      + +
      OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert @@ -1243,32 +1551,19 @@ Scope -

      http://www.example.com

      +

      http://www.example.com

      INPUT presxml = <<~OUTPUT - - - Table of contents - - - - 1. - <tab/> - Scope - -

      - http://www.example.com -

      -
      -
      -
      +

      + http://www.example.com +

      OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:p[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1296,7 +1591,7 @@ - Table of contents + Table of contents @@ -1351,14 +1646,16 @@ - Table of contents + Table of contents

      FL 1

      FL 2

      FL 3

      FL 4

      - Foreword + + ForewordForeword +

      FL 5

      FL 6

      @@ -1391,26 +1688,30 @@
      INPUT presxml = <<~OUTPUT - - Table of contents - Foreword - Table 1 - - - - - - - -
      http://www.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBBBBBBBBhttp://www.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBwww.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBB
      -
      -
      -
      + + + + Table + 1 + + + + Table + 1 + + + + + + + + +
      http://www.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBBBBBBBBhttp://www.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBwww.example.com/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBB
      OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:table").to_xml))) .to be_equivalent_to Xml::C14n.format(presxml) end @@ -1447,41 +1748,47 @@ INPUT presxml = <<~OUTPUT - - Table of contents - Foreword - Table 1 - - - - - - - - - - - - - - - - - - - - - - - -
      http://​www.example.​com/​AAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­AAAAAAAA/​BBBBBBBBBBB­BBBBBBBBBBBBBBBBBhttp://​www.example.​com/​AAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­AAAAAAAABBBBBBBBBBBB­BBBBBBBBBBBBBBBBwww.​example.com/​AAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­ABBBBBBBBBBBBBBBBBBB­BBBBBBBBBaaaaaaaa_​aaaaaaaaaa.​aaaaaaaaaa.0aaaaaaaaa​<a>aaaaaaaaa​<<a>>aaaaaaaaa/​aaaaaaaaaa//​aaaaaaaaaa+​aaaaaaaaaa+​0aaaaaaaaa​{aaaaaaaaaa;​{aaaaaaaaaa​(aaaaaaaaaa(0aaaaaaaa0(aaaaaaaaa­AaaaaaaaaaaaAAaaa
      -
      + + + + Table + 1 + + + + Table + 1 + + + + + + + + + + + + + + + + + + + + + + + + +
      http://​www.example.​com/​AAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­AAAAAAAA/​BBBBBBBBBBB­BBBBBBBBBBBBBBBBBhttp://​www.example.​com/​AAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­AAAAAAAABBBBBBBBBBBB­BBBBBBBBBBBBBBBBwww.​example.com/​AAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAA­ABBBBBBBBBBBBBBBBBBB­BBBBBBBBBaaaaaaaa_​aaaaaaaaaa.​aaaaaaaaaa.0aaaaaaaaa​<a>aaaaaaaaa​<<a>>aaaaaaaaa/​aaaaaaaaaa//​aaaaaaaaaa+​aaaaaaaaaa+​0aaaaaaaaa​{aaaaaaaaaa;​{aaaaaaaaaa​(aaaaaaaaaa(0aaaaaaaa0(aaaaaaaaa­AaaaaaaaaaaaAAaaa
      OUTPUT - expect(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options.merge(breakupurlsintables: "true")) .convert("test", input, true)) - .sub(%r{.*}m, "")) - .to be_equivalent_to (presxml) + .at("//xmlns:table").to_xml))) + .to be_equivalent_to Xml::C14n.format(presxml) end it "realises custom charsets" do @@ -1496,16 +1803,19 @@ presxml = <<~OUTPUT weather:"OGC Weather Symbols",conscript:"Code 2000" - Table of contents + + Table of contents + - Foreword + + ForewordForeword

      OUTPUT - expect(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, "")) + .sub(%r{.*}m, ""))) .to be_equivalent_to (presxml) end @@ -1525,9 +1835,12 @@ INPUT presxml = <<~OUTPUT - Table of contents + + Table of contents + - Foreword + + ForewordForeword

      ABCDABC ABC @@ -1537,10 +1850,10 @@

      OUTPUT - expect(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, "")) + .sub(%r{.*}m, ""))) .to be_equivalent_to (presxml) end @@ -1561,23 +1874,56 @@ INPUT presxml = <<~OUTPUT - Table of contents - - Foreword -

      - Table 1 - - -
      -
      Figure 1X
      -
      -

      -
      + + + Table of contents + + + Foreword + + + Foreword + + +

      + + + + Table + 1 + + + + Table + 1 + + + + +
      +
      + + + Figure + 1 + + + + Figure + 1 + + X +
      +
      +

      +
      +
      + OUTPUT - expect(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert .new(presxml_options) .convert("test", input, true)) - .sub(%r{.*}m, "")) + .sub(%r{.*}m, ""))) .to be_equivalent_to (presxml) end end diff --git a/spec/isodoc/xref_lists_spec.rb b/spec/isodoc/xref_lists_spec.rb index 93bcfe7c..7bcde789 100644 --- a/spec/isodoc/xref_lists_spec.rb +++ b/spec/isodoc/xref_lists_spec.rb @@ -324,109 +324,109 @@ .to be_equivalent_to Xml::C14n.format(output) input1 = input.sub(%r{en}, "ja") output = <<~OUTPUT - - まえがき - - - まえがき - - -

      - - 序文 - の - a - - - - 序文 - の - a - - の - 1 - - - - 序文 - の - a - - の - 1 - - の - i - - - - Preparatory - の - 1 - - - - 箇条 - 1 - の - i - - - - 箇条 - 3.1 - の - リスト - 1 - の - a - - - - 箇条 - 3.1 - の - リスト - 2 - の - I - - - - 附属書 - A.1 - の - A - - - - 附属書 - A.2 - の - リスト - 1 - の - iv - - - - 附属書 - A.2 - の - リスト - 2 - の - a - - - - Bibliographical Section - の - a - - -

      -
      + + まえがき + + + まえがき + + +

      + + 序文 + の + a + ) + + + 序文 + の + a + ) + の + 1 + ) + + + 序文 + の + a + ) + の + 1 + ) + の + i + ) + + + Preparatory + の + 1 + ) + + + 箇条 + 1 + の + i + ) + + + 箇条 + 3.1 + の + リスト + 1 + の + a + ) + + + 箇条 + 3.1 + の + リスト + 2 + の + I + ) + + + 附属書 + A.1 + の + A + ) + + + 附属書 + A.2 + の + リスト + 1 + の + iv + ) + + + 附属書 + A.2 + の + リスト + 2 + の + a + ) + + + Bibliographical Section + の + a + ) + +

      +
      OUTPUT expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) @@ -650,170 +650,170 @@ input1 = input.sub(%r{en}, "ja") output = <<~OUTPUT - まえがき - - - まえがき - - -

      - - 箇条 - 1 - の - a - - - - 箇条 - 1 - の - a - - の - 1 - - - - 箇条 - 1 - の - a - - の - 1 - - の - i - - - - 箇条 - 1 - の - a - - の - 1 - - の - i - - の - A - - - - 箇条 - 1 - の - a - - の - 1 - - の - i - - の - A - - の - I - - - - 箇条 - 1 - の - a - - の - 1 - - の - i - - の - A - - の - I - - の - a - - - - 箇条 - 2 - の - リスト - 1 - の - a - - - - 箇条 - 2 - の - リスト - 1 - の - a - - の - 1 - - - - 箇条 - 2 - の - リスト - 1 - の - a - - の - 1 - - の - i - - - - 箇条 - 2 - の - リスト - 1 - の - a - - の - 1 - - の - i - - の - A - - - - 箇条 - 2 - の - リスト - 2 - の - a - - -

      -
      + まえがき + + + まえがき + + +

      + + 箇条 + 1 + の + a + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + の + i + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + の + i + ) + の + A + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + の + i + ) + の + A + ) + の + I + ) + + + 箇条 + 1 + の + a + ) + の + 1 + ) + の + i + ) + の + A + ) + の + I + ) + の + a + ) + + + 箇条 + 2 + の + リスト + 1 + の + a + ) + + + 箇条 + 2 + の + リスト + 1 + の + a + ) + の + 1 + ) + + + 箇条 + 2 + の + リスト + 1 + の + a + ) + の + 1 + ) + の + i + ) + + + 箇条 + 2 + の + リスト + 1 + の + a + ) + の + 1 + ) + の + i + ) + の + A + ) + + + 箇条 + 2 + の + リスト + 2 + の + a + ) + +

      + OUTPUT expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new(presxml_options) From 2cd6ca01e4c2deeb5c4a018c399cc98644afa374 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Sat, 16 Nov 2024 10:46:19 +1100 Subject: [PATCH 17/78] rspec --- spec/isodoc/presentation_xml_maths_spec.rb | 140 +++++++++------------ 1 file changed, 57 insertions(+), 83 deletions(-) diff --git a/spec/isodoc/presentation_xml_maths_spec.rb b/spec/isodoc/presentation_xml_maths_spec.rb index db4d6982..3f7c2b44 100644 --- a/spec/isodoc/presentation_xml_maths_spec.rb +++ b/spec/isodoc/presentation_xml_maths_spec.rb @@ -214,12 +214,8 @@
      - Table of contents - - Table of contents + Sommaire - Sommaire -

      30 000 PXXmax=j=Xmax1 0001 000jpj1p1,003jP (X ge X_(max)) = sum_(j = X_(max))^(1000) ([[1000], [j]]) p^(j) (1 - p)^(1.003 - j)

      @@ -253,10 +249,9 @@ test fr
      - - Table of contents + Sommaire

      30'000 @@ -297,7 +292,7 @@ - Table of contents + Inhaltsübersicht

      ... 64212149677264515 642121496772;64515 30000

      @@ -362,7 +357,7 @@ test -

      +

      0.0 @@ -490,7 +485,7 @@ 30000 - +

      INPUT end @@ -505,15 +500,7 @@ })) output1 = <<~OUTPUT - - - test - - - - Table of contents - -

      +

      0.00 31.00 327,428.74 @@ -558,16 +545,15 @@ 64,21'00'00'00 × 10-21sqrt(0.6421214967726451564515e-19) 30 000,00

      -
      -
      +

      OUTPUT TwitterCldr.reset_locale_fallbacks - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ localizenumber: "#=#0;##$#" } .merge(presxml_options)) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:p[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(output1) end @@ -580,15 +566,7 @@ })) output1 = <<~OUTPUT - - - test - - - - Table of contents - -

      +

      0.0 31 327,428.74'32'87'84'32'99'2 @@ -632,16 +610,15 @@ 0,00'00'00'00'00'00'00'00'00'06'42'12'14'96'8 64,21'21'49'68 × 10-21sqrt(0.6421214967726451564515e-19) 30 000 - - +

      OUTPUT TwitterCldr.reset_locale_fallbacks - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ localizenumber: "#=#0;##$#" } .merge(presxml_options)) - .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .convert("test", input, true)) + .at("//xmlns:p[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(output1) end @@ -655,15 +632,7 @@ })) output1 = <<~OUTPUT - - - test - - - - Table of contents - -

      +

      0.0 31 327,428.74'32'87'84'32'99'2 @@ -707,16 +676,15 @@ 6,42'12'14'96'8 × 10-20 6,42'12'14'96'8 × 10-20sqrt(0.6421214967726451564515e-19) 30 000 - - +

      OUTPUT TwitterCldr.reset_locale_fallbacks - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ localizenumber: "#=#0;##$#" } .merge(presxml_options)) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:p[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(output1) end @@ -732,14 +700,7 @@ })) output1 = <<~OUTPUT - - - test - - - Table of contentsi - -

      +

      0.0 31 3.27'42'87'43'28'78'43'29'92 × 105 @@ -791,16 +752,14 @@ 3,00'00 × 10 4

      -
      -
      OUTPUT TwitterCldr.reset_locale_fallbacks - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ localizenumber: "#=#0;##$#" } .merge(presxml_options)) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:p[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(output1) end @@ -819,6 +778,7 @@ test +

      @@ -855,21 +815,12 @@ 3 + x +

      INPUT output = <<~OUTPUT - - - test - - - - Table of contents - - - -

      test

      +

      @@ -906,14 +857,13 @@ 3 + x - - +

      OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert .new({ localizenumber: "#=#0;##$#" } .merge(presxml_options)) .convert("test", input, true)) - .sub(%r{.*}m, ""))) + .at("//xmlns:p[@id = 'A']").to_xml))) .to be_equivalent_to Xml::C14n.format(output) end end @@ -954,10 +904,22 @@ presxml = <<~OUTPUT - Table of contents - Foreword + + Table of contents + + + Foreword + + + Foreword + + - NOTE + + + NOTE + + @@ -1020,13 +982,25 @@ - Table of contents + Table of contents - - (1) + + + + ( + 1 + ) + + + + Formula + ( + 1 + ) + From 441f86ea75b1be4968be3bb06f784181650e887b Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Sat, 16 Nov 2024 10:50:47 +1100 Subject: [PATCH 18/78] rspec --- spec/isodoc/lists_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/isodoc/lists_spec.rb b/spec/isodoc/lists_spec.rb index 290c071d..fee6eeb4 100644 --- a/spec/isodoc/lists_spec.rb +++ b/spec/isodoc/lists_spec.rb @@ -194,7 +194,7 @@ Table of contents Foreword
        - Caption + Caption
      1. all information necessary for the complete identification of the sample;

      2. @@ -268,19 +268,19 @@

        Foreword

        Caption

        -
          -
        1. -

          all information necessary for the complete identification of the sample;

          +
            +
          1. +

            all information necessary for the complete identification of the sample;

            1. -

              a reference to this document (i.e. ISO 17301-1);

              +

              a reference to this document (i.e. ISO 17301-1);

              1. -

                the sampling method used;

                +

                the sampling method used;

              @@ -302,8 +302,8 @@ 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))) + expect(Xml::C14n.format(strip_guid(IsoDoc::WordConvert.new({}) + .convert("test", input, true)))) .to be_equivalent_to Xml::C14n.format(word) end @@ -363,7 +363,7 @@ Table of contents Foreword
              - Caption + Caption
              W
              @@ -452,7 +452,7 @@
              -

                This is a note

              +

                This is a note

              From ffc5bbfe8cfb8ef3595edb129ac7fbe0e60a32bd Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Sat, 16 Nov 2024 11:12:45 +1100 Subject: [PATCH 19/78] rspec --- spec/isodoc/inline_spec.rb | 554 +++++++++++++++---------------------- 1 file changed, 220 insertions(+), 334 deletions(-) diff --git a/spec/isodoc/inline_spec.rb b/spec/isodoc/inline_spec.rb index 9d4c7439..e4cc0ff2 100644 --- a/spec/isodoc/inline_spec.rb +++ b/spec/isodoc/inline_spec.rb @@ -71,33 +71,26 @@ input = <<~INPUT -

              +

              INPUT output = <<~OUTPUT - - - - Table of contents - - Foreword -

              2021-01-01

              -
              -
              - -
              +

              2021-01-01

              OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(output) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true)) + .at("//xmlns:p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(output) end it "ignores index entries" do input = <<~INPUT -

              +

              @@ -106,27 +99,20 @@
              INPUT output = <<~OUTPUT - - - - Table of contents - - Foreword -

              - - - - +

              OUTPUT - expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert.new(presxml_options) - .convert("test", input, true)))).to be_equivalent_to Xml::C14n.format(output) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true)) + .at("//xmlns:p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(output) end it "processes concept markup" do input = <<~INPUT -

              +

              • term @@ -225,144 +211,117 @@ INPUT presxml = <<~OUTPUT - - - - Table of contents - - Foreword -

                -

                  -
                • - (Clause 2) -
                • -
                • term - (Clause 2) -
                • -
                • w[o]rd - [Clause #1] -
                • -
                • term - (ISO 712) -
                • -
                • word - [The Aforementioned Citation] -
                • -
                • word - (ISO 712, Clause 3.1, Figure a) -
                • -
                • word - (ISO 712, Clause 3.1 and Figure b) -
                • -
                • word - [ - The Aforementioned Citation - ] -
                • -
                • word - () -
                • -
                • word - [The IEV database] -
                • -
                • - error! -
                • -
                -

                -
                -
                - - - 2.<tab/>Clause 1 - - - 1.<tab/>Normative References -

                The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

                - - International Organization for Standardization. Cereals and cereal products. - ISO 712 - ISO 712 - ISO 712, - -
                -
                - -
                +

                +

                  +
                • + ( + Clause + 2 + ) +
                • +
                • term + ( + Clause + 2 + ) +
                • +
                • w[o]rd + [Clause #1] +
                • +
                • term + (ISO 712) +
                • +
                • word + [The Aforementioned Citation] +
                • +
                • word + (ISO 712, Clause 3.1, Figure a) +
                • +
                • word + (ISO 712, Clause 3.1 and Figure b) +
                • +
                • word + [ + The Aforementioned Citation + ] +
                • +
                • word + () +
                • +
                • word + [The IEV database] +
                • +
                • + error! +
                • +
                +

                OUTPUT - output = <<~OUTPUT - #{HTML_HDR} -
                -
                -

                Foreword

                -

                -

                -
                -
                -

                1.  Normative References

                -

                The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

                -

                ISO 712, International Organization for Standardization. Cereals and cereal products.

                -
                -
                -

                2.  Clause 1

                -
                -
                - - + The Aforementioned Citation + ] +
              • +
              • word + (Termbase IEV, term ID 135-13-13) +
              • +
              • word + [The IEV database] +
              • +
              • + error! +
              • +
              +
            +

            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) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(pres_output) + .at("//xmlns:p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(presxml) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( + IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true), + ) + .at("//p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(html) end it "processes concept attributes" do input = <<~INPUT -

            +

            • termterm,
            • termterm,
            • @@ -391,96 +350,80 @@ INPUT + presxml = <<~OUTPUT - - - - Table of contents - - Foreword -

              -

                -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term,
              • -
              • term,
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • term (Clause 1),
              • -
              • - error! -
              • -
              • - CV_DiscreteCoverage -
              • -
              -

              -
              -
              - - - 1.<tab/>Clause 1 - - -
              +

              +

                +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term,
              • +
              • term,
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • term (Clause 1),
              • +
              • + error! +
              • +
              • + CV_DiscreteCoverage +
              • +
              +

              OUTPUT - output = <<~OUTPUT - #{HTML_HDR} -
              -
              -

              Foreword

              -

              -

              - -
              -

              -
              -
              -

              1.  Clause 1

              -
              -
        - - + html = <<~OUTPUT +

        +

        + +
        +

        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) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(pres_output) + .at("//xmlns:p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(presxml) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( + IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true), + ) + .at("//p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(html) end it "processes concept markup for symbols" do input = <<~INPUT -

        +

        • term @@ -502,68 +445,33 @@ INPUT presxml = <<~OUTPUT - - - - Table of contents - - Foreword -

          -

            -
          • ISO
          • -
          -

          -
          -
          - - - 1.<tab/>Symbols -
          -
          ISO
          -
          xyz
          -
          IEC
          -
          abc
          -
          -
          -
          -
          +

          +

            +
          • ISO
          • +
          +

          OUTPUT - output = <<~OUTPUT - #{HTML_HDR} -
          -
          -

          Foreword

          -

          -

          -
            -
          • ISO
          • -
          -
          -

          -
          -
          -

          1.  Symbols

          -
          -
          -
          -

          ISO

          -
          -
          xyz
          -
          -

          IEC

          -
          -
          abc
          -
          -
          -
          -

- - + html = <<~OUTPUT +

+

+
    +
  • ISO
  • +
+
+

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) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(pres_output) + .at("//xmlns:p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(presxml) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( + IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true), + ) + .at("//p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(html) end it "processes embedded inline formatting" do @@ -1037,7 +945,7 @@ input = <<~INPUT -

+

1 @@ -1074,11 +982,7 @@ INPUT presxml = <<~OUTPUT - - - Table of contents - Foreword -

+

ISO 712 ISO 712 ISO 712, Table 1 @@ -1098,28 +1002,10 @@ ISO 712, 1 ISO 712, clause 1

-
- 1.<tab/>Normative References - - Cereals and cereal products. - ISO 712 - ISO 712 - ISO 712, - - - - - -
OUTPUT html = <<~OUTPUT - #{HTML_HDR} -
-
-

Foreword

-

+

ISO 712 ISO 712 ISO 712, Table 1 @@ -1139,19 +1025,19 @@ ISO 712, 1 ISO 712, clause 1

-
-
-

1.  Normative References

-

ISO 712, Cereals and cereal products.

-
-
- - 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(html) + pres_output = IsoDoc::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML(pres_output) + .at("//xmlns:p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(presxml) + expect(Xml::C14n.format(strip_guid(Nokogiri::XML( + IsoDoc::HtmlConvert.new({}) + .convert("test", pres_output, true), + ) + .at("//p[@id = 'A']").to_xml))) + .to be_equivalent_to Xml::C14n.format(html) end it "processes eref content pointing to reference with citation URL" do From b3413bd8629e1bdbc01864584e7cf3fddbc4bfe1 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Sat, 16 Nov 2024 23:02:42 +1100 Subject: [PATCH 20/78] rspec --- spec/isodoc/inline_spec.rb | 463 +++++++++++++++++-------------------- 1 file changed, 217 insertions(+), 246 deletions(-) diff --git a/spec/isodoc/inline_spec.rb b/spec/isodoc/inline_spec.rb index e4cc0ff2..3f0e0c87 100644 --- a/spec/isodoc/inline_spec.rb +++ b/spec/isodoc/inline_spec.rb @@ -982,26 +982,26 @@ INPUT presxml = <<~OUTPUT -

- ISO 712 - ISO 712 - ISO 712, Table 1 - ISO 712, Table 1 - ISO 712, Table 1 and Clause 1 - ISO 712, Table 1–1 - ISO 712, Clause 1, Table 1 - ISO 712, Clause 1 - ISO 712, Clause 1.5 - A - ISO 712, Whole of text - ISO 712, Prelude 7 - ISO 712, URI 7 - A - ISO 712 - ISO 712, Clause 1 - ISO 712, 1 - ISO 712, clause 1 -

+

+ ISO 712 + ISO 712 + ISO 712, Table 1 + ISO 712, Table 1 + ISO 712, Table 1 and Clause 1 + ISO 712, Table 1–1 + ISO 712, Clause 1, Table 1 + ISO 712, Clause 1 + ISO 712, Clause 1.5 + A + ISO 712, Whole of text + ISO 712, Prelude 7 + ISO 712, URI 7 + A + ISO 712 + ISO 712, Clause 1 + ISO 712, 1 + ISO 712, clause 1 +

OUTPUT html = <<~OUTPUT @@ -1254,7 +1254,7 @@ input = <<~INPUT -

+

1 @@ -1298,135 +1298,81 @@ INPUT presxml = <<~PRESXML - - - Table of contents - Foreword -

- ISO 712 - ISO 712 - ISO 713, Table 1 - ISO 713, Table 1 - ISO 713, Table 1 and Clause 1 - ISO 713, Table 1–1 - ISO 713, Clause 1, Table 1 - ISO 713, Clause 1 - ISO 713, Clause 1.5 - A - ISO 713, Whole of text - ISO 713, Prelude 7 - A - ISO 713 - ISO 713, Clause 1 -

-
-
- - - - - -
+

+ ISO 712 + ISO 712 + ISO 713, Table 1 + ISO 713, Table 1 + ISO 713, Table 1 and Clause 1 + ISO 713, Table 1–1 + ISO 713, Clause 1, Table 1 + ISO 713, Clause 1 + ISO 713, Clause 1.5 + A + ISO 713, Whole of text + ISO 713, Prelude 7 + A + ISO 713 + ISO 713, Clause 1 +

PRESXML html = <<~OUTPUT - #{HTML_HDR} -
- -
- - +

+ ISO 712 + ISO 712 + ISO 713, Table 1 + ISO 713, Table 1 + ISO 713, Table 1 and Clause 1 + ISO 713, Table 1–1 + ISO 713, Clause 1, Table 1 + ISO 713, Clause 1 + ISO 713, Clause 1.5 + A + ISO 713, Whole of text + ISO 713, Prelude 7 + A + ISO 713 + ISO 713, Clause 1 +

OUTPUT word = <<~OUTPUT - - - - -
-

 

-
-

-
-

-
-

-
-

-
-

Table of contents

-
-

-
-

-
+ #{WORD_HDR} +

+
+

+

Foreword

EXAMPLE — Title

@@ -443,60 +443,84 @@ INPUT output = <<~OUTPUT - - - - Table of contents - - - Foreword - - Foreword - - - - - EXAMPLE - 1 - - - - Example - 1 - -

Hello

-
- - Title - - - EXAMPLE - 2 - -  — - Title - - - Example - 2 - -

Hello

-
- - - - EXAMPLE - - - - Example - (??) - -

Hello

-
-
-
-
+ + + + Table of contents + + + Foreword + + Foreword + + + + + EXAMPLE + 1 + + + + Example + 1 + + + + Foreword + + , + Example + 1 + +

Hello

+
+ + Title + + + EXAMPLE + 2 + +  — + Title + + + Example + 2 + + + + Foreword + + , + Example + 2 + +

Hello

+
+ + + + EXAMPLE + + + + Example + (??) + + + + Foreword + + , + Example + (??) + +

Hello

+
+
+
+
OUTPUT expect(Xml::C14n.format(strip_guid(IsoDoc::PresentationXMLConvert .new(presxml_options) @@ -534,101 +558,119 @@ INPUT presxml = <<~INPUT - - - - Table of contents - - - Foreword - - Foreword - - - r = 1 % -

where

-
-
- r -
-
-

is the repeatability limit.

-
-
- - - - NOTE - - - - - - - Note - -

[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.

-
-
- - - - ( - 1 - ) - - - - Formula - ( - 1 - ) - - r = 1 % - -
- - - - - Annex - A - - -
- (informative) -
- - Annex - A - - - - - ( - A - . - 1 - ) - - - - Formula - ( - A - . - 1 - ) - - r = 1 % - -
-
+ + + + Table of contents + + + Foreword + + Foreword + + + r = 1 % +

where

+
+
+ r +
+
+

is the repeatability limit.

+
+
+ + + + NOTE + + + + + + + Note + + + + Foreword + + , + Note + +

[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.

+
+
+ + + + ( + 1 + ) + + + + Formula + ( + 1 + ) + + + + Foreword + + , + Formula + ( + 1 + ) + + r = 1 % + +
+
+ + + + + Annex + A + + +
+ (informative) +
+ + Annex + A + + + + + ( + A + . + 1 + ) + + + + Formula + ( + A + . + 1 + ) + + r = 1 % + +
+
INPUT html = <<~OUTPUT #{HTML_HDR}
-
+

Foreword

(#(r = 1 %)#)

where

@@ -666,29 +708,11 @@ OUTPUT word = <<~OUTPUT - - - - - -
-

 

-
-

-
-

-
-

-
-

-
-

Table of contents

-
+ #{WORD_HDR}


-
+

Foreword

@@ -802,18 +826,7 @@ OUTPUT word = <<~OUTPUT - - - - -

-

 

-
-

-
-

-
-

-
-

-
-

Table of contents

-
+ #{WORD_HDR}


-
+

Foreword

@@ -644,7 +615,7 @@ Table of contents - + Foreword Foreword @@ -846,25 +817,7 @@ HTML doc = <<~DOC - - - - - -
-

 

-
-

-
-

-
-

-
-

-
-

Table of contents

-
+ #{WORD_HDR}


@@ -960,25 +913,7 @@ OUTPUT word = <<~OUTPUT - - - - - -
-

 

-
-

-
-

-
-

-
-

-
-

Table of contents

-
+ #{WORD_HDR}


diff --git a/spec/isodoc/footnotes_spec.rb b/spec/isodoc/footnotes_spec.rb index 2625b48a..1aed0444 100644 --- a/spec/isodoc/footnotes_spec.rb +++ b/spec/isodoc/footnotes_spec.rb @@ -88,25 +88,7 @@ OUTPUT doc = <<~OUTPUT - - - - - -
-

 

-
-

-
-

-
-

-
-

-
-

Table of contents

-
+ #{WORD_HDR}


diff --git a/spec/isodoc/form_spec.rb b/spec/isodoc/form_spec.rb index 9f86353c..0a5f801f 100644 --- a/spec/isodoc/form_spec.rb +++ b/spec/isodoc/form_spec.rb @@ -110,6 +110,12 @@ doc = <<~DOC #{WORD_HDR} +

 

+
+

+
+

+

diff --git a/spec/isodoc/i18n_spec.rb b/spec/isodoc/i18n_spec.rb index a7349faf..bca442e6 100644 --- a/spec/isodoc/i18n_spec.rb +++ b/spec/isodoc/i18n_spec.rb @@ -1908,16 +1908,24 @@ NOTO - - - + noto + + + klaŭzo + 5 + . + 1 + + + noto + @@ -2153,7 +2161,7 @@

5.1.  Introduction

- NOTO   + NOTO 

diff --git a/spec/isodoc/lists_spec.rb b/spec/isodoc/lists_spec.rb index ac8cab2b..a07f8c11 100644 --- a/spec/isodoc/lists_spec.rb +++ b/spec/isodoc/lists_spec.rb @@ -22,7 +22,7 @@ html = <<~OUTPUT #{HTML_HDR}
-
+

Foreword

Caption

@@ -41,26 +41,11 @@ OUTPUT word = <<~OUTPUT - - - - -
-

 

-
-

-
-

-
-

-
-

-
-

Table of contents

-
+ #{WORD_HDR}


diff --git a/spec/isodoc/sourcecode_spec.rb b/spec/isodoc/sourcecode_spec.rb index 623b12d3..934ca03c 100644 --- a/spec/isodoc/sourcecode_spec.rb +++ b/spec/isodoc/sourcecode_spec.rb @@ -18,7 +18,7 @@ Table of contents - + Foreword Foreword @@ -56,7 +56,7 @@ html = <<~OUTPUT #{HTML_HDR}
-
+

Foreword

puts x

@@ -76,26 +76,11 @@ OUTPUT doc = <<~OUTPUT - -