metanorma-standoc 2.9.1 → 2.9.3
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/metanorma/standoc/anchor.rb +6 -6
- data/lib/metanorma/standoc/blocks.rb +5 -5
- data/lib/metanorma/standoc/blocks_image.rb +2 -2
- data/lib/metanorma/standoc/blocks_notes.rb +5 -5
- data/lib/metanorma/standoc/cleanup.rb +2 -1
- data/lib/metanorma/standoc/cleanup_bibitem.rb +14 -10
- data/lib/metanorma/standoc/cleanup_ref.rb +1 -1
- data/lib/metanorma/standoc/cleanup_symbols.rb +1 -1
- data/lib/metanorma/standoc/cleanup_terms_designations.rb +3 -3
- data/lib/metanorma/standoc/cleanup_text.rb +65 -6
- data/lib/metanorma/standoc/inline.rb +6 -6
- data/lib/metanorma/standoc/lists.rb +4 -4
- data/lib/metanorma/standoc/ref_queue.rb +5 -5
- data/lib/metanorma/standoc/section.rb +3 -3
- data/lib/metanorma/standoc/spans_to_bibitem.rb +1 -1
- data/lib/metanorma/standoc/terms.rb +2 -2
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +3 -2
- metadata +20 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e946ea4ef470077763b56b2435a231a884ddede3c32f9bd09dde4fd912b15bfc
         | 
| 4 | 
            +
              data.tar.gz: 80511a11e935c1e090be377db8180907835895d5507e8b4e88df6c2dee7d4f9a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a72d55869cbd272db4c6818cd8aadd3057021bf4b876c595ecb6c10d98008c7da98368189df23ad25297eaa68119c2c2cdc3efeb9b573812b9a200974458d703
         | 
| 7 | 
            +
              data.tar.gz: 6710ac348b46e662a77ec202ec26944c3d0956a5b984546995444f352f661fefff3995c328ee6c7b2448137d690a7091db2b873584a277279f1c01e549c8a099
         | 
| @@ -15,7 +15,7 @@ module Metanorma | |
| 15 15 | 
             
                  def inline_anchor_ref(node)
         | 
| 16 16 | 
             
                    noko do |xml|
         | 
| 17 17 | 
             
                      xml.bookmark nil, **attr_code(id: node.id)
         | 
| 18 | 
            -
                    end | 
| 18 | 
            +
                    end
         | 
| 19 19 | 
             
                  end
         | 
| 20 20 |  | 
| 21 21 | 
             
                  def inline_anchor_xref(node)
         | 
| @@ -26,7 +26,7 @@ module Metanorma | |
| 26 26 | 
             
                      xml.xref **attr_code(attrs) do |x|
         | 
| 27 27 | 
             
                        x << c
         | 
| 28 28 | 
             
                      end
         | 
| 29 | 
            -
                    end | 
| 29 | 
            +
                    end
         | 
| 30 30 | 
             
                  end
         | 
| 31 31 |  | 
| 32 32 | 
             
                  def inline_anchor_xref_attrs(node)
         | 
| @@ -83,7 +83,7 @@ module Metanorma | |
| 83 83 | 
             
                      xml.link **attr_code(attributes) do |l|
         | 
| 84 84 | 
             
                        l << contents
         | 
| 85 85 | 
             
                      end
         | 
| 86 | 
            -
                    end | 
| 86 | 
            +
                    end
         | 
| 87 87 | 
             
                  end
         | 
| 88 88 |  | 
| 89 89 | 
             
                  def inline_anchor_link_attrs(node)
         | 
| @@ -103,7 +103,7 @@ module Metanorma | |
| 103 103 | 
             
                      xml.ref **attr_code(id: node.target || node.id) do |r|
         | 
| 104 104 | 
             
                        r << eref_contents
         | 
| 105 105 | 
             
                      end
         | 
| 106 | 
            -
                    end | 
| 106 | 
            +
                    end
         | 
| 107 107 | 
             
                  end
         | 
| 108 108 |  | 
| 109 109 | 
             
                  def inline_anchor_bibref_contents(node)
         | 
| @@ -114,7 +114,7 @@ module Metanorma | |
| 114 114 | 
             
                  def inline_callout(node)
         | 
| 115 115 | 
             
                    noko do |xml|
         | 
| 116 116 | 
             
                      xml.callout node.text
         | 
| 117 | 
            -
                    end | 
| 117 | 
            +
                    end
         | 
| 118 118 | 
             
                  end
         | 
| 119 119 |  | 
| 120 120 | 
             
                  def inline_footnote(node)
         | 
| @@ -124,7 +124,7 @@ module Metanorma | |
| 124 124 | 
             
                      xml.fn reference: @fn_number do |fn|
         | 
| 125 125 | 
             
                        fn.p { |p| p << node.text }
         | 
| 126 126 | 
             
                      end
         | 
| 127 | 
            -
                    end | 
| 127 | 
            +
                    end
         | 
| 128 128 | 
             
                  end
         | 
| 129 129 | 
             
                end
         | 
| 130 130 | 
             
              end
         | 
| @@ -90,7 +90,7 @@ module Metanorma | |
| 90 90 | 
             
                        )) do |ex|
         | 
| 91 91 | 
             
                        wrap_in_para(node, ex)
         | 
| 92 92 | 
             
                      end
         | 
| 93 | 
            -
                    end | 
| 93 | 
            +
                    end
         | 
| 94 94 | 
             
                  end
         | 
| 95 95 |  | 
| 96 96 | 
             
                  def example(node)
         | 
| @@ -128,7 +128,7 @@ module Metanorma | |
| 128 128 | 
             
                        figure_title(node, ex)
         | 
| 129 129 | 
             
                        wrap_in_para(node, ex)
         | 
| 130 130 | 
             
                      end
         | 
| 131 | 
            -
                    end | 
| 131 | 
            +
                    end
         | 
| 132 132 | 
             
                  end
         | 
| 133 133 |  | 
| 134 134 | 
             
                  def example_attrs(node)
         | 
| @@ -141,7 +141,7 @@ module Metanorma | |
| 141 141 | 
             
                        node.title.nil? or ex.name { |name| name << node.title }
         | 
| 142 142 | 
             
                        wrap_in_para(node, ex)
         | 
| 143 143 | 
             
                      end
         | 
| 144 | 
            -
                    end | 
| 144 | 
            +
                    end
         | 
| 145 145 | 
             
                  end
         | 
| 146 146 |  | 
| 147 147 | 
             
                  def para_attrs(node)
         | 
| @@ -158,7 +158,7 @@ module Metanorma | |
| 158 158 | 
             
                      xml.p **para_attrs(node) do |xml_t|
         | 
| 159 159 | 
             
                        xml_t << node.content
         | 
| 160 160 | 
             
                      end
         | 
| 161 | 
            -
                    end | 
| 161 | 
            +
                    end
         | 
| 162 162 | 
             
                  end
         | 
| 163 163 |  | 
| 164 164 | 
             
                  def quote_attrs(node)
         | 
| @@ -183,7 +183,7 @@ module Metanorma | |
| 183 183 | 
             
                        quote_attribution(node, q)
         | 
| 184 184 | 
             
                        wrap_in_para(node, q)
         | 
| 185 185 | 
             
                      end
         | 
| 186 | 
            -
                    end | 
| 186 | 
            +
                    end
         | 
| 187 187 | 
             
                  end
         | 
| 188 188 |  | 
| 189 189 | 
             
                  def listing_attrs(node)
         | 
| @@ -17,7 +17,7 @@ module Metanorma | |
| 17 17 | 
             
                        figure_title(node, ex)
         | 
| 18 18 | 
             
                        ex << node.content
         | 
| 19 19 | 
             
                      end
         | 
| 20 | 
            -
                    end | 
| 20 | 
            +
                    end
         | 
| 21 21 | 
             
                  end
         | 
| 22 22 |  | 
| 23 23 | 
             
                  def figure_example(node)
         | 
| @@ -26,7 +26,7 @@ module Metanorma | |
| 26 26 | 
             
                        node.title.nil? or ex.name { |name| name << node.title }
         | 
| 27 27 | 
             
                        wrap_in_para(node, ex)
         | 
| 28 28 | 
             
                      end
         | 
| 29 | 
            -
                    end | 
| 29 | 
            +
                    end
         | 
| 30 30 | 
             
                  end
         | 
| 31 31 |  | 
| 32 32 | 
             
                  def figure_title(node, out)
         | 
| @@ -32,7 +32,7 @@ module Metanorma | |
| 32 32 | 
             
                      xml.review **sidebar_attrs(node) do |r|
         | 
| 33 33 | 
             
                        wrap_in_para(node, r)
         | 
| 34 34 | 
             
                      end
         | 
| 35 | 
            -
                    end | 
| 35 | 
            +
                    end
         | 
| 36 36 | 
             
                  end
         | 
| 37 37 |  | 
| 38 38 | 
             
                  def todo_attrs(node)
         | 
| @@ -49,7 +49,7 @@ module Metanorma | |
| 49 49 | 
             
                      xml.review **todo_attrs(node) do |r|
         | 
| 50 50 | 
             
                        wrap_in_para(node, r)
         | 
| 51 51 | 
             
                      end
         | 
| 52 | 
            -
                    end | 
| 52 | 
            +
                    end
         | 
| 53 53 | 
             
                  end
         | 
| 54 54 |  | 
| 55 55 | 
             
                  def termnote(node)
         | 
| @@ -57,7 +57,7 @@ module Metanorma | |
| 57 57 | 
             
                      xml.termnote **termnote_attrs(node) do |ex|
         | 
| 58 58 | 
             
                        wrap_in_para(node, ex)
         | 
| 59 59 | 
             
                      end
         | 
| 60 | 
            -
                    end | 
| 60 | 
            +
                    end
         | 
| 61 61 | 
             
                  end
         | 
| 62 62 |  | 
| 63 63 | 
             
                  def note(node)
         | 
| @@ -67,7 +67,7 @@ module Metanorma | |
| 67 67 | 
             
                      xml.note **note_attrs(node) do |c|
         | 
| 68 68 | 
             
                        wrap_in_para(node, c)
         | 
| 69 69 | 
             
                      end
         | 
| 70 | 
            -
                    end | 
| 70 | 
            +
                    end
         | 
| 71 71 | 
             
                  end
         | 
| 72 72 |  | 
| 73 73 | 
             
                  def boilerplate_note(node)
         | 
| @@ -101,7 +101,7 @@ module Metanorma | |
| 101 101 | 
             
                        node.title.nil? or a.name { |name| name << node.title }
         | 
| 102 102 | 
             
                        wrap_in_para(node, a)
         | 
| 103 103 | 
             
                      end
         | 
| 104 | 
            -
                    end | 
| 104 | 
            +
                    end
         | 
| 105 105 | 
             
                  end
         | 
| 106 106 |  | 
| 107 107 | 
             
                  def admonition_alternatives(node)
         | 
| @@ -82,6 +82,7 @@ module Metanorma | |
| 82 82 | 
             
                    boilerplate_cleanup(xmldoc)
         | 
| 83 83 | 
             
                    toc_cleanup(xmldoc)
         | 
| 84 84 | 
             
                    smartquotes_cleanup(xmldoc)
         | 
| 85 | 
            +
                    linebreak_cleanup(xmldoc)
         | 
| 85 86 | 
             
                    variant_cleanup(xmldoc)
         | 
| 86 87 | 
             
                    para_cleanup(xmldoc)
         | 
| 87 88 | 
             
                    empty_element_cleanup(xmldoc)
         | 
| @@ -137,7 +138,7 @@ module Metanorma | |
| 137 138 | 
             
                  end
         | 
| 138 139 |  | 
| 139 140 | 
             
                  def element_name_cleanup(xmldoc)
         | 
| 140 | 
            -
                    xmldoc.traverse { |n| n.name = n.name. | 
| 141 | 
            +
                    xmldoc.traverse { |n| n.name = n.name.tr("_", "-") }
         | 
| 141 142 | 
             
                  end
         | 
| 142 143 |  | 
| 143 144 | 
             
                  # allows us to deal with doc relation localities,
         | 
| @@ -36,7 +36,7 @@ module Metanorma | |
| 36 36 |  | 
| 37 37 | 
             
                  def extract_notes_from_biblio(refs)
         | 
| 38 38 | 
             
                    refs.xpath("./bibitem").each do |r|
         | 
| 39 | 
            -
                      r.xpath("./note[@appended]"). | 
| 39 | 
            +
                      r.xpath("./note[@appended]").reverse_each do |n|
         | 
| 40 40 | 
             
                        n.delete("appended")
         | 
| 41 41 | 
             
                        r.next = n
         | 
| 42 42 | 
             
                      end
         | 
| @@ -147,34 +147,38 @@ module Metanorma | |
| 147 147 |  | 
| 148 148 | 
             
                  def save_attachment(path, bib)
         | 
| 149 149 | 
             
                    init_attachments
         | 
| 150 | 
            +
                    path = File.join(@localdir, path)
         | 
| 150 151 | 
             
                    valid_attachment?(path, bib) or return ""
         | 
| 151 152 | 
             
                    f = File.basename(path)
         | 
| 152 153 | 
             
                    File.exist?(File.join(@attachmentsdir, f)) and
         | 
| 153 154 | 
             
                      f += "_#{UUIDTools::UUID.random_create}"
         | 
| 154 | 
            -
                     | 
| 155 | 
            -
                    FileUtils.cp(path,  | 
| 156 | 
            -
                    datauri_attachment( | 
| 157 | 
            -
                     | 
| 155 | 
            +
                    out_fld = File.join(@attachmentsdir, f)
         | 
| 156 | 
            +
                    FileUtils.cp(path, out_fld)
         | 
| 157 | 
            +
                    datauri_attachment(out_fld, bib.document)
         | 
| 158 | 
            +
                    File.join(@attachmentsfld, f)
         | 
| 158 159 | 
             
                  end
         | 
| 159 160 |  | 
| 160 161 | 
             
                  def datauri_attachment(path, doc)
         | 
| 161 162 | 
             
                    @datauriattachment or return
         | 
| 162 | 
            -
                     | 
| 163 | 
            +
                    m = add_misc_container(doc)
         | 
| 163 164 | 
             
                    f = File.basename(path)
         | 
| 164 | 
            -
                    d = Vectory::Utils | 
| 165 | 
            -
                     | 
| 165 | 
            +
                    d = Vectory::Utils::datauri(path, @localdir)
         | 
| 166 | 
            +
                    m << "<attachment name='#{f}'/>"
         | 
| 167 | 
            +
                    m.last_element_child << d
         | 
| 166 168 | 
             
                  end
         | 
| 167 169 |  | 
| 168 170 | 
             
                  def valid_attachment?(path, bib)
         | 
| 169 171 | 
             
                    File.exist?(path) and return true
         | 
| 170 | 
            -
                     | 
| 172 | 
            +
                    p = Pathname.new(path).cleanpath
         | 
| 173 | 
            +
                    @log.add("Bibliography", bib, "Attachment #{p} does not exist",
         | 
| 171 174 | 
             
                             severity: 0)
         | 
| 172 175 | 
             
                    false
         | 
| 173 176 | 
             
                  end
         | 
| 174 177 |  | 
| 175 178 | 
             
                  def init_attachments
         | 
| 176 179 | 
             
                    @attachmentsdir and return
         | 
| 177 | 
            -
                    @ | 
| 180 | 
            +
                    @attachmentsfld = "_#{@filename}_attachments"
         | 
| 181 | 
            +
                    @attachmentsdir = File.join(@output_dir, @attachmentsfld)
         | 
| 178 182 | 
             
                    FileUtils.rm_rf(@attachmentsdir)
         | 
| 179 183 | 
             
                    FileUtils.mkdir_p(@attachmentsdir)
         | 
| 180 184 | 
             
                  end
         | 
| @@ -17,7 +17,7 @@ module Metanorma | |
| 17 17 | 
             
                    bib = sort_biblio(refs.xpath("./bibitem"))
         | 
| 18 18 | 
             
                    insert = refs.at("./bibitem")&.previous_element
         | 
| 19 19 | 
             
                    refs.xpath("./bibitem").each(&:remove)
         | 
| 20 | 
            -
                    bib. | 
| 20 | 
            +
                    bib.reverse_each do |b|
         | 
| 21 21 | 
             
                      (insert and insert.next = b.to_xml) or
         | 
| 22 22 | 
             
                        refs.children.first.add_previous_sibling b.to_xml
         | 
| 23 23 | 
             
                    end
         | 
| @@ -10,7 +10,7 @@ module Metanorma | |
| 10 10 | 
             
                  def symbol_key(sym)
         | 
| 11 11 | 
             
                    @c.decode(asciimath_key(sym).text)
         | 
| 12 12 | 
             
                      .gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
         | 
| 13 | 
            -
                      .gsub(/[[:punct:]]|[_^]/, ":\\0"). | 
| 13 | 
            +
                      .gsub(/[[:punct:]]|[_^]/, ":\\0").delete("`")
         | 
| 14 14 | 
             
                      .gsub(/[0-9]+/, "þ\\0")
         | 
| 15 15 | 
             
                      .tr("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",
         | 
| 16 16 | 
             
                          "ABCFEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
         | 
| @@ -46,7 +46,7 @@ module Metanorma | |
| 46 46 | 
             
                    %w(absent geographic-area).each do |a|
         | 
| 47 47 | 
             
                      dl_to_attrs(prev, dlist, a)
         | 
| 48 48 | 
             
                    end
         | 
| 49 | 
            -
                    %w(field-of-application usage-info). | 
| 49 | 
            +
                    %w(field-of-application usage-info).reverse_each do |a|
         | 
| 50 50 | 
             
                      dl_to_elems(prev.at("./expression"), prev, dlist, a)
         | 
| 51 51 | 
             
                    end
         | 
| 52 52 | 
             
                  end
         | 
| @@ -78,7 +78,7 @@ module Metanorma | |
| 78 78 | 
             
                  end
         | 
| 79 79 |  | 
| 80 80 | 
             
                  def term_dl_to_expression_name_metadata(prev, dlist)
         | 
| 81 | 
            -
                    %w(abbreviation-type pronunciation). | 
| 81 | 
            +
                    %w(abbreviation-type pronunciation).reverse_each do |a|
         | 
| 82 82 | 
             
                      dl_to_elems(prev.at("./expression/name"), prev, dlist, a)
         | 
| 83 83 | 
             
                    end
         | 
| 84 84 | 
             
                    g = dlist.at("./dt[text()='grammar']/following::dd//dl") and
         | 
| @@ -89,7 +89,7 @@ module Metanorma | |
| 89 89 | 
             
                    prev.at(".//expression") or return
         | 
| 90 90 | 
             
                    prev.at(".//expression") << "<grammar><sentinel/></grammar>"
         | 
| 91 91 | 
             
                    %w(gender number isPreposition isParticiple isAdjective isAdverb isNoun
         | 
| 92 | 
            -
                       grammar-value). | 
| 92 | 
            +
                       grammar-value).reverse_each do |a|
         | 
| 93 93 | 
             
                      dl_to_elems(prev.at(".//expression/grammar/*"), prev.elements.last,
         | 
| 94 94 | 
             
                                  dlist, a)
         | 
| 95 95 | 
             
                    end
         | 
| @@ -11,6 +11,54 @@ module Metanorma | |
| 11 11 | 
             
                    text
         | 
| 12 12 | 
             
                  end
         | 
| 13 13 |  | 
| 14 | 
            +
                  def ancestor_include?(elem, ancestors)
         | 
| 15 | 
            +
                    path = elem.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-2]
         | 
| 16 | 
            +
                    !path.intersection(ancestors).empty?
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def linebreak_cleanup(xmldoc)
         | 
| 20 | 
            +
                    xmldoc.traverse do |x|
         | 
| 21 | 
            +
                      x.text? && x.text.include?("\n") or next
         | 
| 22 | 
            +
                      ancestor_include?(x, PRESERVE_LINEBREAK_ELEMENTS) and next
         | 
| 23 | 
            +
                      ancestor_include?(x, STRIP_LINEBREAK_ELEMENTS) or next
         | 
| 24 | 
            +
                      x.replace(Metanorma::Utils
         | 
| 25 | 
            +
                        .line_sanitise(x.text.lines.map(&:rstrip)).join)
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  # process example/p, example/sourcecode, not example on its own:
         | 
| 30 | 
            +
                  # this is about stripping lines for blocks containing inline elems & text
         | 
| 31 | 
            +
                  def linebreak_cleanup(xmldoc)
         | 
| 32 | 
            +
                    xmldoc.xpath(STRIP_LINEBREAK_ELEMENTS.map { |e| "//#{e}" }.join(" | "))
         | 
| 33 | 
            +
                      .each do |b|
         | 
| 34 | 
            +
                        b.xpath(STRIP_LINEBREAK_ELEMENTS.map { |e| ".//#{e}" }.join(" | "))
         | 
| 35 | 
            +
                          .empty? or next
         | 
| 36 | 
            +
                        linebreak_cleanup_block(gather_text_for_linebreak_cleanup(b))
         | 
| 37 | 
            +
                      end
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  def linebreak_cleanup_block(block)
         | 
| 41 | 
            +
                    block.each_with_index do |e, i|
         | 
| 42 | 
            +
                      e[:skip] and next
         | 
| 43 | 
            +
                      lines = e[:text].lines.map(&:rstrip)
         | 
| 44 | 
            +
                      e[:last] or lines << block[i + 1][:text].lines.first # next token context
         | 
| 45 | 
            +
                      out = Metanorma::Utils.line_sanitise(lines)
         | 
| 46 | 
            +
                      e[:last] or out.pop
         | 
| 47 | 
            +
                      e[:elem].replace(out.join)
         | 
| 48 | 
            +
                    end
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  def gather_text_for_linebreak_cleanup(block)
         | 
| 52 | 
            +
                    x = block.xpath(".//text()").map do |e|
         | 
| 53 | 
            +
                      { elem: e, text: e.text,
         | 
| 54 | 
            +
                        skip: ancestor_include?(e, PRESERVE_LINEBREAK_ELEMENTS) }
         | 
| 55 | 
            +
                    end
         | 
| 56 | 
            +
                    x.empty? and return x
         | 
| 57 | 
            +
                    x.each { |e| e[:skip] ||= !e[:text].include?("\n") }
         | 
| 58 | 
            +
                    x[-1][:last] = true
         | 
| 59 | 
            +
                    x
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
             | 
| 14 62 | 
             
                  def smartquotes_cleanup(xmldoc)
         | 
| 15 63 | 
             
                    xmldoc.xpath("//date").each { |d| Metanorma::Utils::endash_date(d) }
         | 
| 16 64 | 
             
                    if @smartquotes then smartquotes_cleanup1(xmldoc)
         | 
| @@ -35,12 +83,22 @@ module Metanorma | |
| 35 83 |  | 
| 36 84 | 
             
                  IGNORE_QUOTES_ELEMENTS =
         | 
| 37 85 | 
             
                    %w(pre tt sourcecode stem asciimath figure bibdata passthrough
         | 
| 38 | 
            -
                       identifier  | 
| 86 | 
            +
                       identifier metanorma-extension).freeze
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  PRESERVE_LINEBREAK_ELEMENTS =
         | 
| 89 | 
            +
                    %w(pre sourcecode passthrough metanorma-extension).freeze
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                  STRIP_LINEBREAK_ELEMENTS =
         | 
| 92 | 
            +
                    %w(title name variant-title figure example review admonition
         | 
| 93 | 
            +
                       note li th td dt dd p quote label annotation
         | 
| 94 | 
            +
                       preferred admitted related deprecates field-of-application
         | 
| 95 | 
            +
                       usage-info expression pronunciation grammar-value domain
         | 
| 96 | 
            +
                       definition termnote termexample modification description
         | 
| 97 | 
            +
                       newcontent floating-title).freeze
         | 
| 39 98 |  | 
| 40 99 | 
             
                  def uninterrupt_quotes_around_xml_skip(elem)
         | 
| 41 100 | 
             
                    !(/\A['"]/.match?(elem.text) &&
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                      .intersection(IGNORE_QUOTES_ELEMENTS).empty? &&
         | 
| 101 | 
            +
                    !ancestor_include?(elem.previous, IGNORE_QUOTES_ELEMENTS) &&
         | 
| 44 102 | 
             
                      ((elem.previous.text.strip.empty? &&
         | 
| 45 103 | 
             
                        !empty_tag_with_text_content?(elem.previous)) ||
         | 
| 46 104 | 
             
                       ignoretext?(elem.previous)))
         | 
| @@ -69,7 +127,7 @@ module Metanorma | |
| 69 127 | 
             
                       abstract preferred admitted related deprecates field-of-application
         | 
| 70 128 | 
             
                       usage-info expression pronunciation grammar-value domain
         | 
| 71 129 | 
             
                       definition termnote termexample modification description
         | 
| 72 | 
            -
                       newcontent floating-title tab).include? elem.name
         | 
| 130 | 
            +
                       newcontent floating-title tab review admonition annotation).include? elem.name
         | 
| 73 131 | 
             
                  end
         | 
| 74 132 |  | 
| 75 133 | 
             
                  def empty_tag_with_text_content?(elem)
         | 
| @@ -83,8 +141,9 @@ module Metanorma | |
| 83 141 | 
             
                      empty_tag_with_text_content?(x) and prev = "dummy"
         | 
| 84 142 | 
             
                      x.text? or next
         | 
| 85 143 |  | 
| 86 | 
            -
                      ancestors = x.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-2]
         | 
| 87 | 
            -
                      ancestors.intersection(IGNORE_QUOTES_ELEMENTS).empty? or next
         | 
| 144 | 
            +
                      # ancestors = x.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-2]
         | 
| 145 | 
            +
                      # ancestors.intersection(IGNORE_QUOTES_ELEMENTS).empty? or next
         | 
| 146 | 
            +
                      ancestor_include?(x, IGNORE_QUOTES_ELEMENTS) and next
         | 
| 88 147 | 
             
                      dumb2smart_quotes1(x, prev)
         | 
| 89 148 | 
             
                      prev = x.text
         | 
| 90 149 | 
             
                    end
         | 
| @@ -11,19 +11,19 @@ module Metanorma | |
| 11 11 | 
             
                    noko do |xml|
         | 
| 12 12 | 
             
                      xml << node.text
         | 
| 13 13 | 
             
                      xml.br
         | 
| 14 | 
            -
                    end | 
| 14 | 
            +
                    end
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 |  | 
| 17 17 | 
             
                  def page_break(node)
         | 
| 18 18 | 
             
                    attrs = {}
         | 
| 19 19 | 
             
                    node.option?("landscape") and attrs[:orientation] = "landscape"
         | 
| 20 20 | 
             
                    node.option?("portrait") and attrs[:orientation] = "portrait"
         | 
| 21 | 
            -
                    noko { |xml| xml.pagebreak **attr_code(attrs) } | 
| 21 | 
            +
                    noko { |xml| xml.pagebreak **attr_code(attrs) }
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 |  | 
| 24 24 | 
             
                  def thematic_break(_node)
         | 
| 25 25 | 
             
                    # noko(&:hr).join # Do not do this, noko blows up
         | 
| 26 | 
            -
                    noko { |xml| xml.hr } | 
| 26 | 
            +
                    noko { |xml| xml.hr } # rubocop:disable Style/SymbolProc
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 |  | 
| 29 29 | 
             
                  def latex_parse1(text, block)
         | 
| @@ -102,7 +102,7 @@ module Metanorma | |
| 102 102 | 
             
                          xml << node.text
         | 
| 103 103 | 
             
                        end
         | 
| 104 104 | 
             
                      end
         | 
| 105 | 
            -
                    end | 
| 105 | 
            +
                    end
         | 
| 106 106 | 
             
                  end
         | 
| 107 107 |  | 
| 108 108 | 
             
                  def hash2styles(role)
         | 
| @@ -146,7 +146,7 @@ module Metanorma | |
| 146 146 | 
             
                  def inline_image(node)
         | 
| 147 147 | 
             
                    noko do |xml|
         | 
| 148 148 | 
             
                      xml.image **image_attributes(node)
         | 
| 149 | 
            -
                    end | 
| 149 | 
            +
                    end
         | 
| 150 150 | 
             
                  end
         | 
| 151 151 |  | 
| 152 152 | 
             
                  def inline_indexterm(node)
         | 
| @@ -154,7 +154,7 @@ module Metanorma | |
| 154 154 | 
             
                      node.type == :visible and xml << node.text
         | 
| 155 155 | 
             
                      terms = (node.attr("terms") || [node.text]).map { |x| xml_encode(x) }
         | 
| 156 156 | 
             
                      inline_indexterm1(xml, terms)
         | 
| 157 | 
            -
                    end | 
| 157 | 
            +
                    end
         | 
| 158 158 | 
             
                  end
         | 
| 159 159 |  | 
| 160 160 | 
             
                  def inline_indexterm1(xml, terms)
         | 
| @@ -41,7 +41,7 @@ module Metanorma | |
| 41 41 | 
             
                        list_caption(node, xml_ul)
         | 
| 42 42 | 
             
                        node.items.each { |item| ul_li(xml_ul, item) }
         | 
| 43 43 | 
             
                      end
         | 
| 44 | 
            -
                    end | 
| 44 | 
            +
                    end
         | 
| 45 45 | 
             
                  end
         | 
| 46 46 |  | 
| 47 47 | 
             
                  def olist_style(style)
         | 
| @@ -67,7 +67,7 @@ module Metanorma | |
| 67 67 | 
             
                        list_caption(node, xml_ol)
         | 
| 68 68 | 
             
                        node.items.each { |item| li(xml_ol, item) }
         | 
| 69 69 | 
             
                      end
         | 
| 70 | 
            -
                    end | 
| 70 | 
            +
                    end
         | 
| 71 71 | 
             
                  end
         | 
| 72 72 |  | 
| 73 73 | 
             
                  def dt(terms, xml_dl)
         | 
| @@ -107,7 +107,7 @@ module Metanorma | |
| 107 107 | 
             
                          dd(dd, xml_dl)
         | 
| 108 108 | 
             
                        end
         | 
| 109 109 | 
             
                      end
         | 
| 110 | 
            -
                    end | 
| 110 | 
            +
                    end
         | 
| 111 111 | 
             
                  end
         | 
| 112 112 |  | 
| 113 113 | 
             
                  def colist(node)
         | 
| @@ -117,7 +117,7 @@ module Metanorma | |
| 117 117 | 
             
                          xml_li.p { |p| p << item.text }
         | 
| 118 118 | 
             
                        end
         | 
| 119 119 | 
             
                      end
         | 
| 120 | 
            -
                    end | 
| 120 | 
            +
                    end
         | 
| 121 121 | 
             
                  end
         | 
| 122 122 |  | 
| 123 123 | 
             
                  def list_caption(node, out)
         | 
| @@ -24,7 +24,7 @@ module Metanorma | |
| 24 24 |  | 
| 25 25 | 
             
                  def references2xml(ret)
         | 
| 26 26 | 
             
                    out = ret.map do |b|
         | 
| 27 | 
            -
                      b.nil? ? nil : noko { |xml| reference1out(b, xml) } | 
| 27 | 
            +
                      b.nil? ? nil : noko { |xml| reference1out(b, xml) }
         | 
| 28 28 | 
             
                    end
         | 
| 29 29 | 
             
                    out.map { |x| x.nil? ? nil : Nokogiri::XML(x).root }
         | 
| 30 30 | 
             
                  end
         | 
| @@ -40,7 +40,7 @@ module Metanorma | |
| 40 40 | 
             
                  def reference_queue(results, size)
         | 
| 41 41 | 
             
                    (1..size).each.with_object([]) do |_, m|
         | 
| 42 42 | 
             
                      ref, i, doc = results.pop
         | 
| 43 | 
            -
                      m[i.to_i] = { ref:  | 
| 43 | 
            +
                      m[i.to_i] = { ref: }
         | 
| 44 44 | 
             
                      if doc.is_a?(RelatonBib::RequestError)
         | 
| 45 45 | 
             
                        @log.add("Bibliography", nil, "Could not retrieve #{ref[:code]}: " \
         | 
| 46 46 | 
             
                                                      "no access to online site", severity: 1)
         | 
| @@ -69,7 +69,7 @@ module Metanorma | |
| 69 69 |  | 
| 70 70 | 
             
                  def merge_publishers(base, add)
         | 
| 71 71 | 
             
                    ins = base.at("//contributor[last()]") || base.children[-1]
         | 
| 72 | 
            -
                    add.xpath("//contributor[role/@type = 'publisher']"). | 
| 72 | 
            +
                    add.xpath("//contributor[role/@type = 'publisher']").reverse_each do |p|
         | 
| 73 73 | 
             
                      ins.next = p
         | 
| 74 74 | 
             
                    end
         | 
| 75 75 | 
             
                  end
         | 
| @@ -80,14 +80,14 @@ module Metanorma | |
| 80 80 | 
             
                      v.at("//docidentifier[@primary = 'true']") or
         | 
| 81 81 | 
             
                        v.at("//docidentifier")["primary"] = true
         | 
| 82 82 | 
             
                    end
         | 
| 83 | 
            -
                    add.xpath("//docidentifier"). | 
| 83 | 
            +
                    add.xpath("//docidentifier").reverse_each do |p|
         | 
| 84 84 | 
             
                      ins.next = p
         | 
| 85 85 | 
             
                    end
         | 
| 86 86 | 
             
                  end
         | 
| 87 87 |  | 
| 88 88 | 
             
                  def merge_urls(base, add)
         | 
| 89 89 | 
             
                    ins = base.at("./uri[last()]") || base.at("./title[last()]")
         | 
| 90 | 
            -
                    add.xpath("./uri"). | 
| 90 | 
            +
                    add.xpath("./uri").reverse_each do |p|
         | 
| 91 91 | 
             
                      ins.next = p
         | 
| 92 92 | 
             
                    end
         | 
| 93 93 | 
             
                  end
         | 
| @@ -141,7 +141,7 @@ module Metanorma | |
| 141 141 | 
             
                          clause_parse(a, xml, node)
         | 
| 142 142 | 
             
                        end
         | 
| 143 143 | 
             
                      end
         | 
| 144 | 
            -
                    end | 
| 144 | 
            +
                    end
         | 
| 145 145 | 
             
                  end
         | 
| 146 146 |  | 
| 147 147 | 
             
                  def set_obligation(attrs, node)
         | 
| @@ -162,7 +162,7 @@ module Metanorma | |
| 162 162 | 
             
                        end
         | 
| 163 163 | 
             
                        xml_abstract << node.content
         | 
| 164 164 | 
             
                      end
         | 
| 165 | 
            -
                    end | 
| 165 | 
            +
                    end
         | 
| 166 166 | 
             
                  end
         | 
| 167 167 |  | 
| 168 168 | 
             
                  def misccontainer_parse(_attrs, xml, node)
         | 
| @@ -243,7 +243,7 @@ module Metanorma | |
| 243 243 | 
             
                      xml.floating_title **floating_title_attrs(node) do |xml_t|
         | 
| 244 244 | 
             
                        xml_t << node.title
         | 
| 245 245 | 
             
                      end
         | 
| 246 | 
            -
                    end | 
| 246 | 
            +
                    end
         | 
| 247 247 | 
             
                  end
         | 
| 248 248 | 
             
                end
         | 
| 249 249 | 
             
              end
         | 
| @@ -131,7 +131,7 @@ module Metanorma | |
| 131 131 | 
             
                      span[:surname] and return
         | 
| 132 132 | 
             
                      msg = "Missing surname: issue with bibliographic markup " \
         | 
| 133 133 | 
             
                            "in \"#{title}\": #{span}"
         | 
| 134 | 
            -
                      @err << { msg | 
| 134 | 
            +
                      @err << { msg:, fatal: true }
         | 
| 135 135 | 
             
                    end
         | 
| 136 136 |  | 
| 137 137 | 
             
                    def span_to_person(span, title)
         | 
| @@ -170,7 +170,7 @@ module Metanorma | |
| 170 170 | 
             
                        seen_xref = Nokogiri::XML.fragment(matched[:xref])
         | 
| 171 171 | 
             
                        add_term_source(node, xml_t, seen_xref, matched)
         | 
| 172 172 | 
             
                      end
         | 
| 173 | 
            -
                    end | 
| 173 | 
            +
                    end
         | 
| 174 174 | 
             
                  end
         | 
| 175 175 |  | 
| 176 176 | 
             
                  def termdefinition(node)
         | 
| @@ -178,7 +178,7 @@ module Metanorma | |
| 178 178 | 
             
                      xml.definition **attr_code(type: node.attr("type")) do |d|
         | 
| 179 179 | 
             
                        d << node.content
         | 
| 180 180 | 
             
                      end
         | 
| 181 | 
            -
                    end | 
| 181 | 
            +
                    end
         | 
| 182 182 | 
             
                  end
         | 
| 183 183 | 
             
                end
         | 
| 184 184 | 
             
              end
         | 
    
        data/metanorma-standoc.gemspec
    CHANGED
    
    | @@ -32,12 +32,12 @@ Gem::Specification.new do |spec| | |
| 32 32 | 
             
              spec.add_dependency "asciidoctor", "~> 2.0.0"
         | 
| 33 33 | 
             
              spec.add_dependency "crass", "~> 1.0.0"
         | 
| 34 34 | 
             
              spec.add_dependency "iev", "~> 0.3.0"
         | 
| 35 | 
            -
              spec.add_dependency "isodoc", "~> 2. | 
| 35 | 
            +
              spec.add_dependency "isodoc", "~> 2.11.0"
         | 
| 36 36 | 
             
              spec.add_dependency "metanorma", ">= 1.6.0"
         | 
| 37 37 | 
             
              spec.add_dependency "metanorma-plugin-datastruct", "~> 0.3.0"
         | 
| 38 38 | 
             
              spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.0"
         | 
| 39 39 | 
             
              spec.add_dependency "metanorma-plugin-lutaml", "~> 0.7.0"
         | 
| 40 | 
            -
              spec.add_dependency "metanorma-utils", "~> 1. | 
| 40 | 
            +
              spec.add_dependency "metanorma-utils", "~> 1.10.0"
         | 
| 41 41 | 
             
              spec.add_dependency "ruby-jing"
         | 
| 42 42 | 
             
              # relaton-cli not just relaton, to avoid circular reference in metanorma
         | 
| 43 43 | 
             
              spec.add_dependency "asciimath2unitsml", "~> 0.4.0"
         | 
| @@ -59,5 +59,6 @@ Gem::Specification.new do |spec| | |
| 59 59 | 
             
              spec.add_development_dependency "timecop", "~> 0.9"
         | 
| 60 60 | 
             
              spec.add_development_dependency "vcr", "~> 6.1.0"
         | 
| 61 61 | 
             
              spec.add_development_dependency "webmock"
         | 
| 62 | 
            +
              spec.add_development_dependency "xml-c14n"
         | 
| 62 63 | 
             
              # spec.metadata["rubygems_mfa_required"] = "true"
         | 
| 63 64 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: metanorma-standoc
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.9. | 
| 4 | 
            +
              version: 2.9.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ribose Inc.
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-08-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: addressable
         | 
| @@ -72,14 +72,14 @@ dependencies: | |
| 72 72 | 
             
                requirements:
         | 
| 73 73 | 
             
                - - "~>"
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version: 2. | 
| 75 | 
            +
                    version: 2.11.0
         | 
| 76 76 | 
             
              type: :runtime
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 80 | 
             
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version: 2. | 
| 82 | 
            +
                    version: 2.11.0
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: metanorma
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -142,14 +142,14 @@ dependencies: | |
| 142 142 | 
             
                requirements:
         | 
| 143 143 | 
             
                - - "~>"
         | 
| 144 144 | 
             
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            -
                    version: 1. | 
| 145 | 
            +
                    version: 1.10.0
         | 
| 146 146 | 
             
              type: :runtime
         | 
| 147 147 | 
             
              prerelease: false
         | 
| 148 148 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 149 | 
             
                requirements:
         | 
| 150 150 | 
             
                - - "~>"
         | 
| 151 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            -
                    version: 1. | 
| 152 | 
            +
                    version: 1.10.0
         | 
| 153 153 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 154 154 | 
             
              name: ruby-jing
         | 
| 155 155 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -416,6 +416,20 @@ dependencies: | |
| 416 416 | 
             
                - - ">="
         | 
| 417 417 | 
             
                  - !ruby/object:Gem::Version
         | 
| 418 418 | 
             
                    version: '0'
         | 
| 419 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 420 | 
            +
              name: xml-c14n
         | 
| 421 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 422 | 
            +
                requirements:
         | 
| 423 | 
            +
                - - ">="
         | 
| 424 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 425 | 
            +
                    version: '0'
         | 
| 426 | 
            +
              type: :development
         | 
| 427 | 
            +
              prerelease: false
         | 
| 428 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 429 | 
            +
                requirements:
         | 
| 430 | 
            +
                - - ">="
         | 
| 431 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 432 | 
            +
                    version: '0'
         | 
| 419 433 | 
             
            description: |
         | 
| 420 434 | 
             
              metanorma-standoc realises standards following the Metanorma standoc model
         | 
| 421 435 |  |