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

always put nbsp in docids for PDF xref consistency: https://github.co… #621

Merged
merged 1 commit into from
Dec 8, 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/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,14 @@ def agency?(text)
self.class::AGENCIES.include?(text)
end

# This is highly specific to ISO, but it's not a bad precedent for
# references anyway; keeping here instead of in IsoDoc::Iso for now
def docid_l10n(text)
text.nil? and return text
@i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase)
text.size < 20 and text.gsub!(/ /, "&#xa0;")
text
x = Nokogiri::XML::DocumentFragment.parse(text)
(x.xpath(".//text()") - x.xpath(".//fn//text()")).each do |n|
n.replace(n.text.gsub(/ /, "&#xa0;"))
end
to_xml(x)
end

def docid_prefix(prefix, docid)
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc/presentation_function/inline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_linkend(node)
node["style"] == "id" and anchor_id_postprocess(node)
xref_empty?(node) or return
target = docid_l10n(node["target"]) ||
expand_citeas(docid_l10n(node["citeas"]))
docid_l10n(expand_citeas(node["citeas"]))
link = anchor_linkend(node, target)
link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
link, node)
Expand Down
2 changes: 1 addition & 1 deletion spec/isodoc/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@
<docidentifier type="metanorma-ordinal">[1]</docidentifier>
<docidentifier type="IETF">IETF&#xa0;RFC&#xa0;2616</docidentifier>
<docidentifier type="IETF" scope="anchor">IETF&#xa0;RFC2616</docidentifier>
<docidentifier type="DOI">DOI 10.17487/RFC2616</docidentifier>
<docidentifier type="DOI">DOI&#xa0;10.17487/RFC2616</docidentifier>
<docidentifier scope="biblio-tag">IETF RFC 2616</docidentifier>
<biblio-tag>[1]<tab/>IETF&#xa0;RFC&#xa0;2616, </biblio-tag>
</bibitem>
Expand Down
13 changes: 9 additions & 4 deletions spec/isodoc/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,19 @@
<references id="R" obligation="informative" normative="true" displayorder="5">
<title depth="1">2.<tab/>Normative References</title>
<bibitem id="ISO712" type="standard">
<formattedref><em>Cereals and cereal products</em></formattedref>
<formattedref><em>Cereals and cereal products</em>.</formattedref>
<docidentifier>ISO&#xa0;712</docidentifier>
<docidentifier scope="biblio-tag">ISO 712</docidentifier>
<biblio-tag>ISO&#xa0;712,</biblio-tag>
</bibitem>
</references>
</sections><annex id="P" inline-header="false" obligation="normative" displayorder="9">
<title><strong>&#x9644;&#x4EF6;A</strong><br/>&#xFF08;&#x89C4;&#x8303;&#x6027;&#x9644;&#x5F55;&#xFF09;<br/><br/><strong>Annex</strong></title>
<title>
<strong>附件 A</strong><br/>(规范性附录)
<br/>
<br/>
<strong>Annex</strong>
</title>
<clause id="Q" inline-header="false" obligation="normative">
<title depth="2">A.1.<tab/>Annex A.1</title>
<clause id="Q1" inline-header="false" obligation="normative">
Expand Down Expand Up @@ -811,7 +816,7 @@
</div>
<div><h1>2. Normative References</h1>

<p id="ISO712" class="NormRef">ISO&#xa0;712, <i>Cereals and cereal products</i></p>
<p id="ISO712" class="NormRef">ISO&#xa0;712, <i>Cereals and cereal products</i>.</p>
</div>
<div id="H">
<h1>3. Terms, definitions, symbols and abbreviated terms</h1>
Expand Down Expand Up @@ -849,7 +854,7 @@
</div>
<br/>
<div id="P" class="Section3">
<h1 class="Annex"><b>附件A</b><br/>规范性附录)<br/><br/><b>Annex</b></h1>
<h1 class="Annex"><b>附件 A</b><br/>(规范性附录)<br/><br/><b>Annex</b></h1>
<div id="Q"><h2>A.1. Annex A.1</h2>

<div id="Q1"><h3>A.1.1. Annex A.1a</h3>
Expand Down
2 changes: 1 addition & 1 deletion spec/isodoc/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@
presxml = <<~OUTPUT
<foreword displayorder='2'><title>Foreword</title>
<p>
<xref type="inline" target='ISO712'>BSI BS EN ISO 19011:2018&#x2009;&#x2014;&#x2009;TC</link>
<xref type="inline" target='ISO712'>BSI&#xa0;BS&#xa0;EN&#xa0;ISO&#xa0;19011:2018&#x2009;&#x2014;&#x2009;TC</link>
</p>
</foreword>
OUTPUT
Expand Down
4 changes: 2 additions & 2 deletions spec/isodoc/presentation_xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1017,10 +1017,10 @@
<foreword displayorder="2">
<title>Section</title>
<p id="A"><xref target="ref1">箇条1</xref>~<xref target="ref2">箇条2</xref><xref target="ref1"><location target="ref1" connective="from"/><location target="ref2" connective="to"/>text</xref><xref target="ref1">箇条1</xref> and <xref target="ref2">箇条2</xref>
<xref target="ref1">箇条1</xref><xref target="ref2">箇条2</xref>, and <xref target="ref3">箇条3</xref>
<xref target="ref1">箇条1</xref>, <xref target="ref2">箇条2</xref>, and <xref target="ref3">箇条3</xref>
<xref target="ref1"><location target="ref1" connective="and"/><location target="ref2" connective="and"/>text</xref>
<xref target="ref1">箇条1</xref> or <xref target="ref2">箇条2</xref>
<xref target="ref1">箇条1</xref><xref target="ref2">箇条2</xref>, or <xref target="ref3">箇条3</xref>
<xref target="ref1">箇条1</xref>, <xref target="ref2">箇条2</xref>, or <xref target="ref3">箇条3</xref>
<xref target="ref1">箇条1</xref>~<xref target="ref2">箇条2</xref> and <xref target="ref3">箇条3</xref>~<xref target="ref4">箇条4</xref>
<xref target="item_6-4-a">箇条5のa)の1)</xref>~<xref target="item_6-4-i">箇条5のb)の1)</xref>
</p>
Expand Down
40 changes: 20 additions & 20 deletions spec/isodoc/ref_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<xref target='ISO712'>[110]</xref>
<xref target='ISBN'>[1]</xref>
<xref target='ISSN'>[2]</xref>
<xref target='ISO16634'>ISO 16634:-- (all parts)</xref>
<xref target='ISO16634'>ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</xref>
<xref target='ref1'>ICC/167</xref>
<xref target='ref10'>[4]</xref>
<xref target='ref12'>Citn</xref>
Expand All @@ -170,10 +170,10 @@
</bibitem>
<bibitem id='ISO16634' type='standard'>
<formattedref><em>Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</em>.</formattedref>
<docidentifier type='ISO'>ISO 16634:-- (all parts)</docidentifier>
<docidentifier scope="biblio-tag">ISO 16634:-- (all parts)</docidentifier>
<docidentifier type='ISO'>ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</docidentifier>
<docidentifier scope="biblio-tag">ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</docidentifier>
<note format='text/plain' type='Unpublished-Status' reference='1'>Under preparation. (Stage at the time of publication ISO/DIS 16634)</note>
<biblio-tag>ISO 16634:-- (all parts)<fn reference="_"><p>Under preparation. (Stage at the time of publication ISO/DIS 16634)</p></fn>, </biblio-tag>
<biblio-tag>ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)<fn reference="_"><p>Under preparation. (Stage at the time of publication ISO/DIS 16634)</p></fn>, </biblio-tag>
</bibitem>
<bibitem id='ISO20483' type='standard'>
<formattedref>International Organization for Standardization. <em>Cereals and pulses</em>. 2013&#x2013;2014.</formattedref>
Expand Down Expand Up @@ -306,7 +306,7 @@
<a href="#ISO712">[110]</a>
<a href="#ISBN">[1]</a>
<a href="#ISSN">[2]</a>
<a href="#ISO16634">ISO 16634:-- (all parts)</a>
<a href="#ISO16634">ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</a>
<a href="#ref1">ICC/167</a>
<a href="#ref10">[4]</a>
<a href="#ref12">Citn</a>
Expand All @@ -323,7 +323,7 @@
amendments) applies.
</p>
<p id="ISO712" class="NormRef">[110], ISO&#xa0;712, International Organization for Standardization. <i>Cereals and cereal products</i>.</p>
<p id="ISO16634" class="NormRef">ISO 16634:-- (all parts)<a class="FootnoteRef" href="#fn:_"><sup>_</sup></a>, <i>Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</i>.</p>
<p id="ISO16634" class="NormRef">ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)<a class="FootnoteRef" href="#fn:_"><sup>_</sup></a>, <i>Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</i>.</p>
<p id="ISO20483" class="NormRef">ISO&#xa0;20483:2013-2014, International Organization for Standardization. <i>Cereals and pulses</i>. 2013–2014.</p>
<p id="ref1" class="NormRef">ICC/167,
<span style="font-variant:small-caps;">Standard No I.C.C 167</span>
Expand Down Expand Up @@ -396,7 +396,7 @@
<a href="#ISO712">[110]</a>
<a href="#ISBN">[1]</a>
<a href="#ISSN">[2]</a>
<a href="#ISO16634">ISO 16634:-- (all parts)</a>
<a href="#ISO16634">ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</a>
<a href="#ref1">ICC/167</a>
<a href="#ref10">[4]</a>
<a href="#ref12">Citn</a>
Expand All @@ -419,7 +419,7 @@
amendments) applies.
</p>
<p class="NormRef"><a name="ISO712" id="ISO712"/>[110], ISO&#xa0;712, International Organization for Standardization. <i>Cereals and cereal products</i>.</p>
<p class="NormRef"><a name="ISO16634" id="ISO16634"/>ISO 16634:-- (all parts)<span style="mso-bookmark:_Ref"><a class="FootnoteRef" href="#_ftn1" type="footnote" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"/></span></a></span>, <i>Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</i>.</p>
<p class="NormRef"><a name="ISO16634" id="ISO16634"/>ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)<span style="mso-bookmark:_Ref"><a class="FootnoteRef" href="#_ftn1" type="footnote" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"/></span></a></span>, <i>Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</i>.</p>
<p class="NormRef"><a name="ISO20483" id="ISO20483"/>ISO&#xa0;20483:2013-2014, International Organization for Standardization. <i>Cereals and pulses</i>. 2013–2014.</p>
<p class="NormRef"><a name="ref1" id="ref1"/>ICC/167,
<span style="font-variant:small-caps;">Standard No I.C.C 167</span>
Expand Down Expand Up @@ -773,10 +773,10 @@
</bibitem>
<bibitem id="ISO16634" type="standard">
<formattedref><em>Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</em>.</formattedref>
<docidentifier type="ISO">ISO 16634:-- (all parts)</docidentifier>
<docidentifier scope="biblio-tag">ISO 16634:-- (all parts)</docidentifier>
<docidentifier type="ISO">ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</docidentifier>
<docidentifier scope="biblio-tag">ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</docidentifier>
<note format="text/plain" type="Unpublished-Status" reference="1">Under preparation. (Stage at the time of publication ISO/DIS 16634)</note>
<biblio-tag>ISO 16634:-- (all parts)<fn reference="_"><p>Under preparation. (Stage at the time of publication ISO/DIS 16634)</p></fn>, </biblio-tag>
<biblio-tag>ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)<fn reference="_"><p>Under preparation. (Stage at the time of publication ISO/DIS 16634)</p></fn>, </biblio-tag>
</bibitem>
<bibitem id="ISO20483" type="standard">
<formattedref>International Organization for Standardization. <em>Cereals and pulses</em>. 2013–2014.</formattedref>
Expand Down Expand Up @@ -972,8 +972,8 @@
<formattedref language="en" format="text/plain">
<em>Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</em>
</formattedref>
<docidentifier type="ISO">ISO 16634:-- (all parts)</docidentifier>
<docidentifier scope="biblio-tag">ISO 16634:-- (all parts)</docidentifier>
<docidentifier type="ISO">ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</docidentifier>
<docidentifier scope="biblio-tag">ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)</docidentifier>
<date type="published">
<on>--</on>
</date>
Expand All @@ -987,7 +987,7 @@
<extent type="part">
<referenceFrom>all</referenceFrom>
</extent>
<biblio-tag>ISO 16634:-- (all parts)<fn reference="_"><p>Under preparation. (Stage at the time of publication ISO/DIS 16634)</p></fn>, </biblio-tag>
<biblio-tag>ISO&#xa0;16634:--&#xa0;(all&#xa0;parts)<fn reference="_"><p>Under preparation. (Stage at the time of publication ISO/DIS 16634)</p></fn>, </biblio-tag>
</bibitem>
</references>
</sections>
Expand Down Expand Up @@ -1072,7 +1072,7 @@
presxml = <<~PRESXML
<foreword displayorder='2'><title>Foreword</title>
<p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
<xref target='ISO712'>ISO&#xa0;712&#xA0;/ IEC&#xa0;217</xref>
<xref target='ISO712'>ISO&#xa0;712&#xA0;/&#xa0;IEC&#xa0;217</xref>
</p>
</foreword>
PRESXML
Expand Down Expand Up @@ -1388,10 +1388,10 @@
<uri type="obp">https://www.iso.org/obp/ui/#!iso:std:45324:en</uri>
<uri type="rss">https://www.iso.org/contents/data/standard/04/53/45324.detail.rss</uri>
<uri type="pub">https://isotc.iso.org/livelink/livelink/Open/8389141</uri>
<docidentifier type="ISO" primary="true">ISO/IEC Guide 99:2007</docidentifier>
<docidentifier type="metanorma">[ISO/IEC Guide 99:2007]</docidentifier>
<docidentifier type="URN">URN urn:iso:std:iso-iec:guide:99:ed-1</docidentifier>
<biblio-tag>ISO/IEC Guide 99:2007<fn reference="1"><p id="_">Also known as JCGM 200</p></fn> </biblio-tag>
<docidentifier type="ISO" primary="true">ISO/IEC&#xa0;Guide&#xa0;99:2007</docidentifier>
<docidentifier type="metanorma">[ISO/IEC&#xa0;Guide&#xa0;99:2007]</docidentifier>
<docidentifier type="URN">URN&#xa0;urn:iso:std:iso-iec:guide:99:ed-1</docidentifier>
<biblio-tag>ISO/IEC&#xa0;Guide&#xa0;99:2007<fn reference="1"><p id="_">Also known as JCGM 200</p></fn> </biblio-tag>
</bibitem>
</references>
PRESXML
Expand All @@ -1400,7 +1400,7 @@
<div>
<h1>1.  Normative References</h1>
<p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
<p id="ISO712" class="NormRef">ISO/IEC Guide 99:2007<a class="FootnoteRef" href="#fn:1"><sup>1</sup></a> International Organization for Standardization and International Electrotechnical Commission. <i>International vocabulary of metrology — Basic and general concepts and associated terms (VIM)</i>. First edition. 2007. <a href="https://www.iso.org/standard/45324.html">https://www.iso.org/standard/45324.html</a>. [viewed: #{Date.today.strftime('%B %-d, %Y')}].</p>
<p id="ISO712" class="NormRef">ISO/IEC&#xa0;Guide&#xa0;99:2007<a class="FootnoteRef" href="#fn:1"><sup>1</sup></a> International Organization for Standardization and International Electrotechnical Commission. <i>International vocabulary of metrology — Basic and general concepts and associated terms (VIM)</i>. First edition. 2007. <a href="https://www.iso.org/standard/45324.html">https://www.iso.org/standard/45324.html</a>. [viewed: #{Date.today.strftime('%B %-d, %Y')}].</p>
</div>
<aside id="fn:1" class="footnote">
<p id="_">Also known as JCGM 200</p>
Expand Down
Loading