Module: IsoDoc::Iso::Init
- Included in:
- HtmlConvert, PresentationXMLConvert, WordConvert
- Defined in:
- lib/isodoc/iso/init.rb
Instance Method Summary collapse
- #amd?(docxml) ⇒ Boolean
- #clausedelim ⇒ Object
- #i18n_init(lang, script, locale, i18nyaml = nil) ⇒ Object
- #metadata_init(lang, script, locale, i18n) ⇒ Object
- #requirements_processor ⇒ Object
- #std_docid_semantic(id) ⇒ Object
- #std_docid_semantic1(id) ⇒ Object
- #std_docid_semantic_full(ident) ⇒ Object
- #xref_init(lang, script, _klass, i18n, options) ⇒ Object
Instance Method Details
#amd?(docxml) ⇒ Boolean
23 24 25 |
# File 'lib/isodoc/iso/init.rb', line 23 def amd?(docxml) %w(amendment technical-corrigendum).include? @doctype end |
#clausedelim ⇒ Object
27 28 29 |
# File 'lib/isodoc/iso/init.rb', line 27 def clausedelim "" end |
#i18n_init(lang, script, locale, i18nyaml = nil) ⇒ Object
18 19 20 21 |
# File 'lib/isodoc/iso/init.rb', line 18 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/iso/init.rb', line 9 def (lang, script, locale, i18n) @meta = Metadata.new(lang, script, locale, i18n) end |
#requirements_processor ⇒ Object
31 32 33 |
# File 'lib/isodoc/iso/init.rb', line 31 def requirements_processor ::Metanorma::Requirements::Iso end |
#std_docid_semantic(id) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/isodoc/iso/init.rb', line 35 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
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/isodoc/iso/init.rb', line 45 def std_docid_semantic1(id) ids = id.split(/(\p{Zs})/) agency?(ids[0].sub(/\/.*$/, "")) or return id ids.map! do |i| if %w(GUIDE TR TS DIR).include?(i) "<span class='stddocNumber'>#{i}</span>" elsif /\p{Zs}/.match?(i) then i else std_docid_semantic_full(i) end end.join.gsub(%r{</span>(\p{Zs}+)<}, "\\1</span><") end |
#std_docid_semantic_full(ident) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/isodoc/iso/init.rb', line 57 def std_docid_semantic_full(ident) ident .sub(/^([^0-9]+)(\p{Zs}|$)/, "<span class='stdpublisher'>\\1</span>\\2") .sub(/([0-9]+)/, "<span class='stddocNumber'>\\1</span>") .sub(/-([0-9]+)/, "-<span class='stddocPartNumber'>\\1</span>") .sub(/:([0-9]{4})(?!\d)/, ":<span class='stdyear'>\\1</span>") end |
#xref_init(lang, script, _klass, i18n, options) ⇒ Object
13 14 15 16 |
# File 'lib/isodoc/iso/init.rb', line 13 def xref_init(lang, script, _klass, i18n, ) html = HtmlConvert.new(language: lang, script: script) @xrefs = Xref.new(lang, script, html, i18n, ) end |