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

remove index terms from repeating footnotes: https://github.com/metan… #948

Merged
merged 2 commits into from
Dec 18, 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
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
Loading