Module: IsoDoc::IEEE::Init

Included in:
HtmlConvert, PresentationXMLConvert, WordConvert
Defined in:
lib/isodoc/ieee/init.rb

Instance Method Summary collapse

Instance Method Details

#bibrendererObject



24
25
26
27
# File 'lib/isodoc/ieee/init.rb', line 24

def bibrenderer
  ::Relaton::Render::IEEE::General.new(language: @lang,
                                       i18nhash: @i18n.get)
end

#fileloc(loc) ⇒ Object



29
30
31
# File 'lib/isodoc/ieee/init.rb', line 29

def fileloc(loc)
  File.join(File.dirname(__FILE__), loc)
end

#i18n_init(lang, script, locale, i18nyaml = nil) ⇒ Object



19
20
21
22
# File 'lib/isodoc/ieee/init.rb', line 19

def i18n_init(lang, script, locale, i18nyaml = nil)
  @i18n = I18n.new(lang, script, locale: locale,
                                 i18nyaml: i18nyaml || @i18nyaml)
end

#metadata_init(lang, script, locale, i18n) ⇒ Object



9
10
11
# File 'lib/isodoc/ieee/init.rb', line 9

def (lang, script, locale, i18n)
  @meta = Metadata.new(lang, script, locale, i18n)
end

#std_docid_sdo(text) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/isodoc/ieee/init.rb', line 61

def std_docid_sdo(text)
  found = false
  text.split(%r{([\p{Zs}|/]+)}).reverse.map do |x|
    if /[A-Za-z]/.match?(x)
      k = if found || agency?(x) then "std_publisher"
          else "std_documentType"
          end
      found = true
      "<span class='#{k}'>#{x}</span>"
    else x end
  end.reverse.join.gsub(%r{</span>(\p{Zs}+)<}, "\\1</span><")
end

#std_docid_semantic(id) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/isodoc/ieee/init.rb', line 33

def std_docid_semantic(id)
  id.nil? and return nil
  ret = Nokogiri::XML.fragment(id)
  ret.traverse do |x|
    x.text? or next
    x.replace(std_docid_semantic1(x.text))
  end
  to_xml(ret)
end

#std_docid_semantic1(id) ⇒ Object



43
44
45
46
47
# File 'lib/isodoc/ieee/init.rb', line 43

def std_docid_semantic1(id)
  ids = id.split(/\p{Zs}/)
  agency?(ids[0].sub(/\/.*$/, "")) or return id
  std_docid_semantic_full(id)
end

#std_docid_semantic_full(ident) ⇒ Object

AGENCY+ TYPE NUMBER YEAR



50
51
52
53
54
55
56
57
58
59
# File 'lib/isodoc/ieee/init.rb', line 50

def std_docid_semantic_full(ident)
  m = ident.match(%r{(?<text>[^0-9]+\p{Zs})
                  (?<num>[0-9]+[^:]*)
                  (?:[:](?<yr>(?:19|20)\d\d))?}x)
  m or return ident
  ret = std_docid_sdo(m[:text]) +
    "<span class='std_docNumber'>#{m[:num]}</span>"
  m[:yr] and ret += ":<span class='std_year'>#{m[:yr]}</span>"
  ret.gsub(%r{</span>(\p{Zs}+)<}, "\\1</span><")
end

#xref_init(lang, script, _klass, i18n, options) ⇒ Object



13
14
15
16
17
# File 'lib/isodoc/ieee/init.rb', line 13

def xref_init(lang, script, _klass, i18n, options)
  html = HtmlConvert.new(language: lang, script: script)
  options = options.merge(hierarchicalassets: @hierarchical_assets)
  @xrefs = Xref.new(lang, script, html, i18n, options)
end