metanorma-standoc 1.5.3 → 1.6.0

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +4 -9
  3. data/.github/workflows/ubuntu.yml +0 -4
  4. data/.github/workflows/windows.yml +2 -12
  5. data/lib/asciidoctor/standoc/base.rb +6 -1
  6. data/lib/asciidoctor/standoc/basicdoc.rng +4 -11
  7. data/lib/asciidoctor/standoc/cleanup.rb +30 -12
  8. data/lib/asciidoctor/standoc/cleanup_ref.rb +2 -3
  9. data/lib/asciidoctor/standoc/front_contributor.rb +10 -2
  10. data/lib/asciidoctor/standoc/inline.rb +18 -40
  11. data/lib/asciidoctor/standoc/isodoc.rng +13 -6
  12. data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +2 -1
  13. data/lib/asciidoctor/standoc/ref.rb +31 -30
  14. data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +4 -1
  15. data/lib/metanorma/standoc.rb +0 -5
  16. data/lib/metanorma/standoc/version.rb +20 -1
  17. data/metanorma-standoc.gemspec +2 -1
  18. data/spec/asciidoctor-standoc/base_spec.rb +121 -3
  19. data/spec/asciidoctor-standoc/blocks_spec.rb +1 -1
  20. data/spec/asciidoctor-standoc/cleanup_spec.rb +11 -9
  21. data/spec/asciidoctor-standoc/inline_spec.rb +128 -4
  22. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +9 -7
  23. data/spec/asciidoctor-standoc/refs_spec.rb +27 -18
  24. data/spec/spec_helper.rb +1 -1
  25. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +46 -0
  26. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +71 -71
  27. data/spec/vcr_cassettes/isobib_get_123.yml +17 -17
  28. data/spec/vcr_cassettes/isobib_get_123_1.yml +35 -35
  29. data/spec/vcr_cassettes/isobib_get_123_2001.yml +18 -18
  30. data/spec/vcr_cassettes/isobib_get_124.yml +17 -17
  31. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  32. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +39 -37
  33. metadata +5 -7
  34. data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
  35. data/lib/metanorma/standoc/requirement.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7503bfc7dd68c2d6a6b2ded8f08611e92067a15aa4088c02f1e5408ff8e027e6
4
- data.tar.gz: 65cd5d4d3648788113fd30437fe8d649c6e498b9ebdab8d5b41d2fadb7439056
3
+ metadata.gz: 0a619338025bf24d56d382fde0bfcd3d7c5f2e5ecf5520d995d8c7d4986cb67d
4
+ data.tar.gz: 1f8c10a80a5ada1b94c6216568eb11851fd081c9ae63bae2d8b9e3e080673b17
5
5
  SHA512:
6
- metadata.gz: 73510f7d926c6acf395377794a753cef6bb0f0658fb66c606df07e23548c17f010c7120b77765b388fb363a4309051fcf03a601d6ea95cf20aca6e4645b1c674
7
- data.tar.gz: bae732755cc47dcae17e0d8ef01bcd35173c8941807b2d5844cf45f008f57c199977756d4fd15b0e3c8c558e73432dd9ba88be2b01f61b32cff180308adcd83d
6
+ metadata.gz: 5d9fea4687d265c36099b30faa69893c10ec011e7d1a8b7e32b4e0df4ef9d892e5efe90bb8bd0767f51f3ec74f91b05dc3613532eeff247f1a2039b6094f15dc
7
+ data.tar.gz: 2ccb181da62a4ca659c2f3915ffdbebbc88b501c97938244d65d780b241e05bd2f61870ac32cc8a3cef739ac7a36b8c714f2cc5027d9269e78c7e6f6bcabb12c
@@ -29,18 +29,13 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- - name: Install LaTeXML
33
- run: |
34
- brew install libxml2 cpanminus
35
- env PATH=$(brew --prefix libxml2)/bin:$PATH \
36
- cpanm --notest XML::LibXSLT@1.96 git://github.com/brucemiller/LaTeXML.git@9a0e7dc5
37
- - name: Install PlantUML
38
- run: |
39
- brew install plantuml
40
32
  - name: Update gems
41
33
  run: |
42
34
  sudo gem install bundler --force
43
35
  bundle install --jobs 4 --retry 3
36
+ - name: Install PlantUML
37
+ run: |
38
+ brew install plantuml
44
39
  - name: Run specs
45
40
  run: |
46
- env PATH=$(brew --prefix perl)/bin:$PATH bundle exec rake
41
+ bundle exec rake
@@ -33,10 +33,6 @@ jobs:
33
33
  run: |
34
34
  gem install bundler
35
35
  bundle install --jobs 4 --retry 3
36
- - name: Install LaTeXML
37
- run: |
38
- sudo snap install latexml --edge
39
- echo "::add-path::/snap/bin"
40
36
  - name: Install PlantUML
41
37
  uses: nick-invision/retry@v1
42
38
  with:
@@ -29,25 +29,15 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- - name: Install MN Windows dependencies
33
- shell: pwsh
34
- run: |
35
- choco install --no-progress plantuml make sed gnuwin32-coreutils.install grep
36
32
  - name: Update gems
37
33
  shell: pwsh
38
34
  run: |
39
35
  gem install bundler
40
36
  bundle config --local path vendor/bundle
41
37
  bundle install --jobs 4 --retry 3
42
- - name: Install LaTeXML
43
- shell: cmd
38
+ - name: Install PlantUML
44
39
  run: |
45
- cinst -y latexml
46
- refreshenv
47
- set PATH=C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;%PATH%
48
- where latexmlmath
40
+ cinst -y plantuml
49
41
  - name: Run specs
50
- shell: pwsh
51
42
  run: |
52
- $env:Path = "C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;$env:Path"
53
43
  bundle exec rake
@@ -143,6 +143,11 @@ module Asciidoctor
143
143
  ret
144
144
  end
145
145
 
146
+ def version
147
+ flavour = self.class.name.sub(/::Converter$/, "").sub(/^.+::/, "")
148
+ Metanorma.versioned(Metanorma, flavour)[-1]::VERSION
149
+ end
150
+
146
151
  def clean_exit
147
152
  @log.write(@output_dir + @filename + ".err") unless @novalid
148
153
  @files_to_delete.each { |f| FileUtils.rm f }
@@ -150,7 +155,7 @@ module Asciidoctor
150
155
 
151
156
  def makexml1(node)
152
157
  result = ["<?xml version='1.0' encoding='UTF-8'?>",
153
- "<#{xml_root_tag}>"]
158
+ "<#{xml_root_tag} type='semantic' version='#{version}'>"]
154
159
  result << noko { |ixml| front node, ixml }
155
160
  result << noko { |ixml| middle node, ixml }
156
161
  result << "</#{xml_root_tag}>"
@@ -158,17 +158,7 @@
158
158
  <data type="ID"/>
159
159
  </attribute>
160
160
  <oneOrMore>
161
- <choice>
162
- <ref name="formula"/>
163
- <ref name="ul"/>
164
- <ref name="ol"/>
165
- <ref name="dl"/>
166
- <ref name="quote"/>
167
- <ref name="sourcecode"/>
168
- <ref name="paragraph"/>
169
- <ref name="table"/>
170
- <ref name="figure"/>
171
- </choice>
161
+ <ref name="paragraph"/>
172
162
  </oneOrMore>
173
163
  </element>
174
164
  </define>
@@ -1028,6 +1018,9 @@
1028
1018
  <value>alphabet_upper</value>
1029
1019
  </choice>
1030
1020
  </attribute>
1021
+ <optional>
1022
+ <attribute name="start"/>
1023
+ </optional>
1031
1024
  <oneOrMore>
1032
1025
  <ref name="li"/>
1033
1026
  </oneOrMore>
@@ -81,12 +81,13 @@ module Asciidoctor
81
81
  xmldoc.traverse do |n|
82
82
  next unless n.text?
83
83
  if @smartquotes
84
- next unless /[-'"(<>]|\.\.|\dx/.match(n)
85
- next unless n.ancestors("pre, tt, sourcecode, bibdata, on, "\
86
- "stem, figure[@class = 'pseudocode']").empty?
84
+ /[-'"(<>]|\.\.|\dx/.match(n) or next
85
+ n.ancestors("pre, tt, sourcecode, bibdata, on, "\
86
+ "stem, figure[@class = 'pseudocode']").empty? or next
87
87
  n.replace(Utils::smartformat(n.text))
88
88
  else
89
- n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))
89
+ n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))#.
90
+ #gsub(/</, "&lt;").gsub(/>/, "&gt;"))
90
91
  end
91
92
  end
92
93
  end
@@ -146,16 +147,33 @@ module Asciidoctor
146
147
  align_callouts_to_annotations(xmldoc)
147
148
  end
148
149
 
150
+ def xml_unescape_mathml(x)
151
+ return if x.children.any? { |y| y.element? }
152
+ math = x.text.gsub(/&lt;/, "<").gsub(/&gt;/, ">").gsub(/&quot;/, '"').
153
+ gsub(/&apos;/, "'").gsub(/&amp;/, "&").
154
+ gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</")
155
+ x.children = math
156
+ end
157
+
158
+ def mathml_preserve_space(m)
159
+ m.xpath(".//m:mtext",
160
+ "m" => "http://www.w3.org/1998/Math/MathML").each do |x|
161
+ x.children = x.children.to_xml.gsub(/^\s/, "&#xA0;").
162
+ gsub(/\s$/, "&#xA0;")
163
+ end
164
+ end
165
+
166
+ def mathml_namespace(stem)
167
+ stem.xpath("./math", ).each do |x|
168
+ x.default_namespace = "http://www.w3.org/1998/Math/MathML"
169
+ end
170
+ end
171
+
149
172
  def mathml_cleanup(xmldoc)
150
173
  xmldoc.xpath("//stem[@type = 'MathML']").each do |x|
151
- next if x.children.any? { |y| y.element? }
152
- math = x.text.gsub(/&lt;/, "<").gsub(/&gt;/, ">").gsub(/&quot;/, '"').
153
- gsub(/&apos;/, "'").gsub(/&amp;/, "&").
154
- gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</").
155
- gsub(/ xmlns[^>"']+/, "").
156
- gsub(/<math /, '<math xmlns="http://www.w3.org/1998/Math/MathML" ').
157
- gsub(/<math>/, '<math xmlns="http://www.w3.org/1998/Math/MathML">')
158
- x.children = math
174
+ xml_unescape_mathml(x)
175
+ mathml_namespace(x)
176
+ mathml_preserve_space(x)
159
177
  end
160
178
  end
161
179
 
@@ -49,9 +49,8 @@ module Asciidoctor
49
49
  # consecutively, but that standards codes are preserved as is:
50
50
  # only numeric references are renumbered
51
51
  def biblio_renumber(xmldoc)
52
- r = xmldoc.at("//references[@normative = 'false'] | "\
53
- "//clause[.//references[@normative = 'false']] | "\
54
- "//annex[.//references[@normative = 'false']]") or return
52
+ r = xmldoc.at("//references | //clause[.//references] | "\
53
+ "//annex[.//references]") or return
55
54
  r.xpath(".//bibitem[not(ancestor::bibitem)]").each_with_index do |b, i|
56
55
  next unless docid = b.at("./docidentifier[@type = 'metanorma']")
57
56
  next unless /^\[\d+\]$/.match(docid.text)
@@ -22,14 +22,18 @@ module Asciidoctor
22
22
  end
23
23
 
24
24
  def organization(org, orgname)
25
+ abbrevs = org_abbrev
26
+ n = abbrevs.invert[orgname] and orgname = n
25
27
  org.name orgname
28
+ a = org_abbrev[orgname] and org.abbreviation a
26
29
  end
27
30
 
28
31
  # , " => ," : CSV definition does not deal with space followed by quote
29
32
  # at start of field
30
33
  def csv_split(s, delim = ",")
31
- CSV.parse_line(s&.gsub(/, "(?!")/, ',"'), liberal_parsing: true,
32
- col_sep: delim)&.map { |x| x.strip }
34
+ CSV.parse_line(s&.gsub(/, "(?!")/, ',"'),
35
+ liberal_parsing: true,
36
+ col_sep: delim)&.compact&.map { |x| x.strip }
33
37
  end
34
38
 
35
39
  def metadata_author(node, xml)
@@ -105,6 +109,10 @@ module Asciidoctor
105
109
  nil
106
110
  end
107
111
 
112
+ def org_abbrev
113
+ { }
114
+ end
115
+
108
116
  def metadata_publisher(node, xml)
109
117
  publishers = node.attr("publisher") || default_publisher || return
110
118
  csv_split(publishers)&.each do |p|
@@ -33,18 +33,28 @@ module Asciidoctor
33
33
  end
34
34
 
35
35
  def inline_anchor_xref(node)
36
- m = /^(?<case>capital%|lowercase%)?(?<fn>fn(:\s*(?<text>.*))?)?$/.match node.text
37
- casing = m.nil? ? nil : m[:case]&.sub(/%$/, "")
38
- f = (m.nil? || m[:fn].nil?) ? "inline" : "footnote"
39
- c = (!m.nil? && (!m[:fn].nil? || !m[:case].nil?)) ? m[:text] : node.text
40
- t = node.target.gsub(/^#/, "").gsub(%r{(\.xml|\.adoc)(#.*$)}, "\\2")
41
36
  noko do |xml|
42
- xml.xref **attr_code(target: t, type: f, case: casing) do |x|
37
+ attrs = inline_anchor_xref_attrs(node)
38
+ c = attrs[:text]
39
+ attrs.delete(:text) unless c.nil?
40
+ xml.xref **attr_code(attrs) do |x|
43
41
  x << c
44
42
  end
45
43
  end.join
46
44
  end
47
45
 
46
+ def inline_anchor_xref_attrs(node)
47
+ m = /^(?<drop>droploc%)?(?<case>capital%|lowercase%)?(?<drop2>droploc%)?
48
+ (?<fn>fn(:\s*(?<text>.*))?)?$/x.match node.text
49
+ casing = m.nil? ? nil : m[:case]&.sub(/%$/, "")
50
+ droploc = m.nil? ? nil : ((m[:drop].nil? && m[:drop2].nil?) ? nil: true)
51
+ f = (m.nil? || m[:fn].nil?) ? "inline" : "footnote"
52
+ c = (!m.nil? && (%i[case fn drop drop2].any? { |x| !m[x].nil? })) ?
53
+ m[:text] : node.text
54
+ t = node.target.gsub(/^#/, "").gsub(%r{(\.xml|\.adoc)(#.*$)}, "\\2")
55
+ { target: t, type: f, case: casing, droploc: droploc, text: c }
56
+ end
57
+
48
58
  def inline_anchor_link(node)
49
59
  contents = node.text
50
60
  contents = "" if node.target.gsub(%r{^mailto:}, "") == node.text
@@ -106,40 +116,8 @@ module Asciidoctor
106
116
  HTMLEntities.new.encode(text, :basic, :hexadecimal).
107
117
  gsub(/&amp;gt;/, ">").gsub(/\&amp;lt;/, "<").gsub(/&amp;amp;/, "&").
108
118
  gsub(/&gt;/, ">").gsub(/&lt;/, "<").gsub(/&amp;/, "&").
109
- gsub(/&quot;/, '"').gsub(/&#xa;/, "\n")
110
- end
111
-
112
- =begin
113
- def latex_run1(lxm_input, cmd)
114
- IO.popen(cmd, "r+", external_encoding: "UTF-8") do |io|
115
- io.write(lxm_input)
116
- io.close_write
117
- io.read
118
- end
119
- end
120
-
121
- def latex_run(lxm_input)
122
- results = nil
123
- Metanorma::Standoc::Requirements[:latexml].cmd.each_with_index do |cmd, i|
124
- warn "Retrying with #{cmd}" if i > 0
125
- results = latex_run1(lxm_input, cmd)
126
- if $CHILD_STATUS.to_i.zero?
127
- warn "Success!" if i > 0
128
- break
129
- end
130
- end
131
- $CHILD_STATUS.to_i.zero? ? results : nil
132
- end
133
-
134
- def latex_parse(text)
135
- lxm_input = Unicode2LaTeX.unicode2latex(HTMLEntities.new.decode(text))
136
- results = latex_run(lxm_input)
137
- results.nil? and
138
- @log.add('Math', nil,
139
- "latexmlmath failed to process equation:\n#{lxm_input}")
140
- results&.sub(%r{<math ([^>]+ )?display="block"}, "<math \\1")
119
+ gsub(/&quot;/, '"').gsub(/&#xa;/, "\n").gsub(/&amp;#/, "&#")
141
120
  end
142
- =end
143
121
 
144
122
  def latex_parse(text)
145
123
  lxm_input = Unicode2LaTeX.unicode2latex(HTMLEntities.new.decode(text))
@@ -163,7 +141,7 @@ module Asciidoctor
163
141
  s.parent.children = math
164
142
  end
165
143
  else
166
- xml.stem text, **{ type: "AsciiMath" }
144
+ xml.stem text&.gsub(/\&amp;#/, "&#"), **{ type: "AsciiMath" }
167
145
  end
168
146
  end
169
147
 
@@ -64,6 +64,11 @@
64
64
  </choice>
65
65
  </attribute>
66
66
  </optional>
67
+ <optional>
68
+ <attribute name="droploc">
69
+ <data type="boolean"/>
70
+ </attribute>
71
+ </optional>
67
72
  <text/>
68
73
  </element>
69
74
  </define>
@@ -859,6 +864,13 @@
859
864
  </define>
860
865
  <define name="standard-document">
861
866
  <element name="standard-document">
867
+ <attribute name="version"/>
868
+ <attribute name="type">
869
+ <choice>
870
+ <value>semantic</value>
871
+ <value>presentation</value>
872
+ </choice>
873
+ </attribute>
862
874
  <ref name="bibdata"/>
863
875
  <optional>
864
876
  <ref name="boilerplate"/>
@@ -880,7 +892,7 @@
880
892
  <oneOrMore>
881
893
  <choice>
882
894
  <ref name="content"/>
883
- <ref name="preface_abstract"/>
895
+ <ref name="abstract"/>
884
896
  <ref name="foreword"/>
885
897
  <ref name="introduction"/>
886
898
  <ref name="acknowledgements"/>
@@ -1481,11 +1493,6 @@
1481
1493
  </optional>
1482
1494
  </element>
1483
1495
  </define>
1484
- <define name="preface_abstract">
1485
- <element name="abstract">
1486
- <ref name="Basic-Section"/>
1487
- </element>
1488
- </define>
1489
1496
  <define name="term-clause">
1490
1497
  <element name="clause">
1491
1498
  <optional>
@@ -36,7 +36,8 @@ module Asciidoctor
36
36
  protected
37
37
 
38
38
  def content_from_file(document, file_path)
39
- JSON.parse(File.read(relative_file_path(document, file_path)))
39
+ JSON.parse(File.read(relative_file_path(document, file_path),
40
+ encoding: "UTF-8"))
40
41
  end
41
42
  end
42
43
  end
@@ -42,8 +42,7 @@ module Asciidoctor
42
42
 
43
43
  def docid(t, code)
44
44
  type, code1 = /^\[\d+\]$|^\([^)]+\).*$/.match(code) ?
45
- ["metanorma", mn_code(code)] :
46
- @bibdb&.docid_type(code) || [nil, code]
45
+ ["metanorma", mn_code(code)] : @bibdb&.docid_type(code) || [nil, code]
47
46
  code1.sub!(/^nofetch\((.+)\)$/, "\\1")
48
47
  t.docidentifier **attr_code(type: type) do |d|
49
48
  d << code1
@@ -84,6 +83,10 @@ module Asciidoctor
84
83
  ref = fetch_ref xml, m[:code], nil, no_year: true, note: m[:fn],
85
84
  title: m[:text], usrlbl: m[:usrlbl]
86
85
  return use_my_anchor(ref, m[:anchor]) if ref
86
+ isorefmatches2_1(xml, m)
87
+ end
88
+
89
+ def isorefmatches2_1(xml, m)
87
90
  xml.bibitem **attr_code(ref_attributes(m)) do |t|
88
91
  isorefrender1(t, m, "--")
89
92
  t.date **{ type: "published" } do |d|
@@ -106,13 +109,14 @@ module Asciidoctor
106
109
 
107
110
  def isorefmatches3(xml, m)
108
111
  yr = norm_year(m[:year])
109
- #hasyr = m.names.include?("year") && yr != "--"
110
112
  hasyr = !yr.nil? && yr != "--"
111
- #noyr = m.names.include?("year") && yr == "--"
112
113
  ref = fetch_ref xml, m[:code], hasyr ? yr : nil, all_parts: true,
113
114
  no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl]
114
115
  return use_my_anchor(ref, m[:anchor]) if ref
116
+ isorefmatches3_1(xml, m, yr, hasyr, ref)
117
+ end
115
118
 
119
+ def isorefmatches3_1(xml, m, yr, hasyr, ref)
116
120
  xml.bibitem(**attr_code(ref_attributes(m))) do |t|
117
121
  isorefrender1(t, m, yr, " (all parts)")
118
122
  conditional_date(t, m, yr == "--")
@@ -147,30 +151,24 @@ module Asciidoctor
147
151
  end
148
152
 
149
153
  MALFORMED_REF = "no anchor on reference, markup may be malformed: see "\
150
- "https://www.metanorma.com/author/topics/document-format/bibliography/ , "\
151
- "https://www.metanorma.com/author/iso/topics/markup/#bibliographies".freeze
154
+ "https://www.metanorma.com/author/topics/document-format/"\
155
+ "bibliography/ , https://www.metanorma.com/author/iso/topics/markup/"\
156
+ "#bibliographies".freeze
152
157
 
153
158
  def analyse_ref_nofetch(ret)
154
159
  return ret unless m = /^nofetch\((?<id>.+)\)$/.match(ret[:id])
155
- ret[:id] = m[:id]
156
- ret[:nofetch] = true
157
- ret
160
+ ret.merge(id: m[:id], nofetch: true)
158
161
  end
159
162
 
160
163
  def analyse_ref_repo_path(ret)
161
164
  return ret unless m =
162
165
  /^(?<type>repo|path):\((?<key>[^,]+),(?<id>.+)\)$/.match(ret[:id])
163
- ret[:id] = m[:id]
164
- ret[:type] = m[:type]
165
- ret[:key] = m[:key]
166
- ret[:nofetch] = true
167
- ret
166
+ ret.merge(id: m[:id], type: m[:type], key: m[:key], nofetch: true)
168
167
  end
169
168
 
170
169
  def analyse_ref_numeric(ret)
171
170
  return ret unless /^\d+$/.match(ret[:id])
172
- ret[:numeric] = true
173
- ret
171
+ ret.merge(numeric: true)
174
172
  end
175
173
 
176
174
  # ref id = (usrlbl)code[:-]year
@@ -178,10 +176,7 @@ module Asciidoctor
178
176
  def analyse_ref_code(code)
179
177
  ret = {id: code}
180
178
  return ret if code.nil? || code.empty?
181
- ret = analyse_ref_nofetch(ret)
182
- ret = analyse_ref_repo_path(ret)
183
- ret = analyse_ref_numeric(ret)
184
- ret
179
+ analyse_ref_nofetch(analyse_ref_repo_path(analyse_ref_numeric(ret)))
185
180
  end
186
181
 
187
182
  # TODO: alternative where only title is available
@@ -190,6 +185,10 @@ module Asciidoctor
190
185
  @log.add("AsciiDoc Input", node, "#{MALFORMED_REF}: #{item}")
191
186
  return
192
187
  end
188
+ refitem1(xml, item, m)
189
+ end
190
+
191
+ def refitem1(xml, item, m)
193
192
  code = analyse_ref_code(m[:code])
194
193
  unless code[:id] && code[:numeric] || code[:nofetch]
195
194
  ref = fetch_ref xml, code[:id],
@@ -214,23 +213,25 @@ module Asciidoctor
214
213
  (?<text>.*)$}xm
215
214
 
216
215
  ISO_REF_NO_YEAR = %r{^<ref\sid="(?<anchor>[^"]+)">
217
- \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):(--|\&\#821[12]\;)\]</ref>,?\s*
216
+ \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):
217
+ (--|\&\#821[12]\;)\]</ref>,?\s*
218
218
  (<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>)?,?\s?(?<text>.*)$}xm
219
219
 
220
220
  ISO_REF_ALL_PARTS = %r{^<ref\sid="(?<anchor>[^"]+)">
221
- \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9]+)(:(?<year>--|\&\#821[12]\;|[0-9][0-9-]+))?\s
221
+ \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9]+)
222
+ (:(?<year>--|\&\#821[12]\;|[0-9][0-9-]+))?\s
222
223
  \(all\sparts\)\]</ref>,?\s*
223
224
  (<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>,?\s?)?(?<text>.*)$}xm
224
225
 
225
226
  NON_ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
226
- \[(?<usrlbl>\([^)]+\))?(?<code>[^\]]+?)([:-](?<year>(19|20)[0-9][0-9]))?\]</ref>,?\s*
227
- (?<text>.*)$}xm
228
-
229
- def reference1_matches(item)
230
- matched = ISO_REF.match item
231
- matched2 = ISO_REF_NO_YEAR.match item
232
- matched3 = ISO_REF_ALL_PARTS.match item
233
- [matched, matched2, matched3]
227
+ \[(?<usrlbl>\([^)]+\))?(?<code>[^\]]+?)
228
+ ([:-](?<year>(19|20)[0-9][0-9]))?\]</ref>,?\s*(?<text>.*)$}xm
229
+
230
+ def reference1_matches(item)
231
+ matched = ISO_REF.match item
232
+ matched2 = ISO_REF_NO_YEAR.match item
233
+ matched3 = ISO_REF_ALL_PARTS.match item
234
+ [matched, matched2, matched3]
234
235
  end
235
236
 
236
237
  def reference1(node, item, xml)