metanorma-standoc 1.3.29 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +0 -7
  3. data/.github/workflows/ubuntu.yml +6 -11
  4. data/.github/workflows/windows.yml +0 -8
  5. data/.gitignore +1 -0
  6. data/Rakefile +2 -0
  7. data/lib/asciidoctor/standoc/base.rb +24 -47
  8. data/lib/asciidoctor/standoc/biblio.rng +14 -4
  9. data/lib/asciidoctor/standoc/blocks.rb +30 -97
  10. data/lib/asciidoctor/standoc/blocks_notes.rb +89 -0
  11. data/lib/asciidoctor/standoc/cleanup.rb +12 -6
  12. data/lib/asciidoctor/standoc/cleanup_block.rb +2 -2
  13. data/lib/asciidoctor/standoc/cleanup_inline.rb +1 -1
  14. data/lib/asciidoctor/standoc/cleanup_ref.rb +47 -1
  15. data/lib/asciidoctor/standoc/cleanup_section.rb +8 -125
  16. data/lib/asciidoctor/standoc/cleanup_terms.rb +134 -0
  17. data/lib/asciidoctor/standoc/converter.rb +16 -0
  18. data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +57 -0
  19. data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +102 -0
  20. data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +408 -0
  21. data/lib/asciidoctor/standoc/inline.rb +11 -6
  22. data/lib/asciidoctor/standoc/isodoc.rng +444 -1
  23. data/lib/asciidoctor/standoc/lists.rb +12 -12
  24. data/lib/asciidoctor/standoc/macros.rb +13 -8
  25. data/lib/asciidoctor/standoc/macros_yaml2text.rb +44 -21
  26. data/lib/asciidoctor/standoc/ref.rb +78 -79
  27. data/lib/asciidoctor/standoc/ref_sect.rb +124 -0
  28. data/lib/asciidoctor/standoc/reqt.rb +11 -6
  29. data/lib/asciidoctor/standoc/reqt.rng +23 -0
  30. data/lib/asciidoctor/standoc/section.rb +2 -46
  31. data/lib/asciidoctor/standoc/table.rb +3 -2
  32. data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +30 -0
  33. data/lib/asciidoctor/standoc/views/datamodel/plantuml_representation.adoc.erb +20 -0
  34. data/lib/metanorma/standoc/processor.rb +5 -7
  35. data/lib/metanorma/standoc/version.rb +1 -1
  36. data/metanorma-standoc.gemspec +3 -2
  37. data/spec/asciidoctor-standoc/base_spec.rb +2 -2
  38. data/spec/asciidoctor-standoc/blocks_spec.rb +56 -27
  39. data/spec/asciidoctor-standoc/cleanup_spec.rb +56 -5
  40. data/spec/asciidoctor-standoc/datamodel/attributes_table_preprocessor_spec.rb +111 -0
  41. data/spec/asciidoctor-standoc/datamodel/diagram_preprocessor_spec.rb +72 -0
  42. data/spec/asciidoctor-standoc/inline_spec.rb +7 -3
  43. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +4 -4
  44. data/spec/asciidoctor-standoc/lists_spec.rb +7 -5
  45. data/spec/asciidoctor-standoc/macros_spec.rb +53 -2
  46. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +2 -1
  47. data/spec/asciidoctor-standoc/refs_dl_spec.rb +4 -2
  48. data/spec/asciidoctor-standoc/refs_spec.rb +263 -22
  49. data/spec/asciidoctor-standoc/table_spec.rb +3 -3
  50. data/spec/asciidoctor-standoc/validate_spec.rb +56 -0
  51. data/spec/assets/{html.css → html.scss} +0 -0
  52. data/spec/assets/iso123.rxl +107 -0
  53. data/spec/assets/{word.css → word.scss} +0 -0
  54. data/spec/examples/datamodel/address_class_profile.adoc +4 -0
  55. data/spec/examples/datamodel/address_component_profile.adoc +4 -0
  56. data/spec/examples/datamodel/blank_definition_profile.adoc +4 -0
  57. data/spec/examples/datamodel/common_models_diagram.adoc +4 -0
  58. data/spec/examples/datamodel/models/models/AddressClassProfile.yml +90 -0
  59. data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +63 -0
  60. data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +15 -0
  61. data/spec/examples/datamodel/models/models/AddressProfile.yml +36 -0
  62. data/spec/examples/datamodel/models/models/AttributeProfile.yml +32 -0
  63. data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +79 -0
  64. data/spec/examples/datamodel/models/models/Localization copy.yml +23 -0
  65. data/spec/examples/datamodel/models/models/Localization.yml +23 -0
  66. data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +36 -0
  67. data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +15 -0
  68. data/spec/examples/datamodel/models/models/Signature.yml +20 -0
  69. data/spec/examples/datamodel/models/models/SignatureBlankDefinition.yml +20 -0
  70. data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +16 -0
  71. data/spec/examples/datamodel/models/models/TextDirectionCode.yml +16 -0
  72. data/spec/examples/datamodel/models/models/Validity.yml +14 -0
  73. data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +22 -0
  74. data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +2 -0
  75. data/spec/examples/datamodel/models/style.uml.inc +37 -0
  76. data/spec/examples/datamodel/models/views/CommonModels.yml +9 -0
  77. data/spec/examples/datamodel/models/views/TopDown.yml +62 -0
  78. data/spec/examples/datamodel/top_down_diagram.adoc +4 -0
  79. data/spec/fixtures/macros_datamodel/address_class_profile.xml +149 -0
  80. data/spec/fixtures/macros_datamodel/address_component_profile.xml +71 -0
  81. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +51 -0
  82. data/spec/fixtures/macros_datamodel/common_models_diagram.xml +7 -0
  83. data/spec/fixtures/macros_datamodel/top_down_diagram.xml +7 -0
  84. data/spec/metanorma/processor_spec.rb +4 -4
  85. data/spec/spec_helper.rb +13 -2
  86. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +81 -81
  87. data/spec/vcr_cassettes/isobib_get_123.yml +20 -199
  88. data/spec/vcr_cassettes/isobib_get_123_1.yml +361 -0
  89. data/spec/vcr_cassettes/isobib_get_123_2001.yml +20 -20
  90. data/spec/vcr_cassettes/isobib_get_124.yml +21 -21
  91. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +10 -10
  92. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +47 -44
  93. metadata +68 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e964fb25b29d5ecbe775bf397a17f9cf264fa3709e8756be7a9025bcf043250f
4
- data.tar.gz: d6085180737f332f6aa657eb129bf72f02ca0466b60e22276ddda03cd2cbd788
3
+ metadata.gz: 841be88451455a61d53e89d5c557c57f1769372d878c5200826136dae8d62cfd
4
+ data.tar.gz: b922c30fbd44544dda7ee63a4090d672030f2af570861b500dcd3e8f205497d3
5
5
  SHA512:
6
- metadata.gz: baccf6cbbb3c32defcac92b95911e83f10f44338a2bb631a8c6ee86a7b00833583d27161b18ad45b2d80aeec8dcbe3dd349a39b4cfa08670f6cdbe1c8492323c
7
- data.tar.gz: 347739395332e6d3ac88ea0ec5bec557fa0d06dee7f7f2bbafa198e245131dd313c3f229f63bb3afc92c99eb4cd0cec8fc2a9f969e0cbf42a76271e45955e8eb
6
+ metadata.gz: cd2d8b314061fb9c108b6e7568ee9dc65ce81180e955961d593bcaf17081b0e8e7c3e22c8d132ce57c0f5c698869347ff35fd7b56b62d0d1ee34b6c8877a462c
7
+ data.tar.gz: 7e501083f23311f0b8a8b22eeaf8ec2990d39bc442fe76882b9172bb9bfafc44d273f1485ae0a9117006ba508beff735857194fdf0a49d8eb80deaf902b3a433
@@ -29,10 +29,6 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
33
- - uses: actions/setup-node@v1
34
- with:
35
- node-version: '10.x'
36
32
  - name: Install LaTeXML
37
33
  run: |
38
34
  brew install libxml2 cpanminus
@@ -41,9 +37,6 @@ jobs:
41
37
  - name: Install PlantUML
42
38
  run: |
43
39
  brew install plantuml
44
- - name: Install puppeteer
45
- run: |
46
- npm -g i puppeteer
47
40
  - name: Update gems
48
41
  run: |
49
42
  sudo gem install bundler --force
@@ -29,10 +29,6 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
33
- - uses: actions/setup-node@v1
34
- with:
35
- node-version: '10.x'
36
32
  - name: Update gems
37
33
  run: |
38
34
  gem install bundler
@@ -42,13 +38,12 @@ jobs:
42
38
  sudo snap install latexml --edge
43
39
  echo "::add-path::/snap/bin"
44
40
  - name: Install PlantUML
45
- run: |
46
- curl -L https://raw.githubusercontent.com/metanorma/plantuml-install/master/ubuntu.sh | sudo bash
47
- - name: Install puppeteer
48
- run: |
49
- sudo apt-get update
50
- sudo apt-get install -y libgbm1
51
- npm install -g puppeteer@3.0.1
41
+ uses: nick-invision/retry@v1
42
+ with:
43
+ polling_interval_seconds: 5
44
+ timeout_minutes: 5
45
+ max_attempts: 3
46
+ command: sudo bash -c "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
52
47
  - name: Run specs
53
48
  run: |
54
49
  bundle exec rake
@@ -29,10 +29,6 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
33
- - uses: actions/setup-node@v1
34
- with:
35
- node-version: '10.x'
36
32
  - name: Install MN Windows dependencies
37
33
  shell: pwsh
38
34
  run: |
@@ -50,10 +46,6 @@ jobs:
50
46
  refreshenv
51
47
  set PATH=C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;%PATH%
52
48
  where latexmlmath
53
- - name: Install puppeteer
54
- shell: pwsh
55
- run: |
56
- npm -g i puppeteer
57
49
  - name: Run specs
58
50
  shell: pwsh
59
51
  run: |
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
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require 'isodoc/gem_tasks'
3
4
 
5
+ IsoDoc::GemTasks.install
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
8
  task default: :spec
@@ -14,20 +14,6 @@ module Asciidoctor
14
14
  XML_ROOT_TAG = "standard-document".freeze
15
15
  XML_NAMESPACE = "https://www.metanorma.org/ns/standoc".freeze
16
16
 
17
- Asciidoctor::Extensions.register do
18
- preprocessor Asciidoctor::Standoc::Yaml2TextPreprocessor
19
- inline_macro Asciidoctor::Standoc::AltTermInlineMacro
20
- inline_macro Asciidoctor::Standoc::DeprecatedTermInlineMacro
21
- inline_macro Asciidoctor::Standoc::DomainTermInlineMacro
22
- inline_macro Asciidoctor::Standoc::InheritInlineMacro
23
- inline_macro Asciidoctor::Standoc::HTML5RubyMacro
24
- inline_macro Asciidoctor::Standoc::ConceptInlineMacro
25
- block Asciidoctor::Standoc::ToDoAdmonitionBlock
26
- treeprocessor Asciidoctor::Standoc::ToDoInlineAdmonitionBlock
27
- block Asciidoctor::Standoc::PlantUMLBlockMacro
28
- block Asciidoctor::Standoc::PseudocodeBlockMacro
29
- end
30
-
31
17
  def xml_root_tag
32
18
  self.class::XML_ROOT_TAG
33
19
  end
@@ -96,6 +82,10 @@ module Asciidoctor
96
82
  IsoDoc::WordConvert.new(doc_extract_attributes(node))
97
83
  end
98
84
 
85
+ def presentation_xml_converter(node)
86
+ IsoDoc::PresentationXMLConvert.new(html_extract_attributes(node))
87
+ end
88
+
99
89
  def init(node)
100
90
  @fn_number ||= 0
101
91
  @draft = false
@@ -111,6 +101,7 @@ module Asciidoctor
111
101
  @filename = node.attr("docfile") ?
112
102
  File.basename(node.attr("docfile")).gsub(/\.adoc$/, "") : ""
113
103
  @localdir = Utils::localdir(node)
104
+ @output_dir = outputdir node
114
105
  @no_isobib_cache = node.attr("no-isobib-cache")
115
106
  @no_isobib = node.attr("no-isobib")
116
107
  @bibdb = nil
@@ -125,31 +116,6 @@ module Asciidoctor
125
116
  i18n_init(lang, script)
126
117
  end
127
118
 
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
119
  def default_fonts(node)
154
120
  b = node.attr("body-font") ||
155
121
  (node.attr("script") == "Hans" ? '"SimSun",serif' :
@@ -161,20 +127,23 @@ module Asciidoctor
161
127
  "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
162
128
  end
163
129
 
130
+ def outputs(node, ret)
131
+ File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
132
+ presentation_xml_converter(node).convert(@filename + ".xml")
133
+ html_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.html")
134
+ doc_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
135
+ end
136
+
164
137
  def document(node)
165
138
  init(node)
166
139
  ret = makexml(node).to_xml(indent: 2)
167
- unless node.attr("nodoc") || !node.attr("docfile")
168
- File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
169
- html_converter(node).convert(@filename + ".xml")
170
- doc_converter(node).convert(@filename + ".xml")
171
- end
140
+ outputs(node, ret) unless node.attr("nodoc") || !node.attr("docfile")
172
141
  clean_exit
173
142
  ret
174
143
  end
175
144
 
176
145
  def clean_exit
177
- @log.write(@localdir + @filename + ".err") unless @novalid
146
+ @log.write(@output_dir + @filename + ".err") unless @novalid
178
147
  @files_to_delete.each { |f| FileUtils.rm f }
179
148
  end
180
149
 
@@ -215,7 +184,7 @@ module Asciidoctor
215
184
  end
216
185
  end
217
186
 
218
- def term_source_attr(seen_xref)
187
+ def term_source_attrs(seen_xref)
219
188
  { bibitemid: seen_xref.children[0]["target"],
220
189
  format: seen_xref.children[0]["format"],
221
190
  type: "inline" }
@@ -226,7 +195,7 @@ module Asciidoctor
226
195
  xml_t.origin { |o| o << seen_xref.children[0].to_xml }
227
196
  else
228
197
  xml_t.origin seen_xref.children[0].content,
229
- **attr_code(term_source_attr(seen_xref))
198
+ **attr_code(term_source_attrs(seen_xref))
230
199
  end
231
200
  m[:text] && xml_t.modification do |mod|
232
201
  mod.p { |p| p << m[:text].sub(/^\s+/, "") }
@@ -259,6 +228,14 @@ module Asciidoctor
259
228
  end
260
229
  end.join("\n")
261
230
  end
231
+
232
+ private
233
+
234
+ def outputdir(node)
235
+ if node.attr("output_dir").nil_or_empty? then Utils::localdir(node)
236
+ else File.join(node.attr("output_dir"), "")
237
+ end
238
+ end
262
239
  end
263
240
  end
264
241
  end
@@ -532,7 +532,7 @@
532
532
  </define>
533
533
  <define name="LocalityType">
534
534
  <data type="string">
535
- <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>
536
536
  </data>
537
537
  </define>
538
538
  <define name="referenceFrom">
@@ -661,9 +661,9 @@
661
661
  <optional>
662
662
  <ref name="status"/>
663
663
  </optional>
664
- <optional>
664
+ <zeroOrMore>
665
665
  <ref name="copyright"/>
666
- </optional>
666
+ </zeroOrMore>
667
667
  <zeroOrMore>
668
668
  <ref name="docrelation"/>
669
669
  </zeroOrMore>
@@ -1021,7 +1021,17 @@
1021
1021
  <optional>
1022
1022
  <ref name="to"/>
1023
1023
  </optional>
1024
- <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/>
1025
1035
  </element>
1026
1036
  </define>
1027
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,28 +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
22
  end
23
23
 
24
- def note_attr(node)
25
- attr_code(id_attr(node).merge("keep-separate": node.attr("keep-separate")))
24
+ def keep_attrs(node)
25
+ { "keep-with-next": node.attr("keep-with-next"),
26
+ "keep-lines-together": node.attr("keep-lines-together") }
26
27
  end
27
28
 
28
29
  # We append each contained block to its parent
29
30
  def open(node)
30
31
  role = node.role || node.attr("style")
31
- Utils::reqt_subpart(role) and
32
- return requirement_subpart(node)
32
+ Utils::reqt_subpart(role) and return requirement_subpart(node)
33
33
  result = []
34
34
  node.blocks.each do |b|
35
35
  result << send(b.context, b)
@@ -38,7 +38,7 @@ module Asciidoctor
38
38
  end
39
39
 
40
40
  def literal_attrs(node)
41
- attr_code(id_attr(node))
41
+ attr_code(id_attr(node).merge(keep_attrs(node)))
42
42
  end
43
43
 
44
44
  def literal(node)
@@ -53,82 +53,11 @@ module Asciidoctor
53
53
 
54
54
  # NOTE: html escaping is performed by Nokogiri
55
55
  def stem(node)
56
- stem_content = node.lines.join("\n")
57
- noko do |xml|
58
- xml.formula **formula_attr(node) do |s|
59
- stem_parse(stem_content, s, node.style.to_sym)
60
- end
61
- end
62
- end
63
-
64
- def sidebar_attrs(node)
65
- todo_attrs(node).merge(attr_code(
66
- from: node.attr("from"),
67
- to: node.attr("to") || node.attr("from") ))
68
- end
69
-
70
- def sidebar(node)
71
- return unless draft?
72
- noko do |xml|
73
- xml.review **(sidebar_attrs(node)) do |r|
74
- wrap_in_para(node, r)
75
- end
76
- end
77
- end
78
-
79
- def todo_attrs(node)
80
- date = node.attr("date") || Date.today.iso8601.gsub(/\+.*$/, "")
81
- date += "T00:00:00Z" unless /T/.match date
82
- attr_code(
83
- id: Utils::anchor_or_uuid(node),
84
- reviewer: node.attr("reviewer") || node.attr("source") || "(Unknown)",
85
- date: date )
86
- end
87
-
88
- def todo(node)
89
- noko do |xml|
90
- xml.review **(todo_attrs(node)) do |r|
91
- wrap_in_para(node, r)
92
- end
93
- end
94
- end
95
-
96
- def termnote(n)
97
- noko do |xml|
98
- xml.termnote **note_attr(n) do |ex|
99
- wrap_in_para(n, ex)
100
- end
101
- end.join("\n")
102
- end
103
-
104
- def note(n)
105
56
  noko do |xml|
106
- xml.note **note_attr(n) do |c|
107
- wrap_in_para(n, c)
108
- end
109
- end.join("\n")
110
- end
111
-
112
- def admonition_attrs(node)
113
- name = node.attr("name")
114
- if type = node.attr("type")
115
- ["danger", "safety precautions"].each do |t|
116
- name = t if type.casecmp(t).zero?
57
+ xml.formula **formula_attrs(node) do |s|
58
+ stem_parse(node.lines.join("\n"), s, node.style.to_sym)
117
59
  end
118
60
  end
119
- attr_code(id: Utils::anchor_or_uuid(node), type: name)
120
- end
121
-
122
- def admonition(node)
123
- return termnote(node) if in_terms?
124
- return note(node) if node.attr("name") == "note"
125
- return todo(node) if node.attr("name") == "todo"
126
- noko do |xml|
127
- xml.admonition **admonition_attrs(node) do |a|
128
- node.title.nil? or a.name { |name| name << node.title }
129
- wrap_in_para(node, a)
130
- end
131
- end.join("\n")
132
61
  end
133
62
 
134
63
  def term_example(node)
@@ -149,8 +78,10 @@ module Asciidoctor
149
78
  end
150
79
 
151
80
  def pseudocode_example(node)
81
+ # prevent A's and other subs inappropriate for pseudocode
82
+ node.blocks.each { |b| b.remove_sub(:replacements) }
152
83
  noko do |xml|
153
- xml.figure **id_unnum_attr(node).merge(class: "pseudocode") do |ex|
84
+ xml.figure **example_attrs(node).merge(class: "pseudocode") do |ex|
154
85
  figure_title(node, ex)
155
86
  wrap_in_para(node, ex)
156
87
  end
@@ -158,7 +89,7 @@ module Asciidoctor
158
89
  end
159
90
 
160
91
  def example_attrs(node)
161
- attr_code(id_unnum_attr(node))
92
+ attr_code(id_unnum_attrs(node).merge(keep_attrs(node)))
162
93
  end
163
94
 
164
95
  def example_proper(node)
@@ -176,7 +107,7 @@ module Asciidoctor
176
107
  end
177
108
 
178
109
  def figure_attrs(node)
179
- attr_code(id_unnum_attr(node))
110
+ attr_code(id_unnum_attrs(node).merge(keep_attrs(node)))
180
111
  end
181
112
 
182
113
  def image(node)
@@ -189,8 +120,8 @@ module Asciidoctor
189
120
  end
190
121
 
191
122
  def para_attrs(node)
192
- attr_code(align: node.attr("align"),
193
- id: Utils::anchor_or_uuid(node))
123
+ attr_code(keep_attrs(node).merge(align: node.attr("align"),
124
+ id: Utils::anchor_or_uuid(node)))
194
125
  end
195
126
 
196
127
  def paragraph(node)
@@ -203,7 +134,8 @@ module Asciidoctor
203
134
  end
204
135
 
205
136
  def quote_attrs(node)
206
- 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)))
207
139
  end
208
140
 
209
141
  def quote_attribution(node, out)
@@ -213,9 +145,8 @@ module Asciidoctor
213
145
  s << m[:text]
214
146
  end
215
147
  end
216
- if node.attr("attribution")
148
+ node.attr("attribution") and
217
149
  out.author { |a| a << node.attr("attribution") }
218
- end
219
150
  end
220
151
 
221
152
  def quote(node)
@@ -228,10 +159,11 @@ module Asciidoctor
228
159
  end
229
160
 
230
161
  def listing_attrs(node)
231
- attr_code(lang: node.attr("language"),
232
- id: Utils::anchor_or_uuid(node),
233
- unnumbered: node.option?("unnumbered") ? "true" : nil,
234
- 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")))
235
167
  end
236
168
 
237
169
  # NOTE: html escaping is performed by Nokogiri
@@ -248,7 +180,8 @@ module Asciidoctor
248
180
 
249
181
  def pass(node)
250
182
  noko do |xml|
251
- xml.passthrough **attr_code(formats: node.attr("format")) do |p|
183
+ xml.passthrough **attr_code(formats:
184
+ node.attr("format") || "metanorma") do |p|
252
185
  p << HTMLEntities.new.encode(node.content, :basic, :hexadecimal)
253
186
  end
254
187
  end