Skip to content

Commit

Permalink
Merge pull request #948 from metanorma/fix/fn-index-dup
Browse files Browse the repository at this point in the history
remove index terms from repeating footnotes: https://github.com/metan…
  • Loading branch information
opoudjis authored Dec 18, 2024
2 parents be9a024 + e8c7d9b commit f7cb56e
Show file tree
Hide file tree
Showing 29 changed files with 1,557 additions and 1,367 deletions.
2 changes: 2 additions & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gem "relaton-render", git: "https://github.com/relaton/relaton-render", branch: "main"
gem "isodoc", git: "https://github.com/metanorma/isodoc", branch: "fix/relaton-render-0.9"
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
7 changes: 5 additions & 2 deletions lib/metanorma/standoc/merge_bibitems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ def merge_extent(old, new)
new[:extent] = [{ locality_stack: new[:extent] }]
ret = merge_by_type(old.dig(:extent, 0),
new.dig(:extent, 0), :locality_stack,
%i[locality type])
(ret && !old.dig(:extent, 0)) or return
[:locality, 0, :type])
ret = ret.each_with_object([{ locality: [] }]) do |r, m|
m[0][:locality] += r[:locality]
end
ret or return
old[:extent] ||= []
old[:extent][0] ||= {}
old[:extent][0][:locality_stack] = ret
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
3 changes: 3 additions & 0 deletions spec/metanorma/biblio_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@
<name>World Wide Web Consortium</name>
</organization>
</contributor>
<extent/>
<docidentifier>ISOTC211</docidentifier>
</bibitem>
</references>
Expand Down Expand Up @@ -1303,6 +1304,7 @@
<name>World Wide Web Consortium</name>
</organization>
</contributor>
<extent/>
<docidentifier>ISOTC211</docidentifier>
</bibitem>
<bibitem id="B" type="techreport">
Expand Down Expand Up @@ -1342,6 +1344,7 @@
</organization>
</contributor>
<edition>Edition 1</edition>
<extent/>
<docidentifier>ISOTC211t</docidentifier>
</bibitem>
</references>
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
4 changes: 0 additions & 4 deletions spec/metanorma/refs_fetch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -767,14 +767,12 @@
<title format="text/plain">D-Lib Magazine</title>
</series>
<extent>
<localityStack>
<locality type="volume">
<referenceFrom>16</referenceFrom>
</locality>
<locality type="issue">
<referenceFrom>11/12</referenceFrom>
</locality>
</localityStack>
</extent>
</bibitem>
</references>
Expand Down Expand Up @@ -878,12 +876,10 @@
</bibitem>
</relation>
<extent>
<localityStack>
<locality type="page">
<referenceFrom>257</referenceFrom>
<referenceTo>282</referenceTo>
</locality>
</localityStack>
</extent>
</bibitem>
<bibitem id="ref2" type="book">
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
103 changes: 92 additions & 11 deletions spec/vcr_cassettes/bipm.yml

Large diffs are not rendered by default.

Loading

0 comments on commit f7cb56e

Please sign in to comment.