metanorma-standoc 2.2.4 → 2.2.6
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/.github/workflows/automerge.yml +31 -0
- data/lib/isodoc/html/htmlstyle.css +1 -1
- data/lib/metanorma/standoc/base.rb +1 -0
- data/lib/metanorma/standoc/basicdoc.rng +0 -27
- data/lib/metanorma/standoc/biblio-standoc.rng +164 -0
- data/lib/metanorma/standoc/biblio.rng +45 -18
- data/lib/metanorma/standoc/blocks.rb +2 -1
- data/lib/metanorma/standoc/cleanup.rb +1 -0
- data/lib/metanorma/standoc/cleanup_asciibib.rb +110 -0
- data/lib/metanorma/standoc/cleanup_biblio.rb +5 -111
- data/lib/metanorma/standoc/cleanup_block.rb +7 -6
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +6 -6
- data/lib/metanorma/standoc/cleanup_inline.rb +2 -2
- data/lib/metanorma/standoc/cleanup_text.rb +10 -3
- data/lib/metanorma/standoc/inline.rb +3 -1
- data/lib/metanorma/standoc/isodoc-compile.rng +7 -0
- data/lib/metanorma/standoc/isodoc.rng +32 -195
- data/lib/metanorma/standoc/macros_plantuml.rb +23 -10
- data/lib/metanorma/standoc/validate.rb +8 -8
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +0 -1
- data/spec/metanorma/biblio_spec.rb +152 -144
- data/spec/metanorma/blocks_spec.rb +2 -2
- data/spec/metanorma/cleanup_sections_spec.rb +1 -2
- data/spec/metanorma/cleanup_spec.rb +11 -0
- data/spec/metanorma/inline_spec.rb +70 -8
- data/spec/metanorma/isobib_cache_spec.rb +2 -2
- data/spec/metanorma/macros_plantuml_spec.rb +4 -4
- data/spec/metanorma/macros_spec.rb +2 -2
- data/spec/metanorma/refs_spec.rb +25 -25
- data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +3 -3
- data/spec/vcr_cassettes/bsi16341.yml +70 -72
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +82 -82
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
- data/spec/vcr_cassettes/hide_refs.yml +58 -58
- data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_123_1.yml +22 -22
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +33 -33
- data/spec/vcr_cassettes/isobib_get_123_2.yml +25 -25
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +37 -21
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -45
- data/spec/vcr_cassettes/std-link.yml +12 -12
- metadata +6 -16
| @@ -53,11 +53,11 @@ module Metanorma | |
| 53 53 | 
             
                    end
         | 
| 54 54 | 
             
                  end
         | 
| 55 55 |  | 
| 56 | 
            -
                  TERM_CLAUSE = "//sections/terms | "\
         | 
| 56 | 
            +
                  TERM_CLAUSE = "//sections/terms | " \
         | 
| 57 57 | 
             
                                "//sections/clause[descendant::terms]".freeze
         | 
| 58 58 |  | 
| 59 59 | 
             
                  NORM_REF =
         | 
| 60 | 
            -
                    "//bibliography/references[@normative = 'true'][not(@hidden)] | "\
         | 
| 60 | 
            +
                    "//bibliography/references[@normative = 'true'][not(@hidden)] | " \
         | 
| 61 61 | 
             
                    "//bibliography/clause[.//references[@normative = 'true']]".freeze
         | 
| 62 62 |  | 
| 63 63 | 
             
                  def boilerplate_isodoc(xmldoc)
         | 
| @@ -79,7 +79,7 @@ module Metanorma | |
| 79 79 |  | 
| 80 80 | 
             
                  def unwrap_boilerplate_clauses(xmldoc, xpath)
         | 
| 81 81 | 
             
                    xmldoc.xpath(xpath).each do |f|
         | 
| 82 | 
            -
                      f.xpath(".//clause[@type = 'boilerplate'] | "\
         | 
| 82 | 
            +
                      f.xpath(".//clause[@type = 'boilerplate'] | " \
         | 
| 83 83 | 
             
                              ".//note[@type = 'boilerplate']").each do |c|
         | 
| 84 84 | 
             
                        c&.at("./title")&.remove
         | 
| 85 85 | 
             
                        c.replace(c.children)
         | 
| @@ -175,9 +175,9 @@ module Metanorma | |
| 175 175 | 
             
                  end
         | 
| 176 176 |  | 
| 177 177 | 
             
                  def indirect_eref_to_xref(eref, ident)
         | 
| 178 | 
            -
                    loc = eref | 
| 178 | 
            +
                    loc = eref.at("./localityStack[locality[@type = 'anchor']]")
         | 
| 179 179 | 
             
                      &.remove&.text ||
         | 
| 180 | 
            -
                      eref | 
| 180 | 
            +
                      eref.at("./locality[@type = 'anchor']")&.remove&.text || ident
         | 
| 181 181 | 
             
                    eref.name = "xref"
         | 
| 182 182 | 
             
                    eref.delete("bibitemid")
         | 
| 183 183 | 
             
                    eref.delete("citeas")
         | 
| @@ -213,7 +213,7 @@ module Metanorma | |
| 213 213 | 
             
                  def bibdata_embed_hdr_cleanup(xmldoc)
         | 
| 214 214 | 
             
                    return if @embed_hdr.nil? || @embed_hdr.empty?
         | 
| 215 215 |  | 
| 216 | 
            -
                    xmldoc.at("//bibdata") << "<relation type='derivedFrom'>"\
         | 
| 216 | 
            +
                    xmldoc.at("//bibdata") << "<relation type='derivedFrom'>" \
         | 
| 217 217 | 
             
                                              "#{hdr2bibitem(@embed_hdr.first)}</relation>"
         | 
| 218 218 | 
             
                  end
         | 
| 219 219 |  | 
| @@ -35,7 +35,7 @@ module Metanorma | |
| 35 35 |  | 
| 36 36 | 
             
                  def li_bookmark_cleanup(xmldoc)
         | 
| 37 37 | 
             
                    xmldoc.xpath("//li[descendant::bookmark]").each do |x|
         | 
| 38 | 
            -
                      if x.at("./*[1][local-name() = 'p']/"\
         | 
| 38 | 
            +
                      if x.at("./*[1][local-name() = 'p']/" \
         | 
| 39 39 | 
             
                              "*[1][local-name() = 'bookmark']") &&
         | 
| 40 40 | 
             
                          empty_text_before_first_element(x.elements[0])
         | 
| 41 41 | 
             
                        bookmark_to_id(x, x.elements[0].elements[0])
         | 
| @@ -45,7 +45,7 @@ module Metanorma | |
| 45 45 |  | 
| 46 46 | 
             
                  def dt_bookmark_cleanup(xmldoc)
         | 
| 47 47 | 
             
                    xmldoc.xpath("//dt[descendant::bookmark]").each do |x|
         | 
| 48 | 
            -
                      if x.at("./*[1][local-name() = 'p']/"\
         | 
| 48 | 
            +
                      if x.at("./*[1][local-name() = 'p']/" \
         | 
| 49 49 | 
             
                              "*[1][local-name() = 'bookmark']") &&
         | 
| 50 50 | 
             
                          empty_text_before_first_element(x.elements[0])
         | 
| 51 51 | 
             
                        bookmark_to_id(x, x.elements[0].elements[0])
         | 
| @@ -43,7 +43,7 @@ module Metanorma | |
| 43 43 | 
             
                      .intersection(IGNORE_QUOTES_ELEMENTS).empty? &&
         | 
| 44 44 | 
             
                      ((elem.previous.text.strip.empty? &&
         | 
| 45 45 | 
             
                        !empty_tag_with_text_content?(elem.previous)) ||
         | 
| 46 | 
            -
                       elem.previous | 
| 46 | 
            +
                       ignoretext?(elem.previous)))
         | 
| 47 47 | 
             
                  end
         | 
| 48 48 |  | 
| 49 49 | 
             
                  def uninterrupt_quotes_around_xml1(elem)
         | 
| @@ -56,13 +56,20 @@ module Metanorma | |
| 56 56 | 
             
                    prev.content = "#{prev.text}#{m[1]}"
         | 
| 57 57 | 
             
                  end
         | 
| 58 58 |  | 
| 59 | 
            +
                  IGNORE_TEXT_ELEMENTS =
         | 
| 60 | 
            +
                    %w(index fn).freeze
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  def ignoretext?(elem)
         | 
| 63 | 
            +
                    IGNORE_TEXT_ELEMENTS.include? elem.name
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 59 66 | 
             
                  def block?(elem)
         | 
| 60 67 | 
             
                    %w(title name variant-title clause figure annex example introduction
         | 
| 61 68 | 
             
                       foreword acknowledgements note li th td dt dd p quote label
         | 
| 62 69 | 
             
                       abstract preferred admitted related deprecates field-of-application
         | 
| 63 70 | 
             
                       usage-info expression pronunciation grammar-value domain
         | 
| 64 71 | 
             
                       definition termnote termexample modification description
         | 
| 65 | 
            -
                       newcontent floating-title).include? elem.name
         | 
| 72 | 
            +
                       newcontent floating-title tab).include? elem.name
         | 
| 66 73 | 
             
                  end
         | 
| 67 74 |  | 
| 68 75 | 
             
                  def empty_tag_with_text_content?(elem)
         | 
| @@ -79,7 +86,7 @@ module Metanorma | |
| 79 86 | 
             
                      ancestors = x.path.split(%r{/})[1..-2]
         | 
| 80 87 | 
             
                      ancestors.intersection(IGNORE_QUOTES_ELEMENTS).empty? and
         | 
| 81 88 | 
             
                        dumb2smart_quotes1(x, prev)
         | 
| 82 | 
            -
                      prev = x.text  | 
| 89 | 
            +
                      prev = x.text if ancestors.intersection(IGNORE_TEXT_ELEMENTS).empty?
         | 
| 83 90 | 
             
                    end
         | 
| 84 91 | 
             
                  end
         | 
| 85 92 |  | 
| @@ -45,6 +45,7 @@ module Metanorma | |
| 45 45 | 
             
                    m.nil? and return { target: t, type: "inline", text: node.text }
         | 
| 46 46 | 
             
                    { target: t, type: m[:fn].nil? ? "inline" : "footnote",
         | 
| 47 47 | 
             
                      case: m[:case]&.sub(/%$/, ""),
         | 
| 48 | 
            +
                      style: m[:style]&.sub(/^style=/, "")&.sub(/%$/, "") || @xrefstyle,
         | 
| 48 49 | 
             
                      droploc: m[:drop].nil? && m[:drop2].nil? ? nil : true,
         | 
| 49 50 | 
             
                      text: inline_anchor_xref_text(m, node),
         | 
| 50 51 | 
             
                      hidden: m[:hidden] }
         | 
| @@ -52,12 +53,13 @@ module Metanorma | |
| 52 53 |  | 
| 53 54 | 
             
                  def inline_anchor_xref_match(node)
         | 
| 54 55 | 
             
                    /^(?:hidden%(?<hidden>[^,]+),?)?
         | 
| 56 | 
            +
                      (?<style>style=[^%]+%)?
         | 
| 55 57 | 
             
                      (?<drop>droploc%)?(?<case>capital%|lowercase%)?(?<drop2>droploc%)?
         | 
| 56 58 | 
             
                      (?<fn>fn:?\s*)?(?<text>.*)$/x.match node.text
         | 
| 57 59 | 
             
                  end
         | 
| 58 60 |  | 
| 59 61 | 
             
                  def inline_anchor_xref_text(match, node)
         | 
| 60 | 
            -
                    if %i[case fn drop drop2 hidden].any? do |x|
         | 
| 62 | 
            +
                    if %i[case fn drop drop2 hidden style].any? do |x|
         | 
| 61 63 | 
             
                         !match[x].nil?
         | 
| 62 64 | 
             
                       end
         | 
| 63 65 | 
             
                      match[:text]
         | 
| @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            <?xml version="1.0" encoding="UTF-8"?>
         | 
| 2 | 
            +
            <grammar ns="https://www.metanorma.org/ns/standoc" xmlns="http://relaxng.org/ns/structure/1.0">
         | 
| 3 | 
            +
              <!-- default namespace isostandard = "https://www.metanorma.com/ns/iso" -->
         | 
| 4 | 
            +
              <include href="biblio-standoc.rng"/>
         | 
| 5 | 
            +
              <include href="isodoc.rng"/>
         | 
| 6 | 
            +
            </grammar>
         | 
| 7 | 
            +
            <!-- end overrides -->
         | 
| @@ -17,21 +17,9 @@ | |
| 17 17 | 
             
              these elements; we just want one namespace for any child grammars
         | 
| 18 18 | 
             
              of this.
         | 
| 19 19 | 
             
            -->
         | 
| 20 | 
            -
            <grammar  | 
| 20 | 
            +
            <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
         | 
| 21 21 | 
             
              <include href="reqt.rng"/>
         | 
| 22 | 
            -
              <!-- include "biblio.rnc" { } -->
         | 
| 23 22 | 
             
              <include href="basicdoc.rng">
         | 
| 24 | 
            -
                <start>
         | 
| 25 | 
            -
                  <ref name="standard-document"/>
         | 
| 26 | 
            -
                </start>
         | 
| 27 | 
            -
                <define name="doctype">
         | 
| 28 | 
            -
                  <element name="doctype">
         | 
| 29 | 
            -
                    <optional>
         | 
| 30 | 
            -
                      <attribute name="abbreviation"/>
         | 
| 31 | 
            -
                    </optional>
         | 
| 32 | 
            -
                    <ref name="DocumentType"/>
         | 
| 33 | 
            -
                  </element>
         | 
| 34 | 
            -
                </define>
         | 
| 35 23 | 
             
                <define name="admonition">
         | 
| 36 24 | 
             
                  <element name="admonition">
         | 
| 37 25 | 
             
                    <attribute name="type">
         | 
| @@ -117,24 +105,6 @@ | |
| 117 105 | 
             
                    </optional>
         | 
| 118 106 | 
             
                  </element>
         | 
| 119 107 | 
             
                </define>
         | 
| 120 | 
            -
                <define name="bibitem">
         | 
| 121 | 
            -
                  <element name="bibitem">
         | 
| 122 | 
            -
                    <attribute name="id">
         | 
| 123 | 
            -
                      <data type="ID"/>
         | 
| 124 | 
            -
                    </attribute>
         | 
| 125 | 
            -
                    <optional>
         | 
| 126 | 
            -
                      <attribute name="hidden">
         | 
| 127 | 
            -
                        <data type="boolean"/>
         | 
| 128 | 
            -
                      </attribute>
         | 
| 129 | 
            -
                    </optional>
         | 
| 130 | 
            -
                    <optional>
         | 
| 131 | 
            -
                      <attribute name="suppress_identifier">
         | 
| 132 | 
            -
                        <data type="boolean"/>
         | 
| 133 | 
            -
                      </attribute>
         | 
| 134 | 
            -
                    </optional>
         | 
| 135 | 
            -
                    <ref name="BibliographicItem"/>
         | 
| 136 | 
            -
                  </element>
         | 
| 137 | 
            -
                </define>
         | 
| 138 108 | 
             
                <define name="section-title">
         | 
| 139 109 | 
             
                  <element name="title">
         | 
| 140 110 | 
             
                    <zeroOrMore>
         | 
| @@ -205,6 +175,15 @@ | |
| 205 175 | 
             
                        <data type="boolean"/>
         | 
| 206 176 | 
             
                      </attribute>
         | 
| 207 177 | 
             
                    </optional>
         | 
| 178 | 
            +
                    <optional>
         | 
| 179 | 
            +
                      <attribute name="style">
         | 
| 180 | 
            +
                        <choice>
         | 
| 181 | 
            +
                          <value>basic</value>
         | 
| 182 | 
            +
                          <value>full</value>
         | 
| 183 | 
            +
                          <value>short</value>
         | 
| 184 | 
            +
                        </choice>
         | 
| 185 | 
            +
                      </attribute>
         | 
| 186 | 
            +
                    </optional>
         | 
| 208 187 | 
             
                    <ref name="XrefBody"/>
         | 
| 209 188 | 
             
                  </element>
         | 
| 210 189 | 
             
                </define>
         | 
| @@ -239,42 +218,6 @@ | |
| 239 218 | 
             
                    <ref name="PureTextElement"/>
         | 
| 240 219 | 
             
                  </oneOrMore>
         | 
| 241 220 | 
             
                </define>
         | 
| 242 | 
            -
                <define name="localityStack">
         | 
| 243 | 
            -
                  <element name="localityStack">
         | 
| 244 | 
            -
                    <optional>
         | 
| 245 | 
            -
                      <attribute name="connective">
         | 
| 246 | 
            -
                        <choice>
         | 
| 247 | 
            -
                          <value>and</value>
         | 
| 248 | 
            -
                          <value>or</value>
         | 
| 249 | 
            -
                          <value>from</value>
         | 
| 250 | 
            -
                          <value>to</value>
         | 
| 251 | 
            -
                          <value/>
         | 
| 252 | 
            -
                        </choice>
         | 
| 253 | 
            -
                      </attribute>
         | 
| 254 | 
            -
                    </optional>
         | 
| 255 | 
            -
                    <zeroOrMore>
         | 
| 256 | 
            -
                      <ref name="locality"/>
         | 
| 257 | 
            -
                    </zeroOrMore>
         | 
| 258 | 
            -
                  </element>
         | 
| 259 | 
            -
                </define>
         | 
| 260 | 
            -
                <define name="sourceLocalityStack">
         | 
| 261 | 
            -
                  <element name="sourceLocalityStack">
         | 
| 262 | 
            -
                    <optional>
         | 
| 263 | 
            -
                      <attribute name="connective">
         | 
| 264 | 
            -
                        <choice>
         | 
| 265 | 
            -
                          <value>and</value>
         | 
| 266 | 
            -
                          <value>or</value>
         | 
| 267 | 
            -
                          <value>from</value>
         | 
| 268 | 
            -
                          <value>to</value>
         | 
| 269 | 
            -
                          <value/>
         | 
| 270 | 
            -
                        </choice>
         | 
| 271 | 
            -
                      </attribute>
         | 
| 272 | 
            -
                    </optional>
         | 
| 273 | 
            -
                    <zeroOrMore>
         | 
| 274 | 
            -
                      <ref name="sourceLocality"/>
         | 
| 275 | 
            -
                    </zeroOrMore>
         | 
| 276 | 
            -
                  </element>
         | 
| 277 | 
            -
                </define>
         | 
| 278 221 | 
             
                <define name="ul">
         | 
| 279 222 | 
             
                  <element name="ul">
         | 
| 280 223 | 
             
                    <attribute name="id">
         | 
| @@ -818,21 +761,6 @@ | |
| 818 761 | 
             
                    </zeroOrMore>
         | 
| 819 762 | 
             
                  </element>
         | 
| 820 763 | 
             
                </define>
         | 
| 821 | 
            -
                <define name="BibDataExtensionType">
         | 
| 822 | 
            -
                  <ref name="doctype"/>
         | 
| 823 | 
            -
                  <optional>
         | 
| 824 | 
            -
                    <ref name="docsubtype"/>
         | 
| 825 | 
            -
                  </optional>
         | 
| 826 | 
            -
                  <optional>
         | 
| 827 | 
            -
                    <ref name="editorialgroup"/>
         | 
| 828 | 
            -
                  </optional>
         | 
| 829 | 
            -
                  <zeroOrMore>
         | 
| 830 | 
            -
                    <ref name="ics"/>
         | 
| 831 | 
            -
                  </zeroOrMore>
         | 
| 832 | 
            -
                  <zeroOrMore>
         | 
| 833 | 
            -
                    <ref name="structuredidentifier"/>
         | 
| 834 | 
            -
                  </zeroOrMore>
         | 
| 835 | 
            -
                </define>
         | 
| 836 764 | 
             
                <!-- TitleType = text -->
         | 
| 837 765 | 
             
                <define name="sections">
         | 
| 838 766 | 
             
                  <element name="sections">
         | 
| @@ -872,7 +800,7 @@ | |
| 872 800 | 
             
                      <ref name="BasicBlock"/>
         | 
| 873 801 | 
             
                    </zeroOrMore>
         | 
| 874 802 | 
             
                    <zeroOrMore>
         | 
| 875 | 
            -
                      <ref name=" | 
| 803 | 
            +
                      <ref name="doc_bibitem"/>
         | 
| 876 804 | 
             
                      <zeroOrMore>
         | 
| 877 805 | 
             
                        <ref name="note"/>
         | 
| 878 806 | 
             
                      </zeroOrMore>
         | 
| @@ -1210,6 +1138,24 @@ | |
| 1210 1138 | 
             
                </define>
         | 
| 1211 1139 | 
             
              </include>
         | 
| 1212 1140 | 
             
              <!-- end overrides -->
         | 
| 1141 | 
            +
              <define name="doc_bibitem">
         | 
| 1142 | 
            +
                <element name="bibitem">
         | 
| 1143 | 
            +
                  <attribute name="id">
         | 
| 1144 | 
            +
                    <data type="ID"/>
         | 
| 1145 | 
            +
                  </attribute>
         | 
| 1146 | 
            +
                  <optional>
         | 
| 1147 | 
            +
                    <attribute name="hidden">
         | 
| 1148 | 
            +
                      <data type="boolean"/>
         | 
| 1149 | 
            +
                    </attribute>
         | 
| 1150 | 
            +
                  </optional>
         | 
| 1151 | 
            +
                  <optional>
         | 
| 1152 | 
            +
                    <attribute name="suppress_identifier">
         | 
| 1153 | 
            +
                      <data type="boolean"/>
         | 
| 1154 | 
            +
                    </attribute>
         | 
| 1155 | 
            +
                  </optional>
         | 
| 1156 | 
            +
                  <ref name="BibliographicItem"/>
         | 
| 1157 | 
            +
                </element>
         | 
| 1158 | 
            +
              </define>
         | 
| 1213 1159 | 
             
              <define name="image" combine="choice">
         | 
| 1214 1160 | 
             
                <element name="svg">
         | 
| 1215 1161 | 
             
                  <oneOrMore>
         | 
| @@ -1228,14 +1174,6 @@ | |
| 1228 1174 | 
             
                  <value>tag</value>
         | 
| 1229 1175 | 
             
                </choice>
         | 
| 1230 1176 | 
             
              </define>
         | 
| 1231 | 
            -
              <define name="docsubtype">
         | 
| 1232 | 
            -
                <element name="subdoctype">
         | 
| 1233 | 
            -
                  <ref name="DocumentSubtype"/>
         | 
| 1234 | 
            -
                </element>
         | 
| 1235 | 
            -
              </define>
         | 
| 1236 | 
            -
              <define name="DocumentSubtype">
         | 
| 1237 | 
            -
                <text/>
         | 
| 1238 | 
            -
              </define>
         | 
| 1239 1177 | 
             
              <define name="colgroup">
         | 
| 1240 1178 | 
             
                <element name="colgroup">
         | 
| 1241 1179 | 
             
                  <oneOrMore>
         | 
| @@ -1597,45 +1535,6 @@ | |
| 1597 1535 | 
             
                  </choice>
         | 
| 1598 1536 | 
             
                </element>
         | 
| 1599 1537 | 
             
              </define>
         | 
| 1600 | 
            -
              <define name="editorialgroup">
         | 
| 1601 | 
            -
                <element name="editorialgroup">
         | 
| 1602 | 
            -
                  <oneOrMore>
         | 
| 1603 | 
            -
                    <ref name="technical-committee"/>
         | 
| 1604 | 
            -
                  </oneOrMore>
         | 
| 1605 | 
            -
                </element>
         | 
| 1606 | 
            -
              </define>
         | 
| 1607 | 
            -
              <define name="technical-committee">
         | 
| 1608 | 
            -
                <element name="technical-committee">
         | 
| 1609 | 
            -
                  <ref name="IsoWorkgroup"/>
         | 
| 1610 | 
            -
                </element>
         | 
| 1611 | 
            -
              </define>
         | 
| 1612 | 
            -
              <define name="IsoWorkgroup">
         | 
| 1613 | 
            -
                <optional>
         | 
| 1614 | 
            -
                  <attribute name="number"/>
         | 
| 1615 | 
            -
                </optional>
         | 
| 1616 | 
            -
                <optional>
         | 
| 1617 | 
            -
                  <attribute name="type"/>
         | 
| 1618 | 
            -
                </optional>
         | 
| 1619 | 
            -
                <optional>
         | 
| 1620 | 
            -
                  <attribute name="identifier"/>
         | 
| 1621 | 
            -
                </optional>
         | 
| 1622 | 
            -
                <optional>
         | 
| 1623 | 
            -
                  <attribute name="prefix"/>
         | 
| 1624 | 
            -
                </optional>
         | 
| 1625 | 
            -
                <text/>
         | 
| 1626 | 
            -
              </define>
         | 
| 1627 | 
            -
              <define name="ics">
         | 
| 1628 | 
            -
                <element name="ics">
         | 
| 1629 | 
            -
                  <element name="code">
         | 
| 1630 | 
            -
                    <text/>
         | 
| 1631 | 
            -
                  </element>
         | 
| 1632 | 
            -
                  <optional>
         | 
| 1633 | 
            -
                    <element name="text">
         | 
| 1634 | 
            -
                      <text/>
         | 
| 1635 | 
            -
                    </element>
         | 
| 1636 | 
            -
                  </optional>
         | 
| 1637 | 
            -
                </element>
         | 
| 1638 | 
            -
              </define>
         | 
| 1639 1538 | 
             
              <define name="standard-document">
         | 
| 1640 1539 | 
             
                <element name="standard-document">
         | 
| 1641 1540 | 
             
                  <attribute name="version"/>
         | 
| @@ -2466,71 +2365,6 @@ | |
| 2466 2365 | 
             
                  </optional>
         | 
| 2467 2366 | 
             
                </element>
         | 
| 2468 2367 | 
             
              </define>
         | 
| 2469 | 
            -
              <define name="structuredidentifier">
         | 
| 2470 | 
            -
                <element name="structuredidentifier">
         | 
| 2471 | 
            -
                  <optional>
         | 
| 2472 | 
            -
                    <attribute name="type"/>
         | 
| 2473 | 
            -
                  </optional>
         | 
| 2474 | 
            -
                  <oneOrMore>
         | 
| 2475 | 
            -
                    <element name="agency">
         | 
| 2476 | 
            -
                      <text/>
         | 
| 2477 | 
            -
                    </element>
         | 
| 2478 | 
            -
                  </oneOrMore>
         | 
| 2479 | 
            -
                  <optional>
         | 
| 2480 | 
            -
                    <element name="class">
         | 
| 2481 | 
            -
                      <text/>
         | 
| 2482 | 
            -
                    </element>
         | 
| 2483 | 
            -
                  </optional>
         | 
| 2484 | 
            -
                  <element name="docnumber">
         | 
| 2485 | 
            -
                    <text/>
         | 
| 2486 | 
            -
                  </element>
         | 
| 2487 | 
            -
                  <optional>
         | 
| 2488 | 
            -
                    <element name="partnumber">
         | 
| 2489 | 
            -
                      <text/>
         | 
| 2490 | 
            -
                    </element>
         | 
| 2491 | 
            -
                  </optional>
         | 
| 2492 | 
            -
                  <optional>
         | 
| 2493 | 
            -
                    <element name="edition">
         | 
| 2494 | 
            -
                      <text/>
         | 
| 2495 | 
            -
                    </element>
         | 
| 2496 | 
            -
                  </optional>
         | 
| 2497 | 
            -
                  <optional>
         | 
| 2498 | 
            -
                    <element name="version">
         | 
| 2499 | 
            -
                      <text/>
         | 
| 2500 | 
            -
                    </element>
         | 
| 2501 | 
            -
                  </optional>
         | 
| 2502 | 
            -
                  <optional>
         | 
| 2503 | 
            -
                    <element name="supplementtype">
         | 
| 2504 | 
            -
                      <text/>
         | 
| 2505 | 
            -
                    </element>
         | 
| 2506 | 
            -
                  </optional>
         | 
| 2507 | 
            -
                  <optional>
         | 
| 2508 | 
            -
                    <element name="supplementnumber">
         | 
| 2509 | 
            -
                      <text/>
         | 
| 2510 | 
            -
                    </element>
         | 
| 2511 | 
            -
                  </optional>
         | 
| 2512 | 
            -
                  <optional>
         | 
| 2513 | 
            -
                    <element name="amendment">
         | 
| 2514 | 
            -
                      <text/>
         | 
| 2515 | 
            -
                    </element>
         | 
| 2516 | 
            -
                  </optional>
         | 
| 2517 | 
            -
                  <optional>
         | 
| 2518 | 
            -
                    <element name="corrigendum">
         | 
| 2519 | 
            -
                      <text/>
         | 
| 2520 | 
            -
                    </element>
         | 
| 2521 | 
            -
                  </optional>
         | 
| 2522 | 
            -
                  <optional>
         | 
| 2523 | 
            -
                    <element name="language">
         | 
| 2524 | 
            -
                      <text/>
         | 
| 2525 | 
            -
                    </element>
         | 
| 2526 | 
            -
                  </optional>
         | 
| 2527 | 
            -
                  <optional>
         | 
| 2528 | 
            -
                    <element name="year">
         | 
| 2529 | 
            -
                      <text/>
         | 
| 2530 | 
            -
                    </element>
         | 
| 2531 | 
            -
                  </optional>
         | 
| 2532 | 
            -
                </element>
         | 
| 2533 | 
            -
              </define>
         | 
| 2534 2368 | 
             
              <define name="term-clause">
         | 
| 2535 2369 | 
             
                <element name="clause">
         | 
| 2536 2370 | 
             
                  <optional>
         | 
| @@ -2804,4 +2638,7 @@ | |
| 2804 2638 | 
             
                  </attribute>
         | 
| 2805 2639 | 
             
                </element>
         | 
| 2806 2640 | 
             
              </define>
         | 
| 2641 | 
            +
              <start>
         | 
| 2642 | 
            +
                <ref name="standard-document"/>
         | 
| 2643 | 
            +
              </start>
         | 
| 2807 2644 | 
             
            </grammar>
         | 
| @@ -1,21 +1,22 @@ | |
| 1 1 | 
             
            module Metanorma
         | 
| 2 2 | 
             
              module Standoc
         | 
| 3 3 | 
             
                class PlantUMLBlockMacroBackend
         | 
| 4 | 
            -
                  # https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
         | 
| 5 4 | 
             
                  def self.plantuml_installed?
         | 
| 6 | 
            -
                     | 
| 7 | 
            -
             | 
| 8 | 
            -
                     | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 5 | 
            +
                    unless which("plantuml")
         | 
| 6 | 
            +
                      raise "PlantUML not installed"
         | 
| 7 | 
            +
                    end
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def self.plantuml_bin
         | 
| 11 | 
            +
                    if Gem.win_platform? || which("plantumlc")
         | 
| 12 | 
            +
                      "plantumlc"
         | 
| 13 | 
            +
                    else
         | 
| 14 | 
            +
                      "plantuml"
         | 
| 13 15 | 
             
                    end
         | 
| 14 | 
            -
                    raise "PlantUML not installed"
         | 
| 15 16 | 
             
                  end
         | 
| 16 17 |  | 
| 17 18 | 
             
                  def self.run(umlfile, outfile)
         | 
| 18 | 
            -
                    system " | 
| 19 | 
            +
                    system "#{plantuml_bin} #{umlfile.path}" or (warn $? and return false)
         | 
| 19 20 | 
             
                    i = 0
         | 
| 20 21 | 
             
                    until !Gem.win_platform? || File.exist?(outfile) || i == 15
         | 
| 21 22 | 
             
                      sleep(1)
         | 
| @@ -84,6 +85,18 @@ module Metanorma | |
| 84 85 | 
             
                      memo
         | 
| 85 86 | 
             
                    end
         | 
| 86 87 | 
             
                  end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                  # https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
         | 
| 90 | 
            +
                  def self.which(cmd)
         | 
| 91 | 
            +
                    exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
         | 
| 92 | 
            +
                    ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
         | 
| 93 | 
            +
                      exts.each do |ext|
         | 
| 94 | 
            +
                        exe = File.join(path, "#{cmd}#{ext}")
         | 
| 95 | 
            +
                        return exe if File.executable?(exe) && !File.directory?(exe)
         | 
| 96 | 
            +
                      end
         | 
| 97 | 
            +
                    end
         | 
| 98 | 
            +
                    nil
         | 
| 99 | 
            +
                  end
         | 
| 87 100 | 
             
                end
         | 
| 88 101 |  | 
| 89 102 | 
             
                class PlantUMLBlockMacro < Asciidoctor::Extensions::BlockProcessor
         | 
| @@ -9,7 +9,7 @@ require "pngcheck" | |
| 9 9 | 
             
            module Metanorma
         | 
| 10 10 | 
             
              module Standoc
         | 
| 11 11 | 
             
                module Validate
         | 
| 12 | 
            -
                  SOURCELOCALITY = "./origin//locality[@type = 'clause']/"\
         | 
| 12 | 
            +
                  SOURCELOCALITY = "./origin//locality[@type = 'clause']/" \
         | 
| 13 13 | 
             
                                   "referenceFrom".freeze
         | 
| 14 14 |  | 
| 15 15 | 
             
                  def init_iev
         | 
| @@ -24,7 +24,7 @@ module Metanorma | |
| 24 24 | 
             
                    @iev = init_iev or return
         | 
| 25 25 | 
             
                    xmldoc.xpath("//term").each do |t|
         | 
| 26 26 | 
             
                      t.xpath(".//termsource").each do |src|
         | 
| 27 | 
            -
                        (/^IEC 60050-/.match(src | 
| 27 | 
            +
                        (/^IEC 60050-/.match(src.at("./origin/@citeas")&.text) &&
         | 
| 28 28 | 
             
                      loc = src.xpath(SOURCELOCALITY)&.text) or next
         | 
| 29 29 | 
             
                        iev_validate1(t, loc, xmldoc)
         | 
| 30 30 | 
             
                      end
         | 
| @@ -33,9 +33,9 @@ module Metanorma | |
| 33 33 |  | 
| 34 34 | 
             
                  def iev_validate1(term, loc, xmldoc)
         | 
| 35 35 | 
             
                    iev = @iev.fetch(loc,
         | 
| 36 | 
            -
                                     xmldoc | 
| 36 | 
            +
                                     xmldoc.at("//language")&.text || "en") or return
         | 
| 37 37 | 
             
                    pref = term.xpath("./preferred//name").inject([]) do |m, x|
         | 
| 38 | 
            -
                      m << x | 
| 38 | 
            +
                      m << x.text&.downcase
         | 
| 39 39 | 
             
                    end
         | 
| 40 40 | 
             
                    pref.include?(iev.downcase) or
         | 
| 41 41 | 
             
                      @log.add("Bibliography", term, %(Term "#{pref[0]}" does not match ) +
         | 
| @@ -97,7 +97,7 @@ module Metanorma | |
| 97 97 |  | 
| 98 98 | 
             
                  def repeat_id_validate1(ids, elem)
         | 
| 99 99 | 
             
                    if ids[elem["id"]]
         | 
| 100 | 
            -
                      @log.add("Anchors", elem, "Anchor #{elem['id']} has already been "\
         | 
| 100 | 
            +
                      @log.add("Anchors", elem, "Anchor #{elem['id']} has already been " \
         | 
| 101 101 | 
             
                                                "used at line #{ids[elem['id']]}")
         | 
| 102 102 | 
             
                      @fatalerror << "Multiple instances of same ID: #{elem['id']}"
         | 
| 103 103 | 
             
                    else
         | 
| @@ -137,8 +137,8 @@ module Metanorma | |
| 137 137 | 
             
                  SVG_NS = "http://www.w3.org/2000/svg".freeze
         | 
| 138 138 |  | 
| 139 139 | 
             
                  WILDCARD_ATTRS =
         | 
| 140 | 
            -
                    "//*[@format] | //stem | //bibdata//description | "\
         | 
| 141 | 
            -
                    "//formattedref | //bibdata//note | //bibdata/abstract | "\
         | 
| 140 | 
            +
                    "//*[@format] | //stem | //bibdata//description | " \
         | 
| 141 | 
            +
                    "//formattedref | //bibdata//note | //bibdata/abstract | " \
         | 
| 142 142 | 
             
                    "//bibitem/abstract | //bibitem/note | //misc-container".freeze
         | 
| 143 143 |  | 
| 144 144 | 
             
                  # RelaxNG cannot cope well with wildcard attributes. So we strip
         | 
| @@ -213,7 +213,7 @@ module Metanorma | |
| 213 213 | 
             
                  def validate(doc)
         | 
| 214 214 | 
             
                    content_validate(doc)
         | 
| 215 215 | 
             
                    schema_validate(formattedstr_strip(doc.dup),
         | 
| 216 | 
            -
                                    File.join(File.dirname(__FILE__), "isodoc.rng"))
         | 
| 216 | 
            +
                                    File.join(File.dirname(__FILE__), "isodoc-compile.rng"))
         | 
| 217 217 | 
             
                  end
         | 
| 218 218 | 
             
                end
         | 
| 219 219 | 
             
              end
         | 
    
        data/metanorma-standoc.gemspec
    CHANGED
    
    | @@ -37,7 +37,6 @@ Gem::Specification.new do |spec| | |
| 37 37 | 
             
              spec.add_dependency "concurrent-ruby"
         | 
| 38 38 | 
             
              spec.add_dependency "latexmath"
         | 
| 39 39 | 
             
              spec.add_dependency "mathml2asciimath"
         | 
| 40 | 
            -
              spec.add_dependency "mn-requirements", "~> 0.1.4"
         | 
| 41 40 | 
             
              spec.add_dependency "pngcheck"
         | 
| 42 41 | 
             
              spec.add_dependency "relaton-cli", "~> 1.13.0"
         | 
| 43 42 | 
             
              spec.add_dependency "relaton-iev", "~> 1.1.0"
         |