Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include dl title in postprocessing of table keys: https://github.com/… #576

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/isodoc/function/cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ def new_fullcolspan_row(table, tfoot)
tfoot.xpath(".//td").last
end

TABLENOTE_CSS = "div[@class = 'Note' or @class = 'BlockSource' " \
"or @class = 'TableFootnote' or @class = 'figdl']".freeze

def table_note_cleanup(docxml)
docxml.xpath("//table[dl or div[@class = 'Note' or @class = 'BlockSource' " \
"or @class = 'TableFootnote']]").each do |t|
docxml.xpath("//table[dl or #{TABLENOTE_CSS}]").each do |t|
tfoot = table_get_or_make_tfoot(t)
insert_here = new_fullcolspan_row(t, tfoot)
t.xpath("dl | div[@class = 'Note' or @class = 'BlockSource' or " \
"@class = 'TableFootnote']")
t.xpath("dl | p[@class = 'ListTitle'] | #{TABLENOTE_CSS}")
.each do |d|
d.parent = insert_here
end
Expand Down
8 changes: 5 additions & 3 deletions lib/isodoc/function/lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ def dl_attrs(node)
end

def dl_parse(node, out)
list_title_parse(node, out)
out.dl **dl_attrs(node) do |v|
out.div **attr_code(class: "figdl") do |div|
list_title_parse(node, div)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 2 (not 0) spaces for indentation.

div.dl **dl_attrs(node) do |v|
node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
dl_parse1(v, dt, dd)
end
end
dl_parse_notes(node, out)
dl_parse_notes(node, div)
end
end

def dl_parse_notes(node, out)
Expand Down
10 changes: 6 additions & 4 deletions lib/isodoc/word_function/lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ def dl_parse(node, out)
end

def dl_parse_nontable(node, out)
node["id"] and bookmark_parse(node, out)
list_title_parse(node, out)
out.div **attr_code(class: "figdl") do |div|
node["id"] and bookmark_parse(node, div)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 2 (not 0) spaces for indentation.

list_title_parse(node, div)
node.elements.select { |n| dt_dd?(n) }
.each_slice(2) do |dt, dd|
dl_parse_nontable1(out, dt, dd)
dl_parse_nontable1(div, dt, dd)
end
dl_parse_notes(node, div)
end
dl_parse_notes(node, out)
end

WORD_EMBED_DL_ATTRS =
Expand Down
2 changes: 2 additions & 0 deletions spec/isodoc/blocks_notes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@
<div>
<h1 class="ForewordTitle">Foreword</h1>
<div id="A" class="Note"><p><span class="note_label">NOTE</span>&#160; </p>
<div class="figdl">
<dl><dt><p>A</p></dt><dd><p>B</p></dd></dl>
</div>
<ul>
<li>C</li></ul>
</div>
Expand Down
5 changes: 4 additions & 1 deletion spec/isodoc/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,14 @@
<br/>
<div>
<h1 class="ForewordTitle">Foreword</h1>
<div id="_" style='page-break-after: avoid;page-break-inside: avoid;'><div class="formula"><p><span class="stem">(#(r = 1 %)#)</span></p></div><p style='page-break-after: avoid;'>where</p><dl id="_" class="formula_dl"><dt>
<div id="_" style='page-break-after: avoid;page-break-inside: avoid;'><div class="formula"><p><span class="stem">(#(r = 1 %)#)</span></p></div><p style='page-break-after: avoid;'>where</p>
<div class="figdl">
<dl id="_" class="formula_dl"><dt>
<span class="stem">(#(r)#)</span>
</dt><dd>
<p id="_">is the repeatability limit.</p>
</dd></dl>
</div>


<div id="_" class="Note"><p><span class="note_label">NOTE</span>&#160; [durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.</p></div></div>
Expand Down
5 changes: 4 additions & 1 deletion spec/isodoc/figures_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@
<a href="#_" class="TableFootnoteRef">a</a><aside class="footnote"><div id="fn:_"><span><span id="_" class="TableFootnoteRef">a</span>&#160; </span>
<p id="_">The time <span class="stem">(#(t_90)#)</span> was estimated to be 18,2 min for this example.</p>
</div></aside>
<p style='page-break-after:avoid;'><b>Key</b></p><dl><dt><p>A</p></dt><dd><p>B</p></dd></dl>
<p style='page-break-after:avoid;'><b>Key</b></p>
<div class="figdl">
<dl><dt><p>A</p></dt><dd><p>B</p></dd></dl>
</div>
<div class="BlockSource">
<p>[SOURCE: <a href="#ISO712">ISO&#xa0;712, Section 1</a> &#x2014; with adjustments]</p>
</div>
Expand Down
16 changes: 16 additions & 0 deletions spec/isodoc/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,20 @@
<p class="TermNum" id="J">3.1.1.</p>
<p class="Terms" style="text-align:left;"><b>Term2</b></p>
</div><div id="K"><h2>3.2.</h2>
<div class="figdl">
<dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
</div>
</div></div>
<div id="L" class="Symbols">
<h1>4.</h1>
<div class="figdl">
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
</div>
<div id="M">
<h1>5.&#160; Clause 4</h1>
Expand Down Expand Up @@ -565,16 +569,20 @@
<p class="TermNum" id="J">3.1.1.</p>
<p class="Terms" style="text-align:left;"><b>Term2</b></p>
</div><div id="K"><h2>3.2.</h2>
<div class="figdl">
<dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
</div>
</div></div>
<div id="L" class="Symbols">
<h1>4.</h1>
<div class="figdl">
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
</div>
<div id="M">
<h1>5.&#160; Clause 4</h1>
Expand Down Expand Up @@ -813,17 +821,21 @@

</div>
<div id="K"><h2>3.2.</h2>
<div class="figdl">
<dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
</div>
</div>
</div>
<div id="L" class="Symbols">
<h1>4.</h1>
<div class="figdl">
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
</div>
<div id="M">
<h1>5. Clause 4</h1>
Expand Down Expand Up @@ -1095,22 +1107,26 @@
</div>
<div id='K'>
<h2>3.2.</h2>
<div class="figdl">
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
</div>
</div>
<div id='L' class='Symbols'>
<h1>4.</h1>
<div class="figdl">
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
</div>
<div id='M'>
<h1>5.&#160; Clause 4</h1>
Expand Down
2 changes: 2 additions & 0 deletions spec/isodoc/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@
</div>
<div id='d' class='Symbols'>
<h1>1.</h1>
<div class="figdl">
<dl>
<dt id='d1'>
<p>ISO</p>
Expand All @@ -547,6 +548,7 @@
</dt>
<dd>abc</dd>
</dl>
</div>
</div>
</div>
</body>
Expand Down
6 changes: 6 additions & 0 deletions spec/isodoc/lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
<br/>
<div>
<h1 class="ForewordTitle">Foreword</h1>
<div class="figdl">
<p class='ListTitle'>Caption</p>
<dl id="_732d3f57-4f88-40bf-9ae9-633891edc395" style="page-break-after: avoid;page-break-inside: avoid;">
<dt>
Expand All @@ -379,6 +380,7 @@
</dl>
<div class="Note">
<p>&#160; This is a note</p>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -503,8 +505,10 @@
<p align="left" style="margin-left:0pt;text-align:left;">A Deflist</p>
</td>
<td valign="top">
<div class="figdl">
<a id="_732d3f57-4f88-40bf-9ae9-633891edc395"/>
<p style="text-indent: -2.0cm; margin-left: 2.0cm; tab-stops: 2.0cm;">W<span style="mso-tab-count:1">  </span>mass fraction of gelatinized kernels</p>
</div>
</td>
</tr>
</table>
Expand All @@ -513,8 +517,10 @@
<tbody>
<tr>
<td style="border-top:solid windowtext 1.5pt;mso-border-top-alt:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;page-break-after:auto;">
<div class="figdl">
<a id="_732d3f57-4f88-40bf-9ae9-633891edc397"/>
<p style="text-indent: -2.0cm; margin-left: 2.0cm; tab-stops: 2.0cm;">X<span style="mso-tab-count:1">  </span>expressed in per cent</p>
</div>
</td>
</tr>
</tbody>
Expand Down
8 changes: 8 additions & 0 deletions spec/isodoc/section_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,20 @@
<p class="TermNum" id="J">3.1.1.</p>
<p class="Terms" style="text-align:left;"><b>Term2</b></p>
</div><div id="K"><h2>3.2.&#160; Definitions</h2>
<div class="figdl">
<dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
</div>
</div></div>
<div id="L" class="Symbols">
<h1>4.&#160; Symbols and abbreviated terms</h1>
<div class="figdl">
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
</div>
<div id="M">
<h1>5.&#160; Clause 4</h1>
Expand Down Expand Up @@ -932,12 +936,14 @@
<br/>
Variant 1
</h2>
<div class="figdl">
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
</div>
</div>
<div id='L' class='Symbols'>
Expand All @@ -947,12 +953,14 @@
<br/>
Variant 1
</h1>
<div class="figdl">
<dl>
<dt>
<p>Symbol</p>
</dt>
<dd>Definition</dd>
</dl>
</div>
</div>
<div id='M'>
<h1>
Expand Down
4 changes: 4 additions & 0 deletions spec/isodoc/sourcecode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@
<h1 class="ForewordTitle">Foreword</h1>
<pre id="_" class="sourcecode">puts "Hello, world." <span class="c"> &lt;1&gt;</span><span class="c"> &lt;2&gt;</span> <br/>   %w{a b c}.each do |x|<br/>     puts x <span class="c"> &lt;3&gt;</span><br/>   end</pre>
<div class="annotation">
<div class="figdl">
<p class="ListTitle">Key</p>
<dl>
<dt id="A">
Expand All @@ -556,6 +557,7 @@
<p id="_">This is yet another callout</p>
</dd>
</dl>
</div>
</div>
<p class="SourceTitle" style="text-align:center;">Figure 1</p>
</div>
Expand Down Expand Up @@ -743,6 +745,7 @@
                 <pre class="sourcecode">puts "Hello, world." <span class="c"> &lt;1&gt;</span>  <span class="c"> &lt;2&gt;</span> </pre>
</td></tr><tr><td style="" class="rouge-gutter gl"><pre>2</pre></td><td style="" class="rouge-code"><pre class="sourcecode">   %w{a b c}.each do |x|</pre></td></tr><tr><td style="" class="rouge-gutter gl"><pre>3</pre></td><td style="" class="rouge-code"><pre class="sourcecode">     puts x <span class="c"> &lt;3&gt;</span> </pre></td></tr><tr><td style="" class="rouge-gutter gl"><pre>4</pre></td><td style="" class="rouge-code"><pre class="sourcecode">   end</pre></td></tr></tbody></table></div>
<div class="annotation">
<div class="figdl">
<p class="ListTitle">Key</p>
<dl>
<dt id="A">
Expand All @@ -764,6 +767,7 @@
<p id="_">This is yet another callout</p>
</dd>
</dl>
</div>
</div>
<p class="SourceTitle" style="text-align:center;">Figure 1</p>
</div>
Expand Down
12 changes: 10 additions & 2 deletions spec/isodoc/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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 @@ -171,7 +172,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 @@ -266,12 +268,15 @@
<td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">6,06</td>
</tr>
</tfoot>
<div class="figdl">
<p class="ListTitle">Key</p>
<dl>
<dt>
<p>Drago</p>
</dt>
<dd>A type of rice</dd>
</dl>
</div>
<div class="BlockSource">
<p>[SOURCE: <a href="#ISO712">ISO 712, Section 1</a> —
with adjustments]</p>
Expand Down Expand Up @@ -386,7 +391,10 @@
<td align="center" style="border-top:solid windowtext 1.5pt;mso-border-top-alt:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;page-break-after:auto;">6,06</td>
</tr>
</tfoot>
<div class="figdl">
<p class="ListTitle">Key</p>
<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 class="BlockSource">
<p>[SOURCE: <a href="#ISO712">ISO 712, Section 1</a> —
with adjustments]</p>
Expand Down
Loading