Class: Metanorma::Plugin::Glossarist::BibliographyRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/plugin/glossarist/bibliography_renderer.rb

Constant Summary collapse

IEV_ENTRY =
"* [[[ievtermbank,IEV]]], _IEV: Electropedia_"
IEV_ANCHOR =
"ievtermbank"

Instance Method Summary collapse

Constructor Details

#initialize(existing_anchors: [], bibliography_data: {}) ⇒ BibliographyRenderer

Returns a new instance of BibliographyRenderer.



12
13
14
15
16
# File 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb', line 12

def initialize(existing_anchors: [], bibliography_data: {})
  @rendered = {}
  @existing_anchors = Set.new(existing_anchors)
  @bibliography_data = bibliography_data
end

Instance Method Details

#render_all(concepts, lang: "eng") ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb', line 27

def render_all(concepts, lang: "eng")
  all_entries = concepts.filter_map do |concept|
    l10n = concept.localization(lang)
    next unless l10n

    source_entries(l10n)
  end.flatten

  xref_entries = concepts.filter_map do |concept|
    l10n = concept.localization(lang)
    next unless l10n

    xref_entries(l10n)
  end.flatten

  all_entries.concat(xref_entries)

  all_entries.sort.join("\n")
end

#render_entry(concept, lang: "eng") ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/metanorma/plugin/glossarist/bibliography_renderer.rb', line 18

def render_entry(concept, lang: "eng")
  l10n = concept.localization(lang)
  return nil unless l10n

  entries = source_entries(l10n)
  entries.concat(xref_entries(l10n))
  entries.empty? ? nil : entries.sort.join("\n")
end