isodoc 2.5.4 → 2.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/isodoc/convert.rb +0 -8
 - data/lib/isodoc/function/inline.rb +2 -32
 - data/lib/isodoc/html_function/html.rb +0 -1
 - data/lib/isodoc/presentation_function/block.rb +1 -1
 - data/lib/isodoc/presentation_function/concepts.rb +90 -0
 - data/lib/isodoc/presentation_function/erefs.rb +49 -0
 - data/lib/isodoc/presentation_function/terms.rb +16 -92
 - data/lib/isodoc/presentation_xml_convert.rb +13 -3
 - data/lib/isodoc/version.rb +1 -1
 - data/lib/isodoc-yaml/i18n-ar.yaml +1 -0
 - data/lib/isodoc-yaml/i18n-de.yaml +2 -1
 - data/lib/isodoc-yaml/i18n-en.yaml +1 -0
 - data/lib/isodoc-yaml/i18n-es.yaml +1 -0
 - data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
 - data/lib/isodoc-yaml/i18n-ja.yaml +2 -1
 - data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
 - data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
 - metadata +7 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d6ca47f20afd4ccef8c44ce28bfca11c4803f9aa8988e950cf1842dc251dc855
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9f2ca8a82bb0528e05f8a6cc631cfad987c0fe8d819937af79580a119955a921
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 10170334bf2d0bbf492237695054a1a164c8c7f056a8cec5d782cd468f4a367524fc9dc841fccf4c3f7c90038af32d83e962d5cf224d66e5f7d05323b1b65083
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9fc62b5c28d0baff4b369f15f8811a6be8b0bd85e1b63db6a9b36017e9a84a276c9df3034c679c0bd11ecbca0d5f7056bd2aa1627873a561be29b67f5619db9a
         
     | 
    
        data/lib/isodoc/convert.rb
    CHANGED
    
    | 
         @@ -85,7 +85,6 @@ module IsoDoc 
     | 
|
| 
       85 
85 
     | 
    
         | 
| 
       86 
86 
     | 
    
         
             
                def convert1(docxml, filename, dir)
         
     | 
| 
       87 
87 
     | 
    
         
             
                  @xrefs.parse docxml
         
     | 
| 
       88 
     | 
    
         
            -
                  bibitem_lookup(docxml)
         
     | 
| 
       89 
88 
     | 
    
         
             
                  noko do |xml|
         
     | 
| 
       90 
89 
     | 
    
         
             
                    xml.html lang: @lang.to_s do |html|
         
     | 
| 
       91 
90 
     | 
    
         
             
                      html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
         
     | 
| 
         @@ -97,13 +96,6 @@ module IsoDoc 
     | 
|
| 
       97 
96 
     | 
    
         
             
                  end.join("\n")
         
     | 
| 
       98 
97 
     | 
    
         
             
                end
         
     | 
| 
       99 
98 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
                def bibitem_lookup(docxml)
         
     | 
| 
       101 
     | 
    
         
            -
                  @bibitems = docxml.xpath(ns("//references/bibitem"))
         
     | 
| 
       102 
     | 
    
         
            -
                    .each_with_object({}) do |b, m|
         
     | 
| 
       103 
     | 
    
         
            -
                    m[b["id"]] = b
         
     | 
| 
       104 
     | 
    
         
            -
                  end
         
     | 
| 
       105 
     | 
    
         
            -
                end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
99 
     | 
    
         
             
                def convert_init(file, input_filename, debug)
         
     | 
| 
       108 
100 
     | 
    
         
             
                  docxml = Nokogiri::XML(file) { |config| config.huge }
         
     | 
| 
       109 
101 
     | 
    
         
             
                  filename, dir = init_file(input_filename, debug)
         
     | 
| 
         @@ -52,45 +52,15 @@ module IsoDoc 
     | 
|
| 
       52 
52 
     | 
    
         
             
                    url.sub(/#{File.extname(url)}$/, ".html")
         
     | 
| 
       53 
53 
     | 
    
         
             
                  end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
                  def eref_target(node)
         
     | 
| 
       56 
     | 
    
         
            -
                    url = suffix_url(eref_url(node["bibitemid"]))
         
     | 
| 
       57 
     | 
    
         
            -
                    anchor = node&.at(ns(".//locality[@type = 'anchor']"))
         
     | 
| 
       58 
     | 
    
         
            -
                    return url if url.nil? || /^#/.match?(url) || !anchor
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                    "#{url}##{anchor.text.strip}"
         
     | 
| 
       61 
     | 
    
         
            -
                  end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                  def eref_url(id)
         
     | 
| 
       64 
     | 
    
         
            -
                    @bibitems.nil? and return nil
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                    b = @bibitems[id]
         
     | 
| 
       67 
     | 
    
         
            -
                    b.nil? and return nil
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                    url = b.at(ns("./uri[@type = 'citation'][@language = '#{@lang}']")) and
         
     | 
| 
       70 
     | 
    
         
            -
                      return url.text
         
     | 
| 
       71 
     | 
    
         
            -
                    url = b.at(ns("./uri[@type = 'citation']")) and return url.text
         
     | 
| 
       72 
     | 
    
         
            -
                    b["hidden"] == "true" and return b.at(ns("./uri"))&.text
         
     | 
| 
       73 
     | 
    
         
            -
                    "##{id}"
         
     | 
| 
       74 
     | 
    
         
            -
                  end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
55 
     | 
    
         
             
                  def eref_parse(node, out)
         
     | 
| 
       77 
     | 
    
         
            -
                     
     | 
| 
       78 
     | 
    
         
            -
                      if node["type"] == "footnote"
         
     | 
| 
       79 
     | 
    
         
            -
                        out.sup do |s|
         
     | 
| 
       80 
     | 
    
         
            -
                          s.a(href: href) { |l| no_locality_parse(node, l) }
         
     | 
| 
       81 
     | 
    
         
            -
                        end
         
     | 
| 
       82 
     | 
    
         
            -
                      else
         
     | 
| 
       83 
     | 
    
         
            -
                        out.a(href: href) { |l| no_locality_parse(node, l) }
         
     | 
| 
       84 
     | 
    
         
            -
                      end
         
     | 
| 
       85 
     | 
    
         
            -
                    else no_locality_parse(node, out)
         
     | 
| 
       86 
     | 
    
         
            -
                    end
         
     | 
| 
      
 56 
     | 
    
         
            +
                    no_locality_parse(node, out)
         
     | 
| 
       87 
57 
     | 
    
         
             
                  end
         
     | 
| 
       88 
58 
     | 
    
         | 
| 
       89 
59 
     | 
    
         
             
                  def origin_parse(node, out)
         
     | 
| 
       90 
60 
     | 
    
         
             
                    if t = node.at(ns("./termref"))
         
     | 
| 
       91 
61 
     | 
    
         
             
                      termrefelem_parse(t, out)
         
     | 
| 
       92 
62 
     | 
    
         
             
                    else
         
     | 
| 
       93 
     | 
    
         
            -
                       
     | 
| 
      
 63 
     | 
    
         
            +
                      no_locality_parse(node, out)
         
     | 
| 
       94 
64 
     | 
    
         
             
                    end
         
     | 
| 
       95 
65 
     | 
    
         
             
                  end
         
     | 
| 
       96 
66 
     | 
    
         | 
| 
         @@ -0,0 +1,90 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module IsoDoc
         
     | 
| 
      
 2 
     | 
    
         
            +
              class PresentationXMLConvert < ::IsoDoc::Convert
         
     | 
| 
      
 3 
     | 
    
         
            +
                def concept(docxml)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  @definition_ids = docxml.xpath(ns("//definitions//dt"))
         
     | 
| 
      
 5 
     | 
    
         
            +
                    .each_with_object({}) { |x, m| m[x["id"]] = true }
         
     | 
| 
      
 6 
     | 
    
         
            +
                  docxml.xpath(ns("//concept")).each { |f| concept1(f) }
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                def concept1(node)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  xref = node&.at(ns("./xref/@target"))&.text or
         
     | 
| 
      
 11 
     | 
    
         
            +
                    return concept_render(node, ital: "true", ref: "true", bold: "false",
         
     | 
| 
      
 12 
     | 
    
         
            +
                                                linkref: "true", linkmention: "false")
         
     | 
| 
      
 13 
     | 
    
         
            +
                  if @definition_ids[xref]
         
     | 
| 
      
 14 
     | 
    
         
            +
                    concept_render(node, ital: "false", ref: "false", bold: "false",
         
     | 
| 
      
 15 
     | 
    
         
            +
                                         linkref: "true", linkmention: "false")
         
     | 
| 
      
 16 
     | 
    
         
            +
                  else concept_render(node, ital: "true", ref: "true", bold: "false",
         
     | 
| 
      
 17 
     | 
    
         
            +
                                            linkref: "true", linkmention: "false")
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def concept_render(node, defaults)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  opts, render, ref = concept_render_init(node, defaults)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  node&.at(ns("./refterm"))&.remove
         
     | 
| 
      
 24 
     | 
    
         
            +
                  ref && opts[:ref] != "false" and render&.next = " "
         
     | 
| 
      
 25 
     | 
    
         
            +
                  concept1_linkmention(ref, render, opts)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  concept1_ref(node, ref, opts)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  concept1_style(node, opts)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  node.replace(node.children)
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def concept1_style(node, opts)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  r = node.at(ns(".//renderterm")) or return
         
     | 
| 
      
 33 
     | 
    
         
            +
                  opts[:ital] == "true" and r.children = "<em>#{to_xml(r.children)}</em>"
         
     | 
| 
      
 34 
     | 
    
         
            +
                  opts[:bold] == "true" and
         
     | 
| 
      
 35 
     | 
    
         
            +
                    r.children = "<strong>#{to_xml(r.children)}</strong>"
         
     | 
| 
      
 36 
     | 
    
         
            +
                  r.replace(r.children)
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                def concept_render_init(node, defaults)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  opts = %i(bold ital ref linkref linkmention)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    .each_with_object({}) { |x, m| m[x] = node[x.to_s] || defaults[x] }
         
     | 
| 
      
 42 
     | 
    
         
            +
                  [opts, node.at(ns("./renderterm")),
         
     | 
| 
      
 43 
     | 
    
         
            +
                   node.at(ns("./xref | ./eref | ./termref"))]
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                def concept1_linkmention(ref, renderterm, opts)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  (opts[:linkmention] == "true" && !renderterm.nil? && !ref.nil?) or return
         
     | 
| 
      
 48 
     | 
    
         
            +
                  ref2 = ref.clone
         
     | 
| 
      
 49 
     | 
    
         
            +
                  r2 = renderterm.clone
         
     | 
| 
      
 50 
     | 
    
         
            +
                  renderterm.replace(ref2).children = r2
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                def concept1_ref(_node, ref, opts)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  ref.nil? and return
         
     | 
| 
      
 55 
     | 
    
         
            +
                  opts[:ref] == "false" and return ref.remove
         
     | 
| 
      
 56 
     | 
    
         
            +
                  concept1_ref_content(ref)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  %w(xref eref).include? ref.name and get_linkend(ref)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  opts[:linkref] == "false" && %w(xref eref).include?(ref.name) and
         
     | 
| 
      
 59 
     | 
    
         
            +
                    ref.replace(ref.children)
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                def concept1_ref_content(ref)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  prev = "["
         
     | 
| 
      
 64 
     | 
    
         
            +
                  foll = "]"
         
     | 
| 
      
 65 
     | 
    
         
            +
                  non_locality_elems(ref).select do |c|
         
     | 
| 
      
 66 
     | 
    
         
            +
                    !c.text? || /\S/.match(c)
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end.empty? and
         
     | 
| 
      
 68 
     | 
    
         
            +
                    (prev, foll = @i18n.term_defined_in.split("%"))
         
     | 
| 
      
 69 
     | 
    
         
            +
                  ref.previous = prev
         
     | 
| 
      
 70 
     | 
    
         
            +
                  ref.next = foll
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                def related(docxml)
         
     | 
| 
      
 74 
     | 
    
         
            +
                  docxml.xpath(ns("//related")).each { |f| related1(f) }
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                def related1(node)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  p = node.at(ns("./preferred"))
         
     | 
| 
      
 79 
     | 
    
         
            +
                  ref = node.at(ns("./xref | ./eref | ./termref"))
         
     | 
| 
      
 80 
     | 
    
         
            +
                  label = @i18n.relatedterms[node["type"]].upcase
         
     | 
| 
      
 81 
     | 
    
         
            +
                  if p && ref
         
     | 
| 
      
 82 
     | 
    
         
            +
                    node.replace(l10n("<p><strong>#{label}:</strong> " \
         
     | 
| 
      
 83 
     | 
    
         
            +
                                      "<em>#{to_xml(p)}</em> (#{Common::to_xml(ref)})</p>"))
         
     | 
| 
      
 84 
     | 
    
         
            +
                  else
         
     | 
| 
      
 85 
     | 
    
         
            +
                    node.replace(l10n("<p><strong>#{label}:</strong> " \
         
     | 
| 
      
 86 
     | 
    
         
            +
                                      "<strong>**RELATED TERM NOT FOUND**</strong></p>"))
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -179,5 +179,54 @@ module IsoDoc 
     | 
|
| 
       179 
179 
     | 
    
         
             
                        end
         
     | 
| 
       180 
180 
     | 
    
         
             
                  " #{ret}"
         
     | 
| 
       181 
181 
     | 
    
         
             
                end
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
                def eref2link(docxml)
         
     | 
| 
      
 184 
     | 
    
         
            +
                  docxml.xpath(ns("//eref | //origin[not(termref)] | //quote/source"))
         
     | 
| 
      
 185 
     | 
    
         
            +
                    .each do |e|
         
     | 
| 
      
 186 
     | 
    
         
            +
                    href = eref_target(e) or next
         
     | 
| 
      
 187 
     | 
    
         
            +
                    e.xpath(ns("./locality | ./localityStack")).each(&:remove)
         
     | 
| 
      
 188 
     | 
    
         
            +
                    if /^#/.match?(href) then eref2xref(e)
         
     | 
| 
      
 189 
     | 
    
         
            +
                    else eref2link1(e, href)
         
     | 
| 
      
 190 
     | 
    
         
            +
                    end
         
     | 
| 
      
 191 
     | 
    
         
            +
                  end
         
     | 
| 
      
 192 
     | 
    
         
            +
                end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                def eref2xref(node)
         
     | 
| 
      
 195 
     | 
    
         
            +
                  node.name = "xref"
         
     | 
| 
      
 196 
     | 
    
         
            +
                  node["target"] = node["bibitemid"]
         
     | 
| 
      
 197 
     | 
    
         
            +
                  node.delete("bibitemid")
         
     | 
| 
      
 198 
     | 
    
         
            +
                  node.delete("citeas")
         
     | 
| 
      
 199 
     | 
    
         
            +
                  node["type"] == "footnote" and node.wrap("<sup></sup>")
         
     | 
| 
      
 200 
     | 
    
         
            +
                end
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                def eref2link1(node, href)
         
     | 
| 
      
 203 
     | 
    
         
            +
                  repl = "<link target='#{href}'>#{node.children}</link>"
         
     | 
| 
      
 204 
     | 
    
         
            +
                  node["type"] == "footnote" and repl = "<sup>#{repl}</sup>"
         
     | 
| 
      
 205 
     | 
    
         
            +
                  node.replace(repl)
         
     | 
| 
      
 206 
     | 
    
         
            +
                end
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
                def suffix_url(url)
         
     | 
| 
      
 209 
     | 
    
         
            +
                  return url if url.nil? || %r{^https?://|^#}.match?(url)
         
     | 
| 
      
 210 
     | 
    
         
            +
                  return url unless File.extname(url).empty?
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
                  url.sub(/#{File.extname(url)}$/, ".html")
         
     | 
| 
      
 213 
     | 
    
         
            +
                end
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                def eref_target(node)
         
     | 
| 
      
 216 
     | 
    
         
            +
                  url = suffix_url(eref_url(node["bibitemid"]))
         
     | 
| 
      
 217 
     | 
    
         
            +
                  anchor = node.at(ns(".//locality[@type = 'anchor']"))
         
     | 
| 
      
 218 
     | 
    
         
            +
                  return url if url.nil? || /^#/.match?(url) || !anchor
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
                  "#{url}##{anchor.text.strip}"
         
     | 
| 
      
 221 
     | 
    
         
            +
                end
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                def eref_url(id)
         
     | 
| 
      
 224 
     | 
    
         
            +
                  @bibitems.nil? and return nil
         
     | 
| 
      
 225 
     | 
    
         
            +
                  b = @bibitems[id] or return nil
         
     | 
| 
      
 226 
     | 
    
         
            +
                  url = (b.at(ns("./uri[@type = 'citation'][@language = '#{@lang}']")) ||
         
     | 
| 
      
 227 
     | 
    
         
            +
                  b.at(ns("./uri[@type = 'citation']"))) and return url.text
         
     | 
| 
      
 228 
     | 
    
         
            +
                  b["hidden"] == "true" and return b.at(ns("./uri"))&.text
         
     | 
| 
      
 229 
     | 
    
         
            +
                  "##{id}"
         
     | 
| 
      
 230 
     | 
    
         
            +
                end
         
     | 
| 
       182 
231 
     | 
    
         
             
              end
         
     | 
| 
       183 
232 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,92 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module IsoDoc
         
     | 
| 
       2 
2 
     | 
    
         
             
              class PresentationXMLConvert < ::IsoDoc::Convert
         
     | 
| 
       3 
     | 
    
         
            -
                def concept(docxml)
         
     | 
| 
       4 
     | 
    
         
            -
                  @definition_ids = docxml.xpath(ns("//definitions//dt"))
         
     | 
| 
       5 
     | 
    
         
            -
                    .each_with_object({}) { |x, m| m[x["id"]] = true }
         
     | 
| 
       6 
     | 
    
         
            -
                  docxml.xpath(ns("//concept")).each { |f| concept1(f) }
         
     | 
| 
       7 
     | 
    
         
            -
                end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                def concept1(node)
         
     | 
| 
       10 
     | 
    
         
            -
                  xref = node&.at(ns("./xref/@target"))&.text or
         
     | 
| 
       11 
     | 
    
         
            -
                    return concept_render(node, ital: "true", ref: "true", bold: "false",
         
     | 
| 
       12 
     | 
    
         
            -
                                                linkref: "true", linkmention: "false")
         
     | 
| 
       13 
     | 
    
         
            -
                  if @definition_ids[xref]
         
     | 
| 
       14 
     | 
    
         
            -
                    concept_render(node, ital: "false", ref: "false", bold: "false",
         
     | 
| 
       15 
     | 
    
         
            -
                                         linkref: "true", linkmention: "false")
         
     | 
| 
       16 
     | 
    
         
            -
                  else concept_render(node, ital: "true", ref: "true", bold: "false",
         
     | 
| 
       17 
     | 
    
         
            -
                                            linkref: "true", linkmention: "false")
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                def concept_render(node, defaults)
         
     | 
| 
       22 
     | 
    
         
            -
                  opts, render, ref = concept_render_init(node, defaults)
         
     | 
| 
       23 
     | 
    
         
            -
                  node&.at(ns("./refterm"))&.remove
         
     | 
| 
       24 
     | 
    
         
            -
                  ref && opts[:ref] != "false" and render&.next = " "
         
     | 
| 
       25 
     | 
    
         
            -
                  concept1_linkmention(ref, render, opts)
         
     | 
| 
       26 
     | 
    
         
            -
                  concept1_ref(node, ref, opts)
         
     | 
| 
       27 
     | 
    
         
            -
                  concept1_style(node, opts)
         
     | 
| 
       28 
     | 
    
         
            -
                  node.replace(node.children)
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                def concept1_style(node, opts)
         
     | 
| 
       32 
     | 
    
         
            -
                  r = node.at(ns(".//renderterm")) or return
         
     | 
| 
       33 
     | 
    
         
            -
                  opts[:ital] == "true" and r.children = "<em>#{to_xml(r.children)}</em>"
         
     | 
| 
       34 
     | 
    
         
            -
                  opts[:bold] == "true" and
         
     | 
| 
       35 
     | 
    
         
            -
                    r.children = "<strong>#{to_xml(r.children)}</strong>"
         
     | 
| 
       36 
     | 
    
         
            -
                  r.replace(r.children)
         
     | 
| 
       37 
     | 
    
         
            -
                end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                def concept_render_init(node, defaults)
         
     | 
| 
       40 
     | 
    
         
            -
                  opts = %i(bold ital ref linkref linkmention)
         
     | 
| 
       41 
     | 
    
         
            -
                    .each_with_object({}) { |x, m| m[x] = node[x.to_s] || defaults[x] }
         
     | 
| 
       42 
     | 
    
         
            -
                  [opts, node.at(ns("./renderterm")),
         
     | 
| 
       43 
     | 
    
         
            -
                   node.at(ns("./xref | ./eref | ./termref"))]
         
     | 
| 
       44 
     | 
    
         
            -
                end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                def concept1_linkmention(ref, renderterm, opts)
         
     | 
| 
       47 
     | 
    
         
            -
                  (opts[:linkmention] == "true" && !renderterm.nil? && !ref.nil?) or return
         
     | 
| 
       48 
     | 
    
         
            -
                  ref2 = ref.clone
         
     | 
| 
       49 
     | 
    
         
            -
                  r2 = renderterm.clone
         
     | 
| 
       50 
     | 
    
         
            -
                  renderterm.replace(ref2).children = r2
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                def concept1_ref(_node, ref, opts)
         
     | 
| 
       54 
     | 
    
         
            -
                  ref.nil? and return
         
     | 
| 
       55 
     | 
    
         
            -
                  opts[:ref] == "false" and return ref.remove
         
     | 
| 
       56 
     | 
    
         
            -
                  concept1_ref_content(ref)
         
     | 
| 
       57 
     | 
    
         
            -
                  %w(xref eref).include? ref.name and get_linkend(ref)
         
     | 
| 
       58 
     | 
    
         
            -
                  opts[:linkref] == "false" && %w(xref eref).include?(ref.name) and
         
     | 
| 
       59 
     | 
    
         
            -
                    ref.replace(ref.children)
         
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                def concept1_ref_content(ref)
         
     | 
| 
       63 
     | 
    
         
            -
                  prev = "["
         
     | 
| 
       64 
     | 
    
         
            -
                  foll = "]"
         
     | 
| 
       65 
     | 
    
         
            -
                  non_locality_elems(ref).select do |c|
         
     | 
| 
       66 
     | 
    
         
            -
                    !c.text? || /\S/.match(c)
         
     | 
| 
       67 
     | 
    
         
            -
                  end.empty? and
         
     | 
| 
       68 
     | 
    
         
            -
                    (prev, foll = @i18n.term_defined_in.split("%"))
         
     | 
| 
       69 
     | 
    
         
            -
                  ref.previous = prev
         
     | 
| 
       70 
     | 
    
         
            -
                  ref.next = foll
         
     | 
| 
       71 
     | 
    
         
            -
                end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                def related(docxml)
         
     | 
| 
       74 
     | 
    
         
            -
                  docxml.xpath(ns("//related")).each { |f| related1(f) }
         
     | 
| 
       75 
     | 
    
         
            -
                end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                def related1(node)
         
     | 
| 
       78 
     | 
    
         
            -
                  p = node.at(ns("./preferred"))
         
     | 
| 
       79 
     | 
    
         
            -
                  ref = node.at(ns("./xref | ./eref | ./termref"))
         
     | 
| 
       80 
     | 
    
         
            -
                  label = @i18n.relatedterms[node["type"]].upcase
         
     | 
| 
       81 
     | 
    
         
            -
                  if p && ref
         
     | 
| 
       82 
     | 
    
         
            -
                    node.replace(l10n("<p><strong>#{label}:</strong> " \
         
     | 
| 
       83 
     | 
    
         
            -
                                      "<em>#{to_xml(p)}</em> (#{Common::to_xml(ref)})</p>"))
         
     | 
| 
       84 
     | 
    
         
            -
                  else
         
     | 
| 
       85 
     | 
    
         
            -
                    node.replace(l10n("<p><strong>#{label}:</strong> " \
         
     | 
| 
       86 
     | 
    
         
            -
                                      "<strong>**RELATED TERM NOT FOUND**</strong></p>"))
         
     | 
| 
       87 
     | 
    
         
            -
                  end
         
     | 
| 
       88 
     | 
    
         
            -
                end
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
3 
     | 
    
         
             
                def designation(docxml)
         
     | 
| 
       91 
4 
     | 
    
         
             
                  docxml.xpath(ns("//term")).each { |t| merge_second_preferred(t) }
         
     | 
| 
       92 
5 
     | 
    
         
             
                  docxml.xpath(ns("//preferred | //admitted | //deprecates"))
         
     | 
| 
         @@ -225,9 +138,7 @@ module IsoDoc 
     | 
|
| 
       225 
138 
     | 
    
         
             
                end
         
     | 
| 
       226 
139 
     | 
    
         | 
| 
       227 
140 
     | 
    
         
             
                def termsource(docxml)
         
     | 
| 
       228 
     | 
    
         
            -
                  docxml.xpath(ns("//termsource 
     | 
| 
       229 
     | 
    
         
            -
                    termsource_modification(f)
         
     | 
| 
       230 
     | 
    
         
            -
                  end
         
     | 
| 
      
 141 
     | 
    
         
            +
                  docxml.xpath(ns("//termsource")).each { |f| termsource_modification(f) }
         
     | 
| 
       231 
142 
     | 
    
         
             
                  docxml.xpath(ns("//termsource")).each { |f| termsource1(f) }
         
     | 
| 
       232 
143 
     | 
    
         
             
                end
         
     | 
| 
       233 
144 
     | 
    
         | 
| 
         @@ -238,12 +149,25 @@ module IsoDoc 
     | 
|
| 
       238 
149 
     | 
    
         
             
                  elem.children = l10n("[#{@i18n.source}: #{to_xml(elem.children).strip}]")
         
     | 
| 
       239 
150 
     | 
    
         
             
                end
         
     | 
| 
       240 
151 
     | 
    
         | 
| 
       241 
     | 
    
         
            -
                def termsource_modification( 
     | 
| 
       242 
     | 
    
         
            -
                   
     | 
| 
      
 152 
     | 
    
         
            +
                def termsource_modification(elem)
         
     | 
| 
      
 153 
     | 
    
         
            +
                  origin = elem.at(ns("./origin"))
         
     | 
| 
      
 154 
     | 
    
         
            +
                  s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
         
     | 
| 
      
 155 
     | 
    
         
            +
                  termsource_add_modification_text(elem.at(ns("./modification")))
         
     | 
| 
      
 156 
     | 
    
         
            +
                end
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                def termsource_add_modification_text(mod)
         
     | 
| 
      
 159 
     | 
    
         
            +
                  mod or return
         
     | 
| 
       243 
160 
     | 
    
         
             
                  mod.text.strip.empty? or mod.previous = " – "
         
     | 
| 
       244 
161 
     | 
    
         
             
                  mod.elements.size == 1 and
         
     | 
| 
       245 
162 
     | 
    
         
             
                    mod.elements[0].replace(mod.elements[0].children)
         
     | 
| 
       246 
163 
     | 
    
         
             
                  mod.replace(mod.children)
         
     | 
| 
       247 
164 
     | 
    
         
             
                end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
                def termsource_status(status)
         
     | 
| 
      
 167 
     | 
    
         
            +
                  case status
         
     | 
| 
      
 168 
     | 
    
         
            +
                  when "modified" then @i18n.modified
         
     | 
| 
      
 169 
     | 
    
         
            +
                  when "adapted" then @i18n.adapted
         
     | 
| 
      
 170 
     | 
    
         
            +
                  end
         
     | 
| 
      
 171 
     | 
    
         
            +
                end
         
     | 
| 
       248 
172 
     | 
    
         
             
              end
         
     | 
| 
       249 
173 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require_relative "presentation_function/block"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative "presentation_function/concepts"
         
     | 
| 
       2 
3 
     | 
    
         
             
            require_relative "presentation_function/terms"
         
     | 
| 
       3 
4 
     | 
    
         
             
            require_relative "presentation_function/xrefs"
         
     | 
| 
       4 
5 
     | 
    
         
             
            require_relative "presentation_function/erefs"
         
     | 
| 
         @@ -17,12 +18,20 @@ module IsoDoc 
     | 
|
| 
       17 
18 
     | 
    
         | 
| 
       18 
19 
     | 
    
         
             
                def convert1(docxml, _filename, _dir)
         
     | 
| 
       19 
20 
     | 
    
         
             
                  @xrefs.parse docxml
         
     | 
| 
      
 21 
     | 
    
         
            +
                  bibitem_lookup(docxml)
         
     | 
| 
       20 
22 
     | 
    
         
             
                  info docxml, nil
         
     | 
| 
       21 
23 
     | 
    
         
             
                  conversions(docxml)
         
     | 
| 
       22 
24 
     | 
    
         
             
                  docxml.root["type"] = "presentation"
         
     | 
| 
       23 
25 
     | 
    
         
             
                  docxml.to_xml.gsub(/</, "<").gsub(/>/, ">")
         
     | 
| 
       24 
26 
     | 
    
         
             
                end
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
      
 28 
     | 
    
         
            +
                def bibitem_lookup(docxml)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @bibitems = docxml.xpath(ns("//references/bibitem"))
         
     | 
| 
      
 30 
     | 
    
         
            +
                    .each_with_object({}) do |b, m|
         
     | 
| 
      
 31 
     | 
    
         
            +
                    m[b["id"]] = b
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       26 
35 
     | 
    
         
             
                def conversions(docxml)
         
     | 
| 
       27 
36 
     | 
    
         
             
                  semantic_xml_insert(docxml)
         
     | 
| 
       28 
37 
     | 
    
         
             
                  bibdata docxml
         
     | 
| 
         @@ -69,9 +78,10 @@ module IsoDoc 
     | 
|
| 
       69 
78 
     | 
    
         | 
| 
       70 
79 
     | 
    
         
             
                def inline(docxml)
         
     | 
| 
       71 
80 
     | 
    
         
             
                  xref docxml
         
     | 
| 
       72 
     | 
    
         
            -
                  eref docxml
         
     | 
| 
       73 
     | 
    
         
            -
                  origin docxml
         
     | 
| 
       74 
     | 
    
         
            -
                  quotesource docxml
         
     | 
| 
      
 81 
     | 
    
         
            +
                  eref docxml # feeds docxml
         
     | 
| 
      
 82 
     | 
    
         
            +
                  origin docxml # feeds docxml
         
     | 
| 
      
 83 
     | 
    
         
            +
                  quotesource docxml # feeds docxml
         
     | 
| 
      
 84 
     | 
    
         
            +
                  eref2link docxml
         
     | 
| 
       75 
85 
     | 
    
         
             
                  mathml docxml
         
     | 
| 
       76 
86 
     | 
    
         
             
                  variant docxml
         
     | 
| 
       77 
87 
     | 
    
         
             
                  identifier docxml
         
     | 
    
        data/lib/isodoc/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: isodoc
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.5. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.5.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ribose Inc.
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire:
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-05-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: html2doc
         
     | 
| 
         @@ -433,6 +433,7 @@ files: 
     | 
|
| 
       433 
433 
     | 
    
         
             
            - lib/isodoc/pdf_convert.rb
         
     | 
| 
       434 
434 
     | 
    
         
             
            - lib/isodoc/presentation_function/bibdata.rb
         
     | 
| 
       435 
435 
     | 
    
         
             
            - lib/isodoc/presentation_function/block.rb
         
     | 
| 
      
 436 
     | 
    
         
            +
            - lib/isodoc/presentation_function/concepts.rb
         
     | 
| 
       436 
437 
     | 
    
         
             
            - lib/isodoc/presentation_function/erefs.rb
         
     | 
| 
       437 
438 
     | 
    
         
             
            - lib/isodoc/presentation_function/image.rb
         
     | 
| 
       438 
439 
     | 
    
         
             
            - lib/isodoc/presentation_function/inline.rb
         
     | 
| 
         @@ -473,7 +474,7 @@ homepage: https://github.com/metanorma/isodoc 
     | 
|
| 
       473 
474 
     | 
    
         
             
            licenses:
         
     | 
| 
       474 
475 
     | 
    
         
             
            - BSD-2-Clause
         
     | 
| 
       475 
476 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       476 
     | 
    
         
            -
            post_install_message:
         
     | 
| 
      
 477 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
       477 
478 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       478 
479 
     | 
    
         
             
            require_paths:
         
     | 
| 
       479 
480 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -488,8 +489,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       488 
489 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       489 
490 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       490 
491 
     | 
    
         
             
            requirements: []
         
     | 
| 
       491 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
       492 
     | 
    
         
            -
            signing_key:
         
     | 
| 
      
 492 
     | 
    
         
            +
            rubygems_version: 3.3.26
         
     | 
| 
      
 493 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
       493 
494 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       494 
495 
     | 
    
         
             
            summary: Convert documents in IsoDoc into Word and HTML in AsciiDoc.
         
     | 
| 
       495 
496 
     | 
    
         
             
            test_files: []
         
     |