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

use a single instance of relaton-render (bibrender variable), so that… #564

Merged
merged 2 commits into from
Mar 6, 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
11 changes: 7 additions & 4 deletions lib/isodoc/convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
module IsoDoc
class Convert < ::IsoDoc::Common
attr_accessor :options, :i18n, :meta, :xrefs, :reqt_models,
:requirements_processor, :doctype
:requirements_processor, :doctype, :bibrender

# htmlstylesheet: Generic stylesheet for HTML
# htmlstylesheet_override: Override stylesheet for HTML
Expand Down Expand Up @@ -86,7 +86,7 @@ def requirements_processor

def bibrenderer(options = {})
::Relaton::Render::IsoDoc::General.new(options.merge(language: @lang,
i18nhash: @i18n.get))
i18nhash: @i18n.get))
end

def convert1(docxml, filename, dir)
Expand All @@ -108,7 +108,8 @@ def convert_init(file, input_filename, debug)
docxml.root.default_namespace = ""
convert_i18n_init(docxml)
metadata_init(@lang, @script, @locale, @i18n)
xref_init(@lang, @script, self, @i18n, { locale: @locale })
xref_init(@lang, @script, self, @i18n,
{ locale: @locale, bibrender: @bibrender })
docxml = preprocess_xslt(docxml)
toc_init(docxml)
[docxml, filename, dir]
Expand All @@ -121,7 +122,8 @@ def preprocess_xslt(docxml)
end
docxml
rescue ::Error => e
require "debug"; binding.b
require "debug"
binding.b
end

def extract_preprocess_xslt(docxml)
Expand All @@ -136,6 +138,7 @@ def extract_preprocess_xslt(docxml)
def convert_i18n_init(docxml)
convert_i18n_init1(docxml)
i18n_init(@lang, @script, @locale)
@bibrender ||= bibrenderer
@reqt_models = requirements_processor
.new({ default: "default", lang: @lang, script: @script,
locale: @locale, labels: @i18n.get,
Expand Down
14 changes: 12 additions & 2 deletions lib/isodoc/function/references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,18 @@ def std_bibitem_entry(list, bib, _ordinal, biblio)

def pref_ref_code(bib)
bib["suppress_identifier"] == "true" and return nil
@bibrenderer ||= bibrenderer
data, = @bibrenderer.parse(bib)
ret = bib.xpath(ns("./docidentifier[@scope = 'biblio-tag']"))
ret.empty? or return ret.map(&:text)
ret = pref_ref_code_parse(bib) or return nil
ins = bib.at(ns("./docidentifier[last()]"))
ret.reverse.each do |r|
ins.next = "<docidentifier scope='biblio-tag'>#{docid_l10n(r)}</docidentifier>"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [89/80]

end
ret
end

def pref_ref_code_parse(bib)
data, = @bibrender.parse(bib)
ret = data[:authoritative_identifier] or return nil
ret.empty? and return nil
ret
Expand Down
1 change: 0 additions & 1 deletion lib/isodoc/presentation_function/bibdata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module IsoDoc
class PresentationXMLConvert < ::IsoDoc::Convert
def bibdata(docxml)
docid_prefixes(docxml)
a = bibdata_current(docxml) or return
address_precompose(a)
bibdata_i18n(a)
Expand Down
4 changes: 2 additions & 2 deletions lib/isodoc/presentation_function/refs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def references_render(docxml)
prep_for_rendering(b)
m << to_xml(b)
end.join
@xrefs.klass.bibrenderer.render_all("<references>#{refs}</references>",
type: citestyle)
@bibrender.render_all("<references>#{refs}</references>",
type: citestyle)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the arguments of a method call if they span more than one line.

end

def prep_for_rendering(bib)
Expand Down
1 change: 1 addition & 0 deletions lib/isodoc/presentation_xml_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def initialize(options)
end

def convert1(docxml, _filename, _dir)
docid_prefixes(docxml) # feeds @xrefs.parse citation processing
@xrefs.parse docxml
bibitem_lookup(docxml)
info docxml, nil
Expand Down
1 change: 1 addition & 0 deletions lib/isodoc/xref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def initialize(lang, script, klass, i18n, options = {})
@i18n = i18n
@labels = @i18n.get
@klass.i18n = @i18n
@klass.bibrender ||= options[:bibrender]
@locale = options[:locale]
@reqt_models = @klass.requirements_processor
.new({
Expand Down
11 changes: 8 additions & 3 deletions spec/isodoc/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@
</foreword></preface>
<bibliography><references id="_bibliography" obligation="informative" normative="false" displayorder="3">
<title>Bibliography</title>
<bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type="IETF">RFC 2616</docidentifier> <docidentifier type="IETF" scope="anchor">RFC2616</docidentifier> <docidentifier type="DOI">10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
<bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <docidentifier type="IETF">RFC 2616</docidentifier> <docidentifier type="IETF" scope="anchor">RFC2616</docidentifier> <docidentifier type="DOI">10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
</references></bibliography>
</iso-standard>
INPUT
Expand Down Expand Up @@ -807,7 +807,12 @@
</foreword></preface>
<bibliography><references id="_" obligation="informative" normative="false" displayorder="3">
<title depth="1">Bibliography</title>
<bibitem id="rfc2616" type="standard"><formattedref>R. FIELDING, J. GETTYS, J. MOGUL, H. FRYSTYK, L. MASINTER, P. LEACH and T. BERNERS-LEE. <em>Hypertext Transfer Protocol&#x2009;&#x2014;&#x2009;HTTP/1.1</em>. In: RFC. 1999. Fremont, CA. <link target="https://www.rfc-editor.org/info/rfc2616">https://www.rfc-editor.org/info/rfc2616</link>.</formattedref><uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri><uri type="src">https://www.rfc-editor.org/info/rfc2616</uri><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>
<bibitem id="rfc2616" type="standard"><formattedref>R. FIELDING, J. GETTYS, J. MOGUL, H. FRYSTYK, L. MASINTER, P. LEACH and T. BERNERS-LEE. <em>Hypertext Transfer Protocol&#x2009;&#x2014;&#x2009;HTTP/1.1</em>. In: RFC. 1999. Fremont, CA.</formattedref>
<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 scope="biblio-tag">IETF RFC 2616</docidentifier>
<biblio-tag>[1]<tab/>IETF&#xa0;RFC&#xa0;2616, </biblio-tag>
</bibitem>
</references></bibliography>
Expand Down Expand Up @@ -848,7 +853,7 @@
<br/>
<div>
<h1 class='Section3'>Bibliography</h1>
<p id="rfc2616" class="Biblio">[1]  IETF&#xa0;RFC&#xa0;2616, R. FIELDING, J. GETTYS, J. MOGUL, H. FRYSTYK, L. MASINTER, P. LEACH and T. BERNERS-LEE. <i>Hypertext Transfer Protocol — HTTP/1.1</i>. In: RFC. 1999. Fremont, CA. <a href="https://www.rfc-editor.org/info/rfc2616">https://www.rfc-editor.org/info/rfc2616</a>.</p>
<p id="rfc2616" class="Biblio">[1]  IETF&#xa0;RFC&#xa0;2616, R. FIELDING, J. GETTYS, J. MOGUL, H. FRYSTYK, L. MASINTER, P. LEACH and T. BERNERS-LEE. <i>Hypertext Transfer Protocol — HTTP/1.1</i>. In: RFC. 1999. Fremont, CA.</p>
</div>
</div>
</body>
Expand Down
Loading
Loading