From c46ae37b83a4ef86b94bded55fdb1ce6377c9199 Mon Sep 17 00:00:00 2001 From: Nick Nicholas Date: Wed, 6 Nov 2024 23:34:41 +1100 Subject: [PATCH] move delimiter and italicising for example names to Presentation XML: https://github.com/metanorma/isodoc/issues/613 --- Gemfile.devel | 6 ++-- lib/isodoc/ieee/base_convert.rb | 2 -- lib/isodoc/ieee/presentation_xml_convert.rb | 7 +++++ lib/isodoc/ieee/word_cleanup_blocks.rb | 1 - spec/isodoc/blocks_spec.rb | 35 ++++++++++++++++----- spec/isodoc/terms_spec.rb | 26 +++++++-------- 6 files changed, 52 insertions(+), 25 deletions(-) diff --git a/Gemfile.devel b/Gemfile.devel index 24ae2ae..d1466a4 100644 --- a/Gemfile.devel +++ b/Gemfile.devel @@ -1,2 +1,4 @@ -gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc", branch: "main" -gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "main" +gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/presxml-20241106" + + + diff --git a/lib/isodoc/ieee/base_convert.rb b/lib/isodoc/ieee/base_convert.rb index 1b2366d..5618193 100644 --- a/lib/isodoc/ieee/base_convert.rb +++ b/lib/isodoc/ieee/base_convert.rb @@ -55,11 +55,9 @@ def note_parse1(node, div) node.children.each { |n| parse(n, div) } end - # TODO ":" to Presentation XML def example_label(_node, div, name) return if name.nil? - name << ":" div.p class: "example-title" do |p| name.children.each { |n| parse(n, p) } end diff --git a/lib/isodoc/ieee/presentation_xml_convert.rb b/lib/isodoc/ieee/presentation_xml_convert.rb index b22b528..946c2a7 100644 --- a/lib/isodoc/ieee/presentation_xml_convert.rb +++ b/lib/isodoc/ieee/presentation_xml_convert.rb @@ -212,6 +212,13 @@ def move_abstract(doc) dest.children.first.next = source end + def example1(elem) + super + n = elem.at(ns("./name")) or return + n << l10n(":") + n.children.wrap("") + end + include Init end end diff --git a/lib/isodoc/ieee/word_cleanup_blocks.rb b/lib/isodoc/ieee/word_cleanup_blocks.rb index 4d3f69f..7d1b557 100644 --- a/lib/isodoc/ieee/word_cleanup_blocks.rb +++ b/lib/isodoc/ieee/word_cleanup_blocks.rb @@ -99,7 +99,6 @@ def figure_caption(docxml) def example_caption(docxml) docxml.xpath("//p[@class = 'example-title']").each do |s| - s.children = "#{to_xml(s.children)}" s["class"] = stylesmap[:MsoNormal] end end diff --git a/spec/isodoc/blocks_spec.rb b/spec/isodoc/blocks_spec.rb index 5719b5f..d48b034 100644 --- a/spec/isodoc/blocks_spec.rb +++ b/spec/isodoc/blocks_spec.rb @@ -739,16 +739,32 @@

 

OUTPUT - expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::Ieee::HtmlConvert.new({}) + expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::Ieee::HtmlConvert + .new({}) .convert("test", presxml, true)) .at("//body").to_xml))).to be_equivalent_to Xml::C14n.format(html) - expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::Ieee::WordConvert.new({}) + expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::Ieee::WordConvert + .new({}) .convert("test", presxml, true)) .at("//div[@class = 'WordSection2']").to_xml))) .to be_equivalent_to Xml::C14n.format(word) end it "processes examples" do + input = <<~INPUT + + + Foreword + +

Hello

+ + Sample + +
+
+
+
+ INPUT presxml = <<~INPUT @@ -757,7 +773,7 @@ Foreword - Example 1 + Example:

Hello

Sample @@ -773,7 +789,7 @@

Foreword

-

Example 1:

+

Example:

Hello

                  
@@ -794,7 +810,7 @@
OUTPUT - expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::Ieee::HtmlConvert.new({}) + expect(Xml::C14n.format(strip_guid(IsoDoc::Ieee::PresentationXMLConvert + .new(presxml_options) + .convert("test", input, true).gsub("<", "<")))) + .to be_equivalent_to Xml::C14n.format(presxml) + expect(strip_guid(Xml::C14n.format(Nokogiri::XML(IsoDoc::Ieee::HtmlConvert + .new({}) .convert("test", presxml, true)) .at("//body").to_xml))).to be_equivalent_to Xml::C14n.format(html) IsoDoc::Ieee::WordConvert.new({}).convert("test", presxml, false) @@ -1095,7 +1116,7 @@ Figure - Example A.7 + Example A.7:

This is not generalised further.

diff --git a/spec/isodoc/terms_spec.rb b/spec/isodoc/terms_spec.rb index 289b2db..da6e81e 100644 --- a/spec/isodoc/terms_spec.rb +++ b/spec/isodoc/terms_spec.rb @@ -107,14 +107,14 @@ , modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here)

- Example 1 + Example 1:

Foreign seeds, husks, bran, sand, dust.

  • A
- Example 2 + Example 2:
  • A
@@ -154,7 +154,7 @@

DEPRECATED: cargo rice - Example + Example:
  • A
@@ -215,7 +215,7 @@ , 3.1 , modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here)

-

Example 1:

+

Example 1:

Foreign seeds, husks, bran, sand, dust.

    @@ -224,7 +224,7 @@
-

Example 2:

+

Example 2:

  • A
  • @@ -255,7 +255,7 @@

    DEPRECATED: cargo rice

    -

    Example:

    +

    Example:

    • A
    • @@ -339,7 +339,7 @@ , 3.1 , modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here)

      -

      Example 1:

      +

      Example 1:

      Foreign seeds, husks, bran, sand, dust.

        @@ -348,7 +348,7 @@
      -

      Example 2:

      +

      Example 2:

      • A
      • @@ -379,7 +379,7 @@

        DEPRECATED: cargo rice

        -

        Example:

        +

        Example:

        • A
        • @@ -671,14 +671,14 @@ — with adjustments)

          - Example 1 + Example 1:

          Foreign seeds, husks, bran, sand, dust.

          • A
          - Example 2 + Example 2:
          • A
          @@ -760,14 +760,14 @@ , modified — with adjustments)

          - Example 1 + Example 1:

          Foreign seeds, husks, bran, sand, dust.

          • A
          - Example 2 + Example 2:
          • A