Skip to content

Commit

Permalink
include dl title in postprocessing of table keys: #1162
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Apr 24, 2024
1 parent cade4a1 commit 46090b6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/table-key"
7 changes: 7 additions & 0 deletions lib/isodoc/iso/presentation_xml_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ def formula_where_one(dlist)
dlist.remove
end

def table1(elem)
elem.xpath(ns(".//dl[@key = 'true'][not(./name)]")).each do |dl|
dl.children.first.previous = "<name>#{@i18n.key}</name>"
end
super
end

def toc_title(docxml)
%w(amendment technical-corrigendum).include?(@doctype) and return
super
Expand Down
25 changes: 17 additions & 8 deletions spec/isodoc/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<td align="center">6,06</td>
</tr>
</tfoot>
<dl>
<dl key="true">
<dt>Drago</dt>
<dd>A type of rice</dd>
</dl>
Expand Down Expand Up @@ -88,7 +88,7 @@
</iso-standard>
INPUT
presxml = <<~OUTPUT
<iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
<iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
<preface>
<clause type="toc" id="_" displayorder="1">
<title depth="1">Contents</title>
Expand Down Expand Up @@ -141,7 +141,8 @@
<td align="center">6,06</td>
</tr>
</tfoot>
<dl>
<dl key="true">
<name>Key</name>
<dt>Drago</dt>
<dd>A type of rice</dd>
</dl>
Expand Down Expand Up @@ -175,7 +176,7 @@
OUTPUT

html = <<~OUTPUT
<main class="main-section">
<main class="main-section">
<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<br/>
<br/>
Expand Down Expand Up @@ -232,6 +233,7 @@
</tr>
<tr>
<td colspan="5" style="border-top:0pt;border-bottom:solid windowtext 1.5pt;">
<p class="ListTitle">Key</p>
<dl>
<dt>
<p>Drago</p>
Expand Down Expand Up @@ -277,7 +279,7 @@
OUTPUT

doc = <<~OUTPUT
<div>
<div>
<table xmlns:m="m" class="MsoISOTable" style="mso-table-anchor-horizontal:column;mso-table-overlap:never;border-spacing:0;border-width:1px;" title="tool tip" summary="long desc">
<a name="tableD-1" id="tableD-1"/>
<thead>
Expand Down Expand Up @@ -324,6 +326,10 @@
</tr>
<tr>
<td colspan="5" style="border-top:0pt;mso-border-top-alt:0pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;">
<div class="figdl">
<p class="ListTitle">Key</p>
<p style="text-indent: -2.0cm; margin-left: 2.0cm; tab-stops: 2.0cm;" class="MsoNormal">Drago<span style="mso-tab-count:1">  </span>A type of rice</p>
</div>
<div class="BlockSource">
<p class="MsoNormal">[SOURCE: , Section 1
&#x2014;
Expand All @@ -341,7 +347,6 @@
</td>
</tr>
</tfoot>
<p style="text-indent: -2.0cm; margin-left: 2.0cm; tab-stops: 2.0cm;" class="MsoNormal">Drago<span style="mso-tab-count:1">  </span>A type of rice</p>
</table>
</div>
OUTPUT
Expand All @@ -366,7 +371,8 @@
</div>
</div>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::Iso::PresentationXMLConvert.new(presxml_options)
expect(xmlpp(strip_guid(IsoDoc::Iso::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
IsoDoc::Iso::HtmlConvert.new({}).convert("test", presxml, false)
expect(File.exist?("test.html")).to be true
Expand Down Expand Up @@ -554,7 +560,9 @@
<td align="center" style="border-top:none;mso-border-top-alt:none;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;page-break-after:auto;">81,2</td>
</tr>
</tbody>
<div class="figdl">
<p style="text-indent: -2.0cm; margin-left: 2.0cm; tab-stops: 2.0cm;">Drago<span style="mso-tab-count:1">  </span>A type of rice</p>
</div>
<div id="A" class="Note"><p class="Note"><span class="note_label">NOTE 1</span><span style="mso-tab-count:1">  </span></p>Note 1</div>
<div id="C" class="Note"><p class="Note"><span class="note_label">NOTE 2</span><span style="mso-tab-count:1">  </span></p>Note 2</div>
</table>
Expand All @@ -571,7 +579,8 @@
<div class="colophon"/>
</body>
OUTPUT
expect(xmlpp(strip_guid(IsoDoc::Iso::PresentationXMLConvert.new(presxml_options)
expect(xmlpp(strip_guid(IsoDoc::Iso::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true)))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({})
.convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
Expand Down

0 comments on commit 46090b6

Please sign in to comment.