metanorma-standoc 1.10.1 → 1.10.4

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 (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor/standoc/cleanup.rb +61 -0
  3. data/lib/asciidoctor/standoc/converter.rb +4 -0
  4. data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +22 -21
  5. data/lib/asciidoctor/standoc/isodoc.rng +12 -0
  6. data/lib/asciidoctor/standoc/macros.rb +18 -0
  7. data/lib/asciidoctor/standoc/ref.rb +60 -56
  8. data/lib/asciidoctor/standoc/reqt.rb +39 -27
  9. data/lib/asciidoctor/standoc/reqt.rng +7 -0
  10. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +1 -1
  11. data/lib/asciidoctor/standoc/validate_section.rb +2 -1
  12. data/lib/metanorma/standoc/version.rb +1 -1
  13. data/metanorma-standoc.gemspec +1 -1
  14. data/spec/asciidoctor/blocks_spec.rb +45 -25
  15. data/spec/asciidoctor/cleanup_sections_spec.rb +899 -864
  16. data/spec/asciidoctor/cleanup_spec.rb +56 -6
  17. data/spec/asciidoctor/macros_plantuml_spec.rb +165 -104
  18. data/spec/asciidoctor/macros_spec.rb +277 -0
  19. data/spec/fixtures/datamodel_description_sections_tree.xml +327 -0
  20. data/spec/fixtures/test.xmi +9250 -0
  21. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +34 -34
  22. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +50 -50
  23. data/spec/vcr_cassettes/isobib_get_123.yml +11 -11
  24. data/spec/vcr_cassettes/isobib_get_123_1.yml +23 -23
  25. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
  26. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  27. data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
  28. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  29. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
  30. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5a985aefd39dadc19549ad39c23e0849bac873ea5883e50762ca911c8bd3aad
4
- data.tar.gz: b7560f906a1e50fc4032f3261a44d1edcb2e691872b3e85d14a0363d7668b575
3
+ metadata.gz: 69e06ff811f3411ddd5ddccb1bfd52b82c92b49e1458d781fcfffac4397c1062
4
+ data.tar.gz: c600a5d9e17f3f271d176cefb5c6d3f860d887369efac0f2ad03ec5bf78b01a7
5
5
  SHA512:
6
- metadata.gz: 437c04558d97c828a200ca21668a0e74e7e9fe5b5581ab759955f9ada241a0a87ccfddf114b7bd616430107e5869ce785c547715d627a08b87e35a30237b0516
7
- data.tar.gz: 11d70602d2bd7733e9daab869ec22e3bf58ff6397378b38734711d46cb8f6e04b25e5b5fbcd3b5cd1e36b8e58a1061c92a87502fab945ea8a8c573205e25b126
6
+ metadata.gz: 785c49c3ef49c5bdc393f1f10f44fb2cf3a59e10583b08f1b40ecf282ebe015b1b98a0c9d8f3c796c81d2495e7e1273ba28d15b5a6ad4c6b543dbbe42dbae47f
7
+ data.tar.gz: a55c32649ba87a57dd417802ea70f91efbbae57dc786b294cc08704fbfce0b2ecf03a90827578a7bcc7c138402f0cb87992309fe3aa6397702a400a426cb5640
@@ -62,6 +62,7 @@ module Asciidoctor
62
62
  bibdata_cleanup(xmldoc)
63
63
  svgmap_cleanup(xmldoc)
64
64
  boilerplate_cleanup(xmldoc)
65
+ toc_cleanup(xmldoc)
65
66
  smartquotes_cleanup(xmldoc)
66
67
  variant_cleanup(xmldoc)
67
68
  para_cleanup(xmldoc)
@@ -84,6 +85,30 @@ module Asciidoctor
84
85
  end
85
86
 
86
87
  def smartquotes_cleanup1(xmldoc)
88
+ uninterrupt_quotes_around_xml(xmldoc)
89
+ dumb2smart_quotes(xmldoc)
90
+ end
91
+
92
+ # "abc<tag/>", def => "abc",<tag/> def
93
+ def uninterrupt_quotes_around_xml(xmldoc)
94
+ xmldoc.xpath("//*[following::text()[1]"\
95
+ "[starts-with(., '\"') or starts-with(., \"'\")]]")
96
+ .each do |x|
97
+ next if !x.ancestors("pre, tt, sourcecode, stem, figure").empty?
98
+ uninterrupt_quotes_around_xml1(x)
99
+ end
100
+ end
101
+
102
+ def uninterrupt_quotes_around_xml1(elem)
103
+ prev = elem.at(".//preceding::text()[1]") or return
104
+ /\S$/.match?(prev.text) or return
105
+ foll = elem.at(".//following::text()[1]")
106
+ m = /^(["'][[:punct:]]*)(\s|$)/.match(HTMLEntities.new.decode(foll&.text)) or return
107
+ foll.content = foll.text.sub(/^(["'][[:punct:]]*)/, "")
108
+ prev.content = "#{prev.text}#{m[1]}"
109
+ end
110
+
111
+ def dumb2smart_quotes(xmldoc)
87
112
  (xmldoc.xpath("//*[child::text()]") - xmldoc.xpath(IGNORE_DUMBQUOTES))
88
113
  .each do |x|
89
114
  x.children.each do |n|
@@ -166,6 +191,42 @@ module Asciidoctor
166
191
  end
167
192
  end
168
193
  end
194
+
195
+ def toc_cleanup(xmldoc)
196
+ xmldoc.xpath("//p[toc]").each do |x|
197
+ x.xpath("./toc").reverse.each do |t|
198
+ x.next = t
199
+ end
200
+ x.remove if x.text.strip.empty?
201
+ end
202
+ xmldoc.xpath("//toc").each { |t| toc_cleanup1(t, xmldoc) }
203
+ end
204
+
205
+ def toc_index(toc, xmldoc)
206
+ depths = toc.xpath("./toc-xpath").each_with_object({}) do |x, m|
207
+ m[x.text] = x["depth"]
208
+ end
209
+ depths.keys.each_with_object([]) do |key, arr|
210
+ xmldoc.xpath(key).each do |x|
211
+ arr << { text: x.children.to_xml, depth: depths[key].to_i,
212
+ target: x.xpath("(./ancestor-or-self::*/@id)[last()]")[0].text,
213
+ line: x.line }
214
+ end
215
+ end.sort_by { |a| a[:line] }
216
+ end
217
+
218
+ def toc_cleanup1(toc, xmldoc)
219
+ depth = 1
220
+ ret = ""
221
+ toc_index(toc, xmldoc).each do |x|
222
+ if depth > x[:depth] then ret += "</ul></li>" * (depth - x[:depth])
223
+ elsif depth < x[:depth] then ret += "<li><ul>" * (x[:depth] - depth)
224
+ end
225
+ ret += "<li><xref target='#{x[:target]}'>#{x[:text]}</xref></li>"
226
+ depth = x[:depth]
227
+ end
228
+ toc.children = "<ul>#{ret}</ul>"
229
+ end
169
230
  end
170
231
  end
171
232
  end
@@ -27,6 +27,7 @@ module Asciidoctor
27
27
  preprocessor Metanorma::Plugin::Datastruct::Yaml2TextPreprocessor
28
28
  preprocessor Metanorma::Plugin::Lutaml::LutamlPreprocessor
29
29
  preprocessor Metanorma::Plugin::Lutaml::LutamlUmlAttributesTablePreprocessor
30
+ preprocessor Metanorma::Plugin::Lutaml::LutamlUmlDatamodelDescriptionPreprocessor
30
31
  inline_macro Asciidoctor::Standoc::AltTermInlineMacro
31
32
  inline_macro Asciidoctor::Standoc::DeprecatedTermInlineMacro
32
33
  inline_macro Asciidoctor::Standoc::DomainTermInlineMacro
@@ -47,6 +48,9 @@ module Asciidoctor
47
48
  inline_macro Asciidoctor::Standoc::FormTextareaMacro
48
49
  inline_macro Asciidoctor::Standoc::FormSelectMacro
49
50
  inline_macro Asciidoctor::Standoc::FormOptionMacro
51
+ inline_macro Asciidoctor::Standoc::ToCInlineMacro
52
+ inline_macro Metanorma::Plugin::Lutaml::LutamlFigureInlineMacro
53
+ block_macro Metanorma::Plugin::Lutaml::LutamlDiagramBlockMacro
50
54
  block Asciidoctor::Standoc::ToDoAdmonitionBlock
51
55
  treeprocessor Asciidoctor::Standoc::ToDoInlineAdmonitionBlock
52
56
  block Asciidoctor::Standoc::PlantUMLBlockMacro
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'erb'
4
- require 'asciidoctor/standoc/datamodel/plantuml_renderer'
3
+ require "erb"
4
+ require "asciidoctor/standoc/datamodel/plantuml_renderer"
5
5
 
6
6
  module Asciidoctor
7
7
  module Standoc
8
8
  module Datamodel
9
9
  class DiagramPreprocessor < Asciidoctor::Extensions::Preprocessor
10
- BLOCK_START_REGEXP = /\{(.+?)\.\*,(.+),(.+)\}/
11
- BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z/
12
- MARCO_REGEXP = /\[datamodel_diagram,([^,]+),?(.+)?\]/
13
- TEMPLATES_PATH = File.expand_path('../views/datamodel', __dir__).freeze
10
+ BLOCK_START_REGEXP = /\{(.+?)\.\*,(.+),(.+)\}/.freeze
11
+ BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z/.freeze
12
+ MARCO_REGEXP = /\[datamodel_diagram,([^,]+),?(.+)?\]/.freeze
13
+ TEMPLATES_PATH = File.expand_path("../views/datamodel", __dir__).freeze
14
14
  # search document for block `datamodel_diagram`
15
15
  # read include derectives that goes after that in block and transform
16
16
  # into plantuml block
@@ -33,7 +33,7 @@ module Asciidoctor
33
33
  end
34
34
 
35
35
  def parse_datamodel_marco(yaml_path, include_path, document)
36
- include_path ||= File.join(File.dirname(yaml_path), '..', 'models')
36
+ include_path ||= File.join(File.dirname(yaml_path), "..", "models")
37
37
  include_path = yaml_relative_path(include_path, document)
38
38
  yaml_relative_to_doc_path = yaml_relative_path(yaml_path, document)
39
39
  view_hash = YAML.safe_load(File.read(yaml_relative_to_doc_path))
@@ -43,7 +43,7 @@ module Asciidoctor
43
43
  end
44
44
 
45
45
  def yaml_relative_path(file_path, document)
46
- docfile = document.attributes['docfile'] || '.'
46
+ docfile = document.attributes["docfile"] || "."
47
47
  docfile_directory = File.dirname(docfile)
48
48
  document.path_resolver.system_path(file_path, docfile_directory)
49
49
  end
@@ -51,11 +51,11 @@ module Asciidoctor
51
51
  def import_format(include_path, import_name, values)
52
52
  include_content = File.read(File.join(
53
53
  include_path,
54
- "#{import_name}.yml"
55
- ))
54
+ "#{import_name}.yml",
55
+ ))
56
56
  content = YAML.safe_load(include_content)
57
57
  if values
58
- content['skipSection'] = values['skipSection']
58
+ content["skipSection"] = values["skipSection"]
59
59
  end
60
60
  content
61
61
  end
@@ -63,36 +63,37 @@ module Asciidoctor
63
63
  def format_import_directives(imports, include_path)
64
64
  imports
65
65
  .each_with_object({}) do |(import_name, values), res|
66
- full_model_name = import_name.split('/').join
66
+ full_model_name = import_name.split("/").join
67
67
  content = import_format(include_path, import_name, values)
68
- res[content['name'] || full_model_name] = content
68
+ res[content["name"] || full_model_name] = content
69
69
  end.compact
70
70
  end
71
71
 
72
72
  def prepare_view_hash(view_hash, all_imports)
73
73
  view_hash.merge!(
74
- 'classes' => model_type(all_imports, 'class'),
75
- 'enums' => model_type(all_imports, 'enum'),
76
- 'relations' => view_hash['relations'] || [],
77
- 'fidelity' => (view_hash['fidelity'] || {})
78
- .merge!('classes' => model_type(all_imports, 'class'))
74
+ "classes" => model_type(all_imports, "class"),
75
+ "enums" => model_type(all_imports, "enum"),
76
+ "relations" => view_hash["relations"] || [],
77
+ "fidelity" => (view_hash["fidelity"] || {})
78
+ .merge!("classes" => model_type(all_imports,
79
+ "class")),
79
80
  )
80
81
  end
81
82
 
82
83
  def model_type(imports, type)
83
84
  imports
84
85
  .select do |_name, elem|
85
- elem['modelType'] == type
86
+ elem["modelType"] == type
86
87
  end
87
88
  end
88
89
 
89
90
  def plantuml_representations(view_hash, view_path, include_path)
90
91
  yaml_directory = File.dirname(view_path)
91
- all_imports = format_import_directives(view_hash['imports'],
92
+ all_imports = format_import_directives(view_hash["imports"],
92
93
  include_path)
93
94
  prepare_view_hash(view_hash, all_imports)
94
95
  Asciidoctor::Datamodel::PlantumlRenderer
95
- .new(view_hash, File.join(yaml_directory, '..'))
96
+ .new(view_hash, File.join(yaml_directory, ".."))
96
97
  .render
97
98
  .split("\n")
98
99
  end
@@ -1011,8 +1011,14 @@
1011
1011
  <ref name="imagemap"/>
1012
1012
  <ref name="svgmap"/>
1013
1013
  <ref name="inputform"/>
1014
+ <ref name="toc"/>
1014
1015
  </choice>
1015
1016
  </define>
1017
+ <define name="toc">
1018
+ <element name="toc">
1019
+ <ref name="ul"/>
1020
+ </element>
1021
+ </define>
1016
1022
  <define name="inputform">
1017
1023
  <element name="form">
1018
1024
  <attribute name="id">
@@ -1254,6 +1260,12 @@
1254
1260
  <optional>
1255
1261
  <attribute name="type"/>
1256
1262
  </optional>
1263
+ <optional>
1264
+ <attribute name="identifier"/>
1265
+ </optional>
1266
+ <optional>
1267
+ <attribute name="prefix"/>
1268
+ </optional>
1257
1269
  <text/>
1258
1270
  </define>
1259
1271
  <define name="ics">
@@ -2,6 +2,7 @@ require "asciidoctor/extensions"
2
2
  require "fileutils"
3
3
  require "uuidtools"
4
4
  require "yaml"
5
+ require "csv"
5
6
  require_relative "./macros_plantuml"
6
7
  require_relative "./macros_terms"
7
8
  require_relative "./macros_form"
@@ -211,5 +212,22 @@ module Asciidoctor
211
212
  %{<del>#{out}</del>}
212
213
  end
213
214
  end
215
+
216
+ class ToCInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
217
+ use_dsl
218
+ named :toc
219
+ parse_content_as :text
220
+ using_format :short
221
+
222
+ def process(parent, _target, attrs)
223
+ out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
224
+ content = CSV.parse_line(out).map do |x|
225
+ x.sub!(/^(["'])(.+)\1/, "\\2")
226
+ m = /^(.*?)(:\d+)?$/.match(x)
227
+ %{<toc-xpath depth='#{m[2]&.sub(/:/, '') || 1}'>#{m[1]}</toc-xpath>}
228
+ end.join
229
+ "<toc>#{content}</toc>"
230
+ end
231
+ end
214
232
  end
215
233
  end
@@ -4,7 +4,7 @@ module Asciidoctor
4
4
  module Standoc
5
5
  module Refs
6
6
  def iso_publisher(bib, code)
7
- code.sub(/ .*$/, "").split(/\//).each do |abbrev|
7
+ code.sub(/ .*$/, "").split("/").each do |abbrev|
8
8
  bib.contributor do |c|
9
9
  c.role **{ type: "publisher" }
10
10
  c.organization do |org|
@@ -18,75 +18,78 @@ module Asciidoctor
18
18
  { format: "text/plain" }
19
19
  end
20
20
 
21
- def ref_attributes(m)
22
- { id: m[:anchor], type: "standard" }
21
+ def ref_attributes(match)
22
+ { id: match[:anchor], type: "standard" }
23
23
  end
24
24
 
25
- def isorefrender1(bib, m, yr, allp = "")
26
- bib.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
27
- docid(bib, m[:usrlbl]) if m[:usrlbl]
28
- docid(bib, id_and_year(m[:code], yr) + allp)
29
- docnumber(bib, m[:code])
25
+ def isorefrender1(bib, match, yr, allp = "")
26
+ bib.title(**plaintxt) { |i| i << ref_normalise(match[:text]) }
27
+ docid(bib, match[:usrlbl]) if match[:usrlbl]
28
+ docid(bib, id_and_year(match[:code], yr) + allp)
29
+ docnumber(bib, match[:code])
30
30
  end
31
31
 
32
- def isorefmatches(xml, m)
33
- yr = norm_year(m[:year])
34
- ref = fetch_ref xml, m[:code], yr, title: m[:text], usrlbl: m[:usrlbl],
35
- lang: (@lang || :all)
36
- return use_my_anchor(ref, m[:anchor]) if ref
32
+ def isorefmatches(xml, match)
33
+ yr = norm_year(match[:year])
34
+ ref = fetch_ref xml, match[:code], yr,
35
+ title: match[:text], usrlbl: match[:usrlbl],
36
+ lang: (@lang || :all)
37
+ return use_my_anchor(ref, match[:anchor]) if ref
37
38
 
38
- xml.bibitem **attr_code(ref_attributes(m)) do |t|
39
- isorefrender1(t, m, yr)
39
+ xml.bibitem **attr_code(ref_attributes(match)) do |t|
40
+ isorefrender1(t, match, yr)
40
41
  yr and t.date **{ type: "published" } do |d|
41
42
  set_date_range(d, yr)
42
43
  end
43
- iso_publisher(t, m[:code])
44
+ iso_publisher(t, match[:code])
44
45
  end
45
46
  end
46
47
 
47
- def isorefmatches2(xml, m)
48
- ref = fetch_ref xml, m[:code], nil, no_year: true, note: m[:fn],
49
- title: m[:text], usrlbl: m[:usrlbl], lang: (@lang || :all)
50
- return use_my_anchor(ref, m[:anchor]) if ref
48
+ def isorefmatches2(xml, match)
49
+ ref = fetch_ref xml, match[:code], nil,
50
+ no_year: true, note: match[:fn],
51
+ title: match[:text], usrlbl: match[:usrlbl],
52
+ lang: (@lang || :all)
53
+ return use_my_anchor(ref, match[:anchor]) if ref
51
54
 
52
- isorefmatches2_1(xml, m)
55
+ isorefmatches2_1(xml, match)
53
56
  end
54
57
 
55
- def isorefmatches2_1(xml, m)
56
- xml.bibitem **attr_code(ref_attributes(m)) do |t|
57
- isorefrender1(t, m, "--")
58
+ def isorefmatches2_1(xml, match)
59
+ xml.bibitem **attr_code(ref_attributes(match)) do |t|
60
+ isorefrender1(t, match, "--")
58
61
  t.date **{ type: "published" } do |d|
59
62
  d.on "--"
60
63
  end
61
- iso_publisher(t, m[:code])
62
- unless m[:fn].nil?
64
+ iso_publisher(t, match[:code])
65
+ unless match[:fn].nil?
63
66
  t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
64
- p << (m[:fn]).to_s
67
+ p << (match[:fn]).to_s
65
68
  end
66
69
  end
67
70
  end
68
71
  end
69
72
 
70
- def isorefmatches3(xml, m)
71
- yr = norm_year(m[:year])
73
+ def isorefmatches3(xml, match)
74
+ yr = norm_year(match[:year])
72
75
  hasyr = !yr.nil? && yr != "--"
73
- ref = fetch_ref(xml, m[:code], hasyr ? yr : nil,
74
- all_parts: true,
75
- no_year: yr == "--", text: m[:text], usrlbl: m[:usrlbl],
76
+ ref = fetch_ref(xml, match[:code], hasyr ? yr : nil,
77
+ all_parts: true, no_year: yr == "--",
78
+ text: match[:text], usrlbl: match[:usrlbl],
76
79
  lang: (@lang || :all))
77
- return use_my_anchor(ref, m[:anchor]) if ref
80
+ return use_my_anchor(ref, match[:anchor]) if ref
78
81
 
79
- isorefmatches3_1(xml, m, yr, hasyr, ref)
82
+ isorefmatches3_1(xml, match, yr, hasyr, ref)
80
83
  end
81
84
 
82
- def isorefmatches3_1(xml, m, yr, _hasyr, _ref)
83
- xml.bibitem(**attr_code(ref_attributes(m))) do |t|
84
- isorefrender1(t, m, yr, " (all parts)")
85
- conditional_date(t, m, yr == "--")
86
- iso_publisher(t, m[:code])
87
- if m.names.include?("fn") && m[:fn]
85
+ def isorefmatches3_1(xml, match, yr, _hasyr, _ref)
86
+ xml.bibitem(**attr_code(ref_attributes(match))) do |t|
87
+ isorefrender1(t, match, yr, " (all parts)")
88
+ conditional_date(t, match, yr == "--")
89
+ iso_publisher(t, match[:code])
90
+ if match.names.include?("fn") && match[:fn]
88
91
  t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
89
- p << (m[:fn]).to_s
92
+ p << (match[:fn]).to_s
90
93
  end
91
94
  end
92
95
  t.extent **{ type: "part" } do |e|
@@ -95,23 +98,23 @@ module Asciidoctor
95
98
  end
96
99
  end
97
100
 
98
- def refitem_render1(m, code, bib)
101
+ def refitem_render1(match, code, bib)
99
102
  if code[:type] == "path"
100
103
  bib.uri code[:key].sub(/\.[a-zA-Z0-9]+$/, ""), **{ type: "URI" }
101
104
  bib.uri code[:key].sub(/\.[a-zA-Z0-9]+$/, ""), **{ type: "citation" }
102
105
  end
103
- docid(bib, m[:usrlbl]) if m[:usrlbl]
106
+ docid(bib, match[:usrlbl]) if match[:usrlbl]
104
107
  docid(bib, /^\d+$/.match?(code[:id]) ? "[#{code[:id]}]" : code[:id])
105
108
  code[:type] == "repo" and
106
109
  bib.docidentifier code[:key], **{ type: "repository" }
107
110
  end
108
111
 
109
- def refitem_render(xml, m, code)
110
- xml.bibitem **attr_code(id: m[:anchor]) do |t|
112
+ def refitem_render(xml, match, code)
113
+ xml.bibitem **attr_code(id: match[:anchor]) do |t|
111
114
  t.formattedref **{ format: "application/x-isodoc+xml" } do |i|
112
- i << ref_normalise_no_format(m[:text])
115
+ i << ref_normalise_no_format(match[:text])
113
116
  end
114
- refitem_render1(m, code, t)
117
+ refitem_render1(match, code, t)
115
118
  docnumber(t, code[:id]) unless /^\d+$|^\(.+\)$/.match?(code[:id])
116
119
  end
117
120
  end
@@ -128,7 +131,7 @@ module Asciidoctor
128
131
 
129
132
  def analyse_ref_repo_path(ret)
130
133
  return ret unless m =
131
- /^(?<type>repo|path):\((?<key>[^,]+),?(?<id>.*)\)$/.match(ret[:id])
134
+ /^(?<type>repo|path):\((?<key>[^,]+),?(?<id>.*)\)$/.match(ret[:id])
132
135
 
133
136
  id = m[:id].empty? ? m[:key].sub(%r{^[^/]+/}, "") : m[:id]
134
137
  ret.merge(id: id, type: m[:type], key: m[:key], nofetch: true)
@@ -156,16 +159,17 @@ module Asciidoctor
156
159
  nil
157
160
  end
158
161
 
159
- def refitem1(xml, _item, m)
160
- code = analyse_ref_code(m[:code])
162
+ def refitem1(xml, _item, match)
163
+ code = analyse_ref_code(match[:code])
161
164
  unless code[:id] && code[:numeric] || code[:nofetch]
162
165
  ref = fetch_ref(xml, code[:id],
163
- m.names.include?("year") ? m[:year] : nil,
164
- title: m[:text],
165
- usrlbl: m[:usrlbl], lang: (@lang || :all))
166
- return use_my_anchor(ref, m[:anchor]) if ref
166
+ match.names.include?("year") ? match[:year] : nil,
167
+ title: match[:text],
168
+ usrlbl: match[:usrlbl], lang: (@lang || :all)) and
169
+ return use_my_anchor(ref, match[:anchor])
167
170
  end
168
- refitem_render(xml, m, code)
171
+
172
+ refitem_render(xml, match, code)
169
173
  end
170
174
 
171
175
  def ref_normalise(ref)
@@ -186,7 +190,7 @@ module Asciidoctor
186
190
  \[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):
187
191
  (--|&\#821[12];)\]</ref>,?\s*
188
192
  (<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>)?,?\s?(?<text>.*)$}xm
189
- .freeze
193
+ .freeze
190
194
 
191
195
  ISO_REF_ALL_PARTS =
192
196
  %r{^<ref\sid="(?<anchor>[^"]+)">