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 2 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
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
4 changes: 4 additions & 0 deletions spec/isodoc/lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,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 +515,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
10 changes: 8 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,6 +268,7 @@
<td style="text-align:center;border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">6,06</td>
</tr>
</tfoot>
<p class="ListTitle">Key</p>
<dl>
<dt>
<p>Drago</p>
Expand Down Expand Up @@ -386,7 +389,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