Skip to content

Commit

Permalink
Merge pull request #431 from metanorma/fix/presxml-20241106
Browse files Browse the repository at this point in the history
move delimiter and italicising for example names to Presentation XML:…
  • Loading branch information
opoudjis authored Nov 10, 2024
2 parents d66c2db + c46ae37 commit 5e8a84d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 25 deletions.
6 changes: 4 additions & 2 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -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"



2 changes: 0 additions & 2 deletions lib/isodoc/ieee/base_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions lib/isodoc/ieee/presentation_xml_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("<em></em>")
end

include Init
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/isodoc/ieee/word_cleanup_blocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def figure_caption(docxml)

def example_caption(docxml)
docxml.xpath("//p[@class = 'example-title']").each do |s|
s.children = "<em>#{to_xml(s.children)}</em>"
s["class"] = stylesmap[:MsoNormal]
end
end
Expand Down
35 changes: 28 additions & 7 deletions spec/isodoc/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -739,16 +739,32 @@
<p>&#xa0;</p>
</div>
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
<iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
<preface>
<foreword id="A"><title>Foreword</title>
<example id='samplecode' keep-with-next='true' keep-lines-together='true'>
<p>Hello</p>
<sourcecode id='X'>
<name>Sample</name>
</sourcecode>
</example>
</foreword>
</preface>
</iso-standard>
INPUT
presxml = <<~INPUT
<iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
<preface>
Expand All @@ -757,7 +773,7 @@
</clause>
<foreword displayorder="2" id="A"><title>Foreword</title>
<example id='samplecode' keep-with-next='true' keep-lines-together='true'>
<name>Example 1</name>
<name><em>Example:</em></name>
<p>Hello</p>
<sourcecode id='X'>
<name>Sample</name>
Expand All @@ -773,7 +789,7 @@
<div id="A">
<h1 class='ForewordTitle'>Foreword</h1>
<div id='samplecode' class='example' style='page-break-after: avoid;page-break-inside: avoid;'>
<p class='example-title'>Example 1:</p>
<p class='example-title'><i>Example:</i></p>
<p>Hello</p>
<pre id='X' class='sourcecode'>
<br/>
Expand All @@ -794,7 +810,7 @@
<div class='IEEEStdsParagraph' style='page-break-after: avoid;page-break-inside: avoid;'>
<a name='samplecode' id='samplecode'/>
<p class='IEEEStdsParagraph'>
<em>Example 1:</em>
<i>Example:</i>
</p>
<p class='IEEEStdsParagraph'>Hello</p>
<p class='IEEEStdsComputerCode' style='page-break-after:avoid;'>
Expand All @@ -806,7 +822,12 @@
</div>
</div>
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("&lt;", "&#x3c;"))))
.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)
Expand Down Expand Up @@ -1095,7 +1116,7 @@
<name>Figure</name>
</figure>
<example id='F' number='A.7'>
<name>Example A.7</name>
<name><em>Example A.7:</em></name>
<p id='G'>This is not generalised further.</p>
</example>
</quote>
Expand Down
26 changes: 13 additions & 13 deletions spec/isodoc/terms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@
, modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here)
</p>
<termexample id="_" keep-with-next="true" keep-lines-together="true">
<name>Example 1</name>
<name><em>Example 1:</em></name>
<p id="_">Foreign seeds, husks, bran, sand, dust.</p>
<ul>
<li>A</li>
</ul>
</termexample>
<termexample id="_">
<name>Example 2</name>
<name><em>Example 2:</em></name>
<ul>
<li>A</li>
</ul>
Expand Down Expand Up @@ -154,7 +154,7 @@
</p>
<deprecates>DEPRECATED: cargo rice</deprecates>
<termexample id="_">
<name>Example</name>
<name><em>Example:</em></name>
<ul>
<li>A</li>
</ul>
Expand Down Expand Up @@ -215,7 +215,7 @@
, 3.1 , modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here)
</p>
<div id="_" class="example" style="page-break-after: avoid;page-break-inside: avoid;">
<p class="example-title">Example 1:</p>
<p class="example-title"><i>Example 1:</i></p>
<p id="_">Foreign seeds, husks, bran, sand, dust.</p>
<div class="ul_wrap">
<ul>
Expand All @@ -224,7 +224,7 @@
</div>
</div>
<div id="_" class="example">
<p class="example-title">Example 2:</p>
<p class="example-title"><i>Example 2:</i></p>
<div class="ul_wrap">
<ul>
<li>A</li>
Expand Down Expand Up @@ -255,7 +255,7 @@
</p>
<p class="DeprecatedTerms" style="text-align:left;">DEPRECATED: cargo rice</p>
<div id="_" class="example">
<p class="example-title">Example:</p>
<p class="example-title"><i>Example:</i></p>
<div class="ul_wrap">
<ul>
<li>A</li>
Expand Down Expand Up @@ -339,7 +339,7 @@
, 3.1 , modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here)
</p>
<div id="_" class="example" style="page-break-after: avoid;page-break-inside: avoid;">
<p class="example-title">Example 1:</p>
<p class="example-title"><i>Example 1:</i></p>
<p id="_">Foreign seeds, husks, bran, sand, dust.</p>
<div class="ul_wrap">
<ul>
Expand All @@ -348,7 +348,7 @@
</div>
</div>
<div id="_" class="example">
<p class="example-title">Example 2:</p>
<p class="example-title"><i>Example 2:</i></p>
<div class="ul_wrap">
<ul>
<li>A</li>
Expand Down Expand Up @@ -379,7 +379,7 @@
</p>
<p class="DeprecatedTerms" style="text-align:left;">DEPRECATED: cargo rice</p>
<div id="_" class="example">
<p class="example-title">Example:</p>
<p class="example-title"><i>Example:</i></p>
<div class="ul_wrap">
<ul>
<li>A</li>
Expand Down Expand Up @@ -671,14 +671,14 @@
&#x2014;
with adjustments)</p>
<termexample id="_" keep-with-next="true" keep-lines-together="true">
<name>Example 1</name>
<name><em>Example 1:</em></name>
<p id="_">Foreign seeds, husks, bran, sand, dust.</p>
<ul>
<li>A</li>
</ul>
</termexample>
<termexample id="_">
<name>Example 2</name>
<name><em>Example 2:</em></name>
<ul>
<li>A</li>
</ul>
Expand Down Expand Up @@ -760,14 +760,14 @@
, modified &#x2014; with adjustments)
</p>
<termexample id='_' keep-with-next='true' keep-lines-together='true'>
<name>Example 1</name>
<name><em>Example 1:</em></name>
<p id='_'>Foreign seeds, husks, bran, sand, dust.</p>
<ul>
<li>A</li>
</ul>
</termexample>
<termexample id='_'>
<name>Example 2</name>
<name><em>Example 2:</em></name>
<ul>
<li>A</li>
</ul>
Expand Down

0 comments on commit 5e8a84d

Please sign in to comment.