Skip to content

Commit

Permalink
remove index terms from repeating footnotes: metanorma/bipm-si-brochu…
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Dec 17, 2024
1 parent be9a024 commit 0f8c5ab
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
22 changes: 11 additions & 11 deletions lib/metanorma/standoc/cleanup_footnotes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@ def figure_footnote_cleanup(xmldoc)
end
end

def table_footnote_renumber1(fnote, idx, seen)
def duplicate_footnote(fnote, idx, seen)
content = footnote_content(fnote)
if seen[content] then outnum = seen[content]
if seen[content]
outnum = seen[content]
fnote.xpath(".//index | .//bookmark").each(&:remove)
else
idx += 1
outnum = idx
seen[content] = outnum
end
[fnote, idx, seen, outnum]
end

def table_footnote_renumber1(fnote, idx, seen)
fnote, idx, seen, outnum = duplicate_footnote(fnote, idx, seen)
fnote["reference"] = table_footnote_number(outnum)
fnote["table"] = true
[idx, seen]
Expand All @@ -62,15 +69,8 @@ def table_footnote_renumber(xmldoc)
end

def other_footnote_renumber1(fnote, idx, seen)
return [idx, seen] if fnote["table"]

content = footnote_content(fnote)
if seen[content] then outnum = seen[content]
else
idx += 1
outnum = idx
seen[content] = outnum
end
fnote["table"] and return [idx, seen]
fnote, idx, seen, outnum = duplicate_footnote(fnote, idx, seen)
fnote["reference"] = outnum.to_s
[idx, seen]
end
Expand Down
2 changes: 1 addition & 1 deletion metanorma-standoc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "asciimath2unitsml", "~> 0.4.0"
spec.add_dependency "concurrent-ruby"
spec.add_dependency "pngcheck"
spec.add_dependency "relaton-cli", "~> 1.19.0"
spec.add_dependency "relaton-cli", "~> 1.20.0"
spec.add_dependency "relaton-iev", "~> 1.2.0"
spec.add_dependency "unicode2latex", "~> 0.0.1"

Expand Down
48 changes: 29 additions & 19 deletions spec/metanorma/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@
== Title footnote:[Footnote text 2]
Hello.footnote:abc[This is a repeated footnote]
Hello.footnote:abc[This is a repeated footnote (((a)))]
Repetition.footnote:abc[]
INPUT
Expand All @@ -1020,25 +1020,35 @@
<p id="_">Hello!<fn reference="1">
<p id="_">Footnote text</p>
</fn></p>
</foreword></preface><sections>
</foreword></preface>
<sections>
<clause id="_title_footnote_text_2" inline-header="false" obligation="normative">
<title>Title<fn reference="2">
<p id="_">Footnote text 2</p>
</fn></title>
<p id='_'>
Hello.
<fn reference='3'>
<p id='_'>This is a repeated footnote</p>
</fn>
</p>
<p id='_'>
Repetition.
<fn reference='3'>
<p id='_'>This is a repeated footnote</p>
</fn>
</p>
</clause></sections>
</standard-document>
<title>
Title
<fn reference="2">
<p id="_">Footnote text 2</p>
</fn>
</title>
<p id="_">
Hello.
<fn reference="3">
<p id="_">
This is a repeated footnote
<index>
<primary>a</primary>
</index>
</p>
</fn>
</p>
<p id="_">
Repetition.
<fn reference="3">
<p id="_">This is a repeated footnote </p>
</fn>
</p>
</clause>
</sections>
</standard-document>
OUTPUT
expect(Xml::C14n.format(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to Xml::C14n.format(output)
Expand Down
8 changes: 6 additions & 2 deletions spec/metanorma/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
| Husked rice, parboiled | 1,0 | 1,0 | Not applicable | 1,0
| Milled rice, parboiled | 1,0 | 1,0 | 1,0 | Not applicable
| Chips | 0,1 | 0,1 | 0,1 | 0,1
| HDK | 2,0 footnote:defectsmass[The maximum permissible mass fraction of defects shall be determined with respect to the mass fraction obtained after milling.] | 2,0 | 2,0 footnote:defectsmass[] | 2,0
| HDK | 2,0 footnote:defectsmass[The maximum permissible mass fraction of ((defects)) shall be determined with respect to the mass fraction obtained after milling.] | 2,0 | 2,0 footnote:defectsmass[] | 2,0
| Damaged kernels | 4,0 | 3,0 | 4,0 | 3,0
| Immature and/or malformed kernels | 8,0 | 2,0 | 8,0 | 2,0
| Chalky kernels | 5,0 footnote:defectsmass[] | 5,0 | Not applicable | Not applicable
Expand Down Expand Up @@ -391,7 +391,11 @@
<tr>
<td valign="middle" align="left">HDK</td>
<td valign="top" align="center">2,0<fn reference="c">
<p id="_">The maximum permissible mass fraction of defects shall be determined with respect to the mass fraction obtained after milling.</p>
<p id="_">The maximum permissible mass fraction of defects
<index>
<primary>defects</primary>
</index>
shall be determined with respect to the mass fraction obtained after milling.</p>
</fn></td>
<td valign="bottom" align="center">2,0</td>
<td valign="top" align="center">2,0<fn reference="c">
Expand Down

0 comments on commit 0f8c5ab

Please sign in to comment.