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 1 commit
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
Loading