metanorma-standoc 1.3.26 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +8 -0
  3. data/.github/workflows/ubuntu.yml +8 -0
  4. data/.github/workflows/windows.yml +8 -0
  5. data/.gitignore +1 -0
  6. data/lib/asciidoctor/standoc/base.rb +12 -31
  7. data/lib/asciidoctor/standoc/biblio.rng +36 -6
  8. data/lib/asciidoctor/standoc/blocks.rb +36 -96
  9. data/lib/asciidoctor/standoc/blocks_notes.rb +89 -0
  10. data/lib/asciidoctor/standoc/cleanup.rb +21 -7
  11. data/lib/asciidoctor/standoc/cleanup_block.rb +5 -2
  12. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +1 -3
  13. data/lib/asciidoctor/standoc/cleanup_inline.rb +1 -1
  14. data/lib/asciidoctor/standoc/cleanup_ref.rb +56 -6
  15. data/lib/asciidoctor/standoc/cleanup_section.rb +23 -127
  16. data/lib/asciidoctor/standoc/cleanup_terms.rb +134 -0
  17. data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +57 -0
  18. data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +102 -0
  19. data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +408 -0
  20. data/lib/asciidoctor/standoc/inline.rb +11 -6
  21. data/lib/asciidoctor/standoc/isodoc.rng +450 -4
  22. data/lib/asciidoctor/standoc/lists.rb +12 -12
  23. data/lib/asciidoctor/standoc/macros.rb +13 -8
  24. data/lib/asciidoctor/standoc/macros_yaml2text.rb +44 -21
  25. data/lib/asciidoctor/standoc/ref.rb +79 -80
  26. data/lib/asciidoctor/standoc/ref_sect.rb +124 -0
  27. data/lib/asciidoctor/standoc/reqt.rb +11 -6
  28. data/lib/asciidoctor/standoc/reqt.rng +23 -0
  29. data/lib/asciidoctor/standoc/section.rb +21 -38
  30. data/lib/asciidoctor/standoc/table.rb +3 -2
  31. data/lib/asciidoctor/standoc/validate.rb +8 -2
  32. data/lib/asciidoctor/standoc/validate_section.rb +1 -3
  33. data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +30 -0
  34. data/lib/asciidoctor/standoc/views/datamodel/plantuml_representation.adoc.erb +20 -0
  35. data/lib/metanorma/standoc/version.rb +1 -1
  36. data/metanorma-standoc.gemspec +1 -1
  37. data/spec/asciidoctor-standoc/blocks_spec.rb +68 -22
  38. data/spec/asciidoctor-standoc/cleanup_spec.rb +101 -27
  39. data/spec/asciidoctor-standoc/datamodel/attributes_table_preprocessor_spec.rb +111 -0
  40. data/spec/asciidoctor-standoc/datamodel/diagram_preprocessor_spec.rb +72 -0
  41. data/spec/asciidoctor-standoc/inline_spec.rb +6 -2
  42. data/spec/asciidoctor-standoc/lists_spec.rb +7 -5
  43. data/spec/asciidoctor-standoc/macros_spec.rb +56 -4
  44. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +2 -1
  45. data/spec/asciidoctor-standoc/refs_dl_spec.rb +91 -3
  46. data/spec/asciidoctor-standoc/refs_spec.rb +283 -24
  47. data/spec/asciidoctor-standoc/section_spec.rb +139 -6
  48. data/spec/asciidoctor-standoc/table_spec.rb +2 -2
  49. data/spec/asciidoctor-standoc/validate_spec.rb +89 -2
  50. data/spec/assets/iso123.rxl +107 -0
  51. data/spec/assets/xref_error.adoc +7 -0
  52. data/spec/examples/datamodel/address_class_profile.adoc +4 -0
  53. data/spec/examples/datamodel/address_component_profile.adoc +4 -0
  54. data/spec/examples/datamodel/blank_definition_profile.adoc +4 -0
  55. data/spec/examples/datamodel/common_models_diagram.adoc +4 -0
  56. data/spec/examples/datamodel/models/models/AddressClassProfile.yml +90 -0
  57. data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +63 -0
  58. data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +15 -0
  59. data/spec/examples/datamodel/models/models/AddressProfile.yml +36 -0
  60. data/spec/examples/datamodel/models/models/AttributeProfile.yml +32 -0
  61. data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +79 -0
  62. data/spec/examples/datamodel/models/models/Localization copy.yml +23 -0
  63. data/spec/examples/datamodel/models/models/Localization.yml +23 -0
  64. data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +36 -0
  65. data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +15 -0
  66. data/spec/examples/datamodel/models/models/Signature.yml +20 -0
  67. data/spec/examples/datamodel/models/models/SignatureBlankDefinition.yml +20 -0
  68. data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +16 -0
  69. data/spec/examples/datamodel/models/models/TextDirectionCode.yml +16 -0
  70. data/spec/examples/datamodel/models/models/Validity.yml +14 -0
  71. data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +22 -0
  72. data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +2 -0
  73. data/spec/examples/datamodel/models/style.uml.inc +37 -0
  74. data/spec/examples/datamodel/models/views/CommonModels.yml +9 -0
  75. data/spec/examples/datamodel/models/views/TopDown.yml +62 -0
  76. data/spec/examples/datamodel/top_down_diagram.adoc +4 -0
  77. data/spec/fixtures/macros_datamodel/address_class_profile.xml +149 -0
  78. data/spec/fixtures/macros_datamodel/address_component_profile.xml +71 -0
  79. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +51 -0
  80. data/spec/fixtures/macros_datamodel/common_models_diagram.xml +7 -0
  81. data/spec/fixtures/macros_datamodel/top_down_diagram.xml +7 -0
  82. data/spec/spec_helper.rb +13 -2
  83. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +65 -65
  84. data/spec/vcr_cassettes/isobib_get_123.yml +37 -37
  85. data/spec/vcr_cassettes/isobib_get_123_2001.yml +17 -17
  86. data/spec/vcr_cassettes/isobib_get_124.yml +16 -16
  87. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  88. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +40 -37
  89. metadata +46 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 775bf1c752d3200f542014ac45b50d4d71cf4f660a8c25e80cae21f234cbf219
4
- data.tar.gz: 50d5cdbbdf778a7a470c2e58bd9c1c6a46c0c7d522f7ac80c984511540ac0325
3
+ metadata.gz: ec38f1dc395a1d89eb57193772856d31e40e0d4e725f449884529f794a77c341
4
+ data.tar.gz: be6615f68c933d6028ef70aad058e4ec042d7ff5eabdf489c13abe7743aa1010
5
5
  SHA512:
6
- metadata.gz: 3d427d6d3525c635a5303b1f4ac2078bd789ada7268f8493c26e112f985ff249a4b9d74fe466d14177962132c7903a64162a52f41d8e439a5170e2c96e3b1380
7
- data.tar.gz: 7e052c9a72d6f530fd0de026012e3cfaed6813256ed7e979076af4da02fc05f04884e30fc69e27eb2246d721e200c6a4d368a19d1d32cd9c6344a9fbf3e6b7cf
6
+ metadata.gz: 425e48990782c8de5e70d18fb3404eebdfa9b7c0bf1e6e454e89451e4593266d80b87981162881eac9e17aa5dcf6f711e3f2c4c4d61141be15b396446163bb30
7
+ data.tar.gz: 4d534831af15ebdd19c9e81ea000a13022cd1ed2ff0e9c1bedab90a829cbb105dd454adfe72befedd3341d5a47ca6920925ea6de77266259f93a17f25287a62a
@@ -6,15 +6,23 @@ on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
+ paths-ignore:
10
+ - .github/workflows/ubuntu.yml
11
+ - .github/workflows/windows.yml
9
12
 
10
13
  jobs:
11
14
  test-macos:
12
15
  name: Test on Ruby ${{ matrix.ruby }} macOS
13
16
  runs-on: macos-latest
17
+ continue-on-error: ${{ matrix.experimental }}
14
18
  strategy:
15
19
  fail-fast: false
16
20
  matrix:
17
21
  ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
18
26
  steps:
19
27
  - uses: actions/checkout@master
20
28
  - name: Use Ruby
@@ -6,15 +6,23 @@ on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
+ paths-ignore:
10
+ - .github/workflows/macos.yml
11
+ - .github/workflows/windows.yml
9
12
 
10
13
  jobs:
11
14
  test-linux:
12
15
  name: Test on Ruby ${{ matrix.ruby }} Ubuntu
13
16
  runs-on: ubuntu-latest
17
+ continue-on-error: ${{ matrix.experimental }}
14
18
  strategy:
15
19
  fail-fast: false
16
20
  matrix:
17
21
  ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
18
26
  steps:
19
27
  - uses: actions/checkout@master
20
28
  - name: Use Ruby
@@ -6,15 +6,23 @@ on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
+ paths-ignore:
10
+ - .github/workflows/macos.yml
11
+ - .github/workflows/ubuntu.yml
9
12
 
10
13
  jobs:
11
14
  test-windows:
12
15
  name: Test on Ruby ${{ matrix.ruby }} Windows
13
16
  runs-on: windows-latest
17
+ continue-on-error: ${{ matrix.experimental }}
14
18
  strategy:
15
19
  fail-fast: false
16
20
  matrix:
17
21
  ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
18
26
  steps:
19
27
  - uses: actions/checkout@master
20
28
  - name: Use Ruby
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ spec/examples/rice.doc
9
9
  spec/examples/rice.html
10
10
  spec/examples/rice.xml
11
11
  spec/examples/rice_files/
12
+ Gemfile.lock
@@ -15,6 +15,8 @@ module Asciidoctor
15
15
  XML_NAMESPACE = "https://www.metanorma.org/ns/standoc".freeze
16
16
 
17
17
  Asciidoctor::Extensions.register do
18
+ preprocessor Asciidoctor::Standoc::Datamodel::AttributesTablePreprocessor
19
+ preprocessor Asciidoctor::Standoc::Datamodel::DiagramPreprocessor
18
20
  preprocessor Asciidoctor::Standoc::Yaml2TextPreprocessor
19
21
  inline_macro Asciidoctor::Standoc::AltTermInlineMacro
20
22
  inline_macro Asciidoctor::Standoc::DeprecatedTermInlineMacro
@@ -43,7 +45,7 @@ module Asciidoctor
43
45
  def skip(node, name = nil)
44
46
  name = name || node.node_name
45
47
  w = "converter missing for #{name} node in Metanorma backend"
46
- @log.add("Asciidoctor Input", node, w)
48
+ @log.add("AsciiDoc Input", node, w)
47
49
  nil
48
50
  end
49
51
 
@@ -109,7 +111,7 @@ module Asciidoctor
109
111
  @fontheader = default_fonts(node)
110
112
  @files_to_delete = []
111
113
  @filename = node.attr("docfile") ?
112
- node.attr("docfile").gsub(/\.adoc$/, "").gsub(%r{^.*/}, "") : ""
114
+ File.basename(node.attr("docfile")).gsub(/\.adoc$/, "") : ""
113
115
  @localdir = Utils::localdir(node)
114
116
  @no_isobib_cache = node.attr("no-isobib-cache")
115
117
  @no_isobib = node.attr("no-isobib")
@@ -125,31 +127,6 @@ module Asciidoctor
125
127
  i18n_init(lang, script)
126
128
  end
127
129
 
128
- def init_bib_caches(node)
129
- return if @no_isobib
130
- global = !@no_isobib_cache && !node.attr("local-cache-only")
131
- local = node.attr("local-cache") || node.attr("local-cache-only")
132
- local = nil if @no_isobib_cache
133
- @bibdb = Relaton::DbCache.init_bib_caches(
134
- local_cache: local,
135
- flush_caches: node.attr("flush-caches"),
136
- global_cache: global)
137
- end
138
-
139
- def init_iev_caches(node)
140
- unless (@no_isobib_cache || @no_isobib)
141
- node.attr("local-cache-only") or
142
- @iev_globalname = global_ievcache_name
143
- @iev_localname = local_ievcache_name(node.attr("local-cache") ||
144
- node.attr("local-cache-only"))
145
- if node.attr("flush-caches")
146
- FileUtils.rm_f @iev_globalname unless @iev_globalname.nil?
147
- FileUtils.rm_f @iev_localname unless @iev_localname.nil?
148
- end
149
- end
150
- #@iev = Iev::Db.new(globalname, localname) unless @no_isobib
151
- end
152
-
153
130
  def default_fonts(node)
154
131
  b = node.attr("body-font") ||
155
132
  (node.attr("script") == "Hans" ? '"SimSun",serif' :
@@ -169,9 +146,13 @@ module Asciidoctor
169
146
  html_converter(node).convert(@filename + ".xml")
170
147
  doc_converter(node).convert(@filename + ".xml")
171
148
  end
149
+ clean_exit
150
+ ret
151
+ end
152
+
153
+ def clean_exit
172
154
  @log.write(@localdir + @filename + ".err") unless @novalid
173
155
  @files_to_delete.each { |f| FileUtils.rm f }
174
- ret
175
156
  end
176
157
 
177
158
  def makexml1(node)
@@ -211,7 +192,7 @@ module Asciidoctor
211
192
  end
212
193
  end
213
194
 
214
- def term_source_attr(seen_xref)
195
+ def term_source_attrs(seen_xref)
215
196
  { bibitemid: seen_xref.children[0]["target"],
216
197
  format: seen_xref.children[0]["format"],
217
198
  type: "inline" }
@@ -222,7 +203,7 @@ module Asciidoctor
222
203
  xml_t.origin { |o| o << seen_xref.children[0].to_xml }
223
204
  else
224
205
  xml_t.origin seen_xref.children[0].content,
225
- **attr_code(term_source_attr(seen_xref))
206
+ **attr_code(term_source_attrs(seen_xref))
226
207
  end
227
208
  m[:text] && xml_t.modification do |mod|
228
209
  mod.p { |p| p << m[:text].sub(/^\s+/, "") }
@@ -241,7 +222,7 @@ module Asciidoctor
241
222
  def extract_termsource_refs(text, node)
242
223
  matched = TERM_REFERENCE_RE.match text
243
224
  matched.nil? and
244
- @log.add("Asciidoctor Input", node, "term reference not in expected format: #{text}")
225
+ @log.add("AsciiDoc Input", node, "term reference not in expected format: #{text}")
245
226
  matched
246
227
  end
247
228
 
@@ -88,7 +88,7 @@
88
88
  <text/>
89
89
  </element>
90
90
  </define>
91
- <define name="LocalizedString">
91
+ <define name="LocalizedString1">
92
92
  <optional>
93
93
  <!-- multiple languages and scripts possible: comma delimit them if so -->
94
94
  <attribute name="language"/>
@@ -98,6 +98,16 @@
98
98
  </optional>
99
99
  <text/>
100
100
  </define>
101
+ <define name="LocalizedString">
102
+ <choice>
103
+ <ref name="LocalizedString1"/>
104
+ <oneOrMore>
105
+ <element name="variant">
106
+ <ref name="LocalizedString1"/>
107
+ </element>
108
+ </oneOrMore>
109
+ </choice>
110
+ </define>
101
111
  <!--
102
112
  Unlike UML, change type to format: type is overloaded
103
113
  Would be need if plain were default value and could omit the attribute
@@ -121,7 +131,7 @@
121
131
  </optional>
122
132
  <ref name="LocalizedStringOrXsAny"/>
123
133
  </define>
124
- <define name="LocalizedStringOrXsAny">
134
+ <define name="LocalizedStringOrXsAny1">
125
135
  <optional>
126
136
  <!-- multiple languages and scripts possible: comma delimit them if so -->
127
137
  <attribute name="language"/>
@@ -136,6 +146,16 @@
136
146
  </choice>
137
147
  </oneOrMore>
138
148
  </define>
149
+ <define name="LocalizedStringOrXsAny">
150
+ <choice>
151
+ <ref name="LocalizedStringOrXsAny1"/>
152
+ <oneOrMore>
153
+ <element name="variant">
154
+ <ref name="LocalizedStringOrXsAny1"/>
155
+ </element>
156
+ </oneOrMore>
157
+ </choice>
158
+ </define>
139
159
  <define name="contributor">
140
160
  <element name="contributor">
141
161
  <zeroOrMore>
@@ -512,7 +532,7 @@
512
532
  </define>
513
533
  <define name="LocalityType">
514
534
  <data type="string">
515
- <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|locality:[a-zA-Z0-9_]+</param>
535
+ <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+</param>
516
536
  </data>
517
537
  </define>
518
538
  <define name="referenceFrom">
@@ -641,9 +661,9 @@
641
661
  <optional>
642
662
  <ref name="status"/>
643
663
  </optional>
644
- <optional>
664
+ <zeroOrMore>
645
665
  <ref name="copyright"/>
646
- </optional>
666
+ </zeroOrMore>
647
667
  <zeroOrMore>
648
668
  <ref name="docrelation"/>
649
669
  </zeroOrMore>
@@ -1001,7 +1021,17 @@
1001
1021
  <optional>
1002
1022
  <ref name="to"/>
1003
1023
  </optional>
1004
- <ref name="owner"/>
1024
+ <oneOrMore>
1025
+ <ref name="owner"/>
1026
+ </oneOrMore>
1027
+ <optional>
1028
+ <ref name="copyright_scope"/>
1029
+ </optional>
1030
+ </element>
1031
+ </define>
1032
+ <define name="copyright_scope">
1033
+ <element name="scope">
1034
+ <text/>
1005
1035
  </element>
1006
1036
  </define>
1007
1037
  <define name="from">
@@ -1,5 +1,6 @@
1
1
  require "htmlentities"
2
2
  require "uri"
3
+ require_relative "./blocks_notes"
3
4
 
4
5
  module Asciidoctor
5
6
  module Standoc
@@ -8,24 +9,27 @@ module Asciidoctor
8
9
  { id: Utils::anchor_or_uuid(node) }
9
10
  end
10
11
 
11
- def id_unnum_attr(node)
12
+ def id_unnum_attrs(node)
12
13
  attr_code( id: Utils::anchor_or_uuid(node),
13
14
  unnumbered: node.option?("unnumbered") ? "true" : nil,
15
+ number: node.attr("number"),
14
16
  subsequence: node.attr("subsequence") )
15
17
  end
16
18
 
17
- def formula_attr(node)
18
- attr_code( id: Utils::anchor_or_uuid(node),
19
- inequality: node.option?("inequality") ? "true" : nil,
20
- unnumbered: node.option?("unnumbered") ? "true" : nil,
21
- subsequence: node.attr("subsequence") )
19
+ def formula_attrs(node)
20
+ attr_code(id_unnum_attrs(node).merge(keep_attrs(node).merge(
21
+ inequality: node.option?("inequality") ? "true" : nil)))
22
+ end
23
+
24
+ def keep_attrs(node)
25
+ { "keep-with-next": node.attr("keep-with-next"),
26
+ "keep-lines-together": node.attr("keep-lines-together") }
22
27
  end
23
28
 
24
29
  # We append each contained block to its parent
25
30
  def open(node)
26
31
  role = node.role || node.attr("style")
27
- Utils::reqt_subpart(role) and
28
- return requirement_subpart(node)
32
+ Utils::reqt_subpart(role) and return requirement_subpart(node)
29
33
  result = []
30
34
  node.blocks.each do |b|
31
35
  result << send(b.context, b)
@@ -34,7 +38,7 @@ module Asciidoctor
34
38
  end
35
39
 
36
40
  def literal_attrs(node)
37
- attr_code(id_attr(node))
41
+ attr_code(id_attr(node).merge(keep_attrs(node)))
38
42
  end
39
43
 
40
44
  def literal(node)
@@ -49,84 +53,13 @@ module Asciidoctor
49
53
 
50
54
  # NOTE: html escaping is performed by Nokogiri
51
55
  def stem(node)
52
- stem_content = node.lines.join("\n")
53
- noko do |xml|
54
- xml.formula **formula_attr(node) do |s|
55
- stem_parse(stem_content, s, node.style.to_sym)
56
- end
57
- end
58
- end
59
-
60
- def sidebar_attrs(node)
61
- todo_attrs(node).merge(attr_code(
62
- from: node.attr("from"),
63
- to: node.attr("to") || node.attr("from") ))
64
- end
65
-
66
- def sidebar(node)
67
- return unless draft?
68
56
  noko do |xml|
69
- xml.review **(sidebar_attrs(node)) do |r|
70
- wrap_in_para(node, r)
57
+ xml.formula **formula_attrs(node) do |s|
58
+ stem_parse(node.lines.join("\n"), s, node.style.to_sym)
71
59
  end
72
60
  end
73
61
  end
74
62
 
75
- def todo_attrs(node)
76
- date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
77
- date += "T00:00:00Z" unless /T/.match date
78
- attr_code(
79
- id: Utils::anchor_or_uuid(node),
80
- reviewer: node.attr("reviewer") || node.attr("source") || "(Unknown)",
81
- date: date )
82
- end
83
-
84
- def todo(node)
85
- noko do |xml|
86
- xml.review **(todo_attrs(node)) do |r|
87
- wrap_in_para(node, r)
88
- end
89
- end
90
- end
91
-
92
- def termnote(n)
93
- noko do |xml|
94
- xml.termnote **id_attr(n) do |ex|
95
- wrap_in_para(n, ex)
96
- end
97
- end.join("\n")
98
- end
99
-
100
- def note(n)
101
- noko do |xml|
102
- xml.note **id_attr(n) do |c|
103
- wrap_in_para(n, c)
104
- end
105
- end.join("\n")
106
- end
107
-
108
- def admonition_attrs(node)
109
- name = node.attr("name")
110
- if type = node.attr("type")
111
- ["danger", "safety precautions"].each do |t|
112
- name = t if type.casecmp(t).zero?
113
- end
114
- end
115
- attr_code(id: Utils::anchor_or_uuid(node), type: name)
116
- end
117
-
118
- def admonition(node)
119
- return termnote(node) if in_terms?
120
- return note(node) if node.attr("name") == "note"
121
- return todo(node) if node.attr("name") == "todo"
122
- noko do |xml|
123
- xml.admonition **admonition_attrs(node) do |a|
124
- node.title.nil? or a.name { |name| name << node.title }
125
- wrap_in_para(node, a)
126
- end
127
- end.join("\n")
128
- end
129
-
130
63
  def term_example(node)
131
64
  noko do |xml|
132
65
  xml.termexample **id_attr(node) do |ex|
@@ -145,9 +78,10 @@ module Asciidoctor
145
78
  end
146
79
 
147
80
  def pseudocode_example(node)
81
+ # prevent A's and other subs inappropriate for pseudocode
82
+ node.blocks.each { |b| b.remove_sub(:replacements) }
148
83
  noko do |xml|
149
- xml.figure **{id: Asciidoctor::Standoc::Utils::anchor_or_uuid(node),
150
- class: "pseudocode"} do |ex|
84
+ xml.figure **example_attrs(node).merge(class: "pseudocode") do |ex|
151
85
  figure_title(node, ex)
152
86
  wrap_in_para(node, ex)
153
87
  end
@@ -155,7 +89,7 @@ module Asciidoctor
155
89
  end
156
90
 
157
91
  def example_attrs(node)
158
- attr_code(id_unnum_attr(node))
92
+ attr_code(id_unnum_attrs(node).merge(keep_attrs(node)))
159
93
  end
160
94
 
161
95
  def example_proper(node)
@@ -173,7 +107,7 @@ module Asciidoctor
173
107
  end
174
108
 
175
109
  def figure_attrs(node)
176
- attr_code(id_unnum_attr(node))
110
+ attr_code(id_unnum_attrs(node).merge(keep_attrs(node)))
177
111
  end
178
112
 
179
113
  def image(node)
@@ -186,8 +120,8 @@ module Asciidoctor
186
120
  end
187
121
 
188
122
  def para_attrs(node)
189
- attr_code(align: node.attr("align"),
190
- id: Utils::anchor_or_uuid(node))
123
+ attr_code(keep_attrs(node).merge(align: node.attr("align"),
124
+ id: Utils::anchor_or_uuid(node)))
191
125
  end
192
126
 
193
127
  def paragraph(node)
@@ -200,7 +134,8 @@ module Asciidoctor
200
134
  end
201
135
 
202
136
  def quote_attrs(node)
203
- attr_code(id: Utils::anchor_or_uuid(node), align: node.attr("align"))
137
+ attr_code(keep_attrs(node).merge(align: node.attr("align"),
138
+ id: Utils::anchor_or_uuid(node)))
204
139
  end
205
140
 
206
141
  def quote_attribution(node, out)
@@ -210,9 +145,8 @@ module Asciidoctor
210
145
  s << m[:text]
211
146
  end
212
147
  end
213
- if node.attr("attribution")
148
+ node.attr("attribution") and
214
149
  out.author { |a| a << node.attr("attribution") }
215
- end
216
150
  end
217
151
 
218
152
  def quote(node)
@@ -225,10 +159,11 @@ module Asciidoctor
225
159
  end
226
160
 
227
161
  def listing_attrs(node)
228
- attr_code(lang: node.attr("language"),
229
- id: Utils::anchor_or_uuid(node),
230
- unnumbered: node.option?("unnumbered") ? "true" : nil,
231
- filename: node.attr("filename"))
162
+ attr_code(keep_attrs(node).merge(lang: node.attr("language"),
163
+ id: Utils::anchor_or_uuid(node),
164
+ unnumbered: node.option?("unnumbered") ? "true" : nil,
165
+ number: node.attr("number"),
166
+ filename: node.attr("filename")))
232
167
  end
233
168
 
234
169
  # NOTE: html escaping is performed by Nokogiri
@@ -244,7 +179,12 @@ module Asciidoctor
244
179
  end
245
180
 
246
181
  def pass(node)
247
- node.content
182
+ noko do |xml|
183
+ xml.passthrough **attr_code(formats:
184
+ node.attr("format") || "metanorma") do |p|
185
+ p << HTMLEntities.new.encode(node.content, :basic, :hexadecimal)
186
+ end
187
+ end
248
188
  end
249
189
  end
250
190
  end