metanorma-iso 1.5.12 → 1.7.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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +18 -1
  3. data/lib/asciidoctor/iso/base.rb +5 -5
  4. data/lib/asciidoctor/iso/basicdoc.rng +52 -3
  5. data/lib/asciidoctor/iso/cleanup.rb +0 -6
  6. data/lib/asciidoctor/iso/front.rb +10 -5
  7. data/lib/asciidoctor/iso/isodoc.rng +51 -3
  8. data/lib/asciidoctor/iso/isostandard-amd.rng +8 -4
  9. data/lib/asciidoctor/iso/isostandard.rng +27 -10
  10. data/lib/asciidoctor/iso/validate.rb +78 -0
  11. data/lib/asciidoctor/iso/validate_section.rb +12 -9
  12. data/lib/isodoc/iso/base_convert.rb +2 -1
  13. data/lib/isodoc/iso/html/header.html +12 -12
  14. data/lib/isodoc/iso/html/html_iso_intro.html +1 -1
  15. data/lib/isodoc/iso/html/html_iso_titlepage.html +1 -1
  16. data/lib/isodoc/iso/html/htmlstyle.css +1 -1
  17. data/lib/isodoc/iso/html/htmlstyle.scss +1 -1
  18. data/lib/isodoc/iso/html/isodoc.css +42 -42
  19. data/lib/isodoc/iso/html/isodoc.scss +42 -42
  20. data/lib/isodoc/iso/html/style-human.css +9 -9
  21. data/lib/isodoc/iso/html/style-human.scss +7 -7
  22. data/lib/isodoc/iso/html/style-iso.css +7 -7
  23. data/lib/isodoc/iso/html/style-iso.scss +5 -5
  24. data/lib/isodoc/iso/html/word_iso_intro.html +1 -1
  25. data/lib/isodoc/iso/html/word_iso_titlepage.html +1 -1
  26. data/lib/isodoc/iso/html/wordstyle.css +67 -67
  27. data/lib/isodoc/iso/html/wordstyle.scss +67 -67
  28. data/lib/isodoc/iso/html_convert.rb +6 -2
  29. data/lib/isodoc/iso/i18n-en.yaml +2 -0
  30. data/lib/isodoc/iso/i18n-fr.yaml +1 -1
  31. data/lib/isodoc/iso/i18n-zh-Hans.yaml +1 -1
  32. data/lib/isodoc/iso/iso.amendment.xsl +276 -59
  33. data/lib/isodoc/iso/iso.international-standard.xsl +276 -59
  34. data/lib/isodoc/iso/metadata.rb +1 -0
  35. data/lib/isodoc/iso/sections.rb +1 -1
  36. data/lib/isodoc/iso/word_convert.rb +6 -2
  37. data/lib/isodoc/iso/xref.rb +34 -8
  38. data/lib/metanorma/iso/processor.rb +11 -9
  39. data/lib/metanorma/iso/version.rb +1 -1
  40. data/metanorma-iso.gemspec +2 -2
  41. data/spec/asciidoctor-iso/amd_spec.rb +14 -14
  42. data/spec/asciidoctor-iso/base_spec.rb +22 -20
  43. data/spec/asciidoctor-iso/blocks_spec.rb +22 -22
  44. data/spec/asciidoctor-iso/cleanup_spec.rb +32 -26
  45. data/spec/asciidoctor-iso/inline_spec.rb +7 -7
  46. data/spec/asciidoctor-iso/lists_spec.rb +9 -9
  47. data/spec/asciidoctor-iso/refs_spec.rb +5 -5
  48. data/spec/asciidoctor-iso/section_spec.rb +12 -7
  49. data/spec/asciidoctor-iso/table_spec.rb +4 -4
  50. data/spec/asciidoctor-iso/validate_spec.rb +455 -87
  51. data/spec/isodoc/amd_spec.rb +13 -13
  52. data/spec/isodoc/iso_spec.rb +2 -2
  53. data/spec/isodoc/metadata_spec.rb +2 -0
  54. data/spec/isodoc/section_spec.rb +20 -0
  55. data/spec/isodoc/xref_spec.rb +12 -0
  56. metadata +6 -12
  57. data/.github/workflows/macos.yml +0 -49
  58. data/.github/workflows/ubuntu.yml +0 -53
  59. data/.github/workflows/windows.yml +0 -50
  60. data/lib/asciidoctor/iso/macros.rb +0 -21
  61. data/lib/asciidoctor/iso/term_lookup_cleanup.rb +0 -86
  62. data/spec/asciidoctor-iso/macros_spec.rb +0 -310
@@ -66,9 +66,9 @@ RSpec.describe IsoDoc do
66
66
  <preface>
67
67
  <foreword>
68
68
  <p>
69
- <xref target='N'>[scope], Note</xref>
70
- <xref target='note1'>[widgets1], Note 1</xref>
71
- <xref target='note2'>[widgets1], Note 2</xref>
69
+ <xref target='N'>Scope, Note</xref>
70
+ <xref target='note1'>Widgets, 1, Note 1</xref>
71
+ <xref target='note2'>Widgets, 1, Note 2</xref>
72
72
  <xref target='AN'>A.1, Note</xref>
73
73
  <xref target='Anote1'>A.2, Note 1</xref>
74
74
  <xref target='Anote2'>A.2, Note 2</xref>
@@ -231,15 +231,15 @@ RSpec.describe IsoDoc do
231
231
  This is a preamble
232
232
  <xref target='C'>0.1</xref>
233
233
  <xref target='C1'>0.2</xref>
234
- <xref target='D'>[D]</xref>
234
+ <xref target='D'>Scope</xref>
235
235
  <xref target='H'>[H]</xref>
236
236
  <xref target='I'>[I]</xref>
237
237
  <xref target='J'>[J]</xref>
238
238
  <xref target='K'>[K]</xref>
239
239
  <xref target='L'>[L]</xref>
240
- <xref target='M'>[M]</xref>
241
- <xref target='N'>[N]</xref>
242
- <xref target='O'>[O]</xref>
240
+ <xref target='M'>Clause 4</xref>
241
+ <xref target='N'>Introduction</xref>
242
+ <xref target='O'>Clause 4.2</xref>
243
243
  <xref target='P'>Annex A</xref>
244
244
  <xref target='Q'>A.1</xref>
245
245
  <xref target='Q1'>A.1.1</xref>
@@ -263,10 +263,10 @@ RSpec.describe IsoDoc do
263
263
  <clause id='M' inline-header='false' obligation='normative'>
264
264
  <title depth="1">Clause 4</title>
265
265
  <clause id='N' inline-header='false' obligation='normative'>
266
- <title depth="1">Introduction</title>
266
+ <title depth="2">Introduction</title>
267
267
  </clause>
268
268
  <clause id='O' inline-header='false' obligation='normative'>
269
- <title depth="1">Clause 4.2</title>
269
+ <title depth="2">Clause 4.2</title>
270
270
  </clause>
271
271
  </clause>
272
272
  </sections>
@@ -452,10 +452,10 @@ RSpec.describe IsoDoc do
452
452
  <clause id='M' inline-header='false' obligation='normative'>
453
453
  <title depth='1'>Clause 4</title>
454
454
  <clause id='N' inline-header='false' obligation='normative'>
455
- <title depth='1'>Introduction</title>
455
+ <title depth='2'>Introduction</title>
456
456
  </clause>
457
457
  <clause id='O' inline-header='false' obligation='normative'>
458
- <title depth='1'>Clause 4.2</title>
458
+ <title depth='2'>Clause 4.2</title>
459
459
  </clause>
460
460
  <clause id='O1' inline-header='true' obligation='normative'> </clause>
461
461
  </clause>
@@ -570,10 +570,10 @@ RSpec.describe IsoDoc do
570
570
  <div id='M'>
571
571
  <h1>Clause 4</h1>
572
572
  <div id='N'>
573
- <h1>Introduction</h1>
573
+ <h2>Introduction</h2>
574
574
  </div>
575
575
  <div id='O'>
576
- <h1>Clause 4.2</h1>
576
+ <h2>Clause 4.2</h2>
577
577
  </div>
578
578
  <div id='O1'>
579
579
  </div>
@@ -49,8 +49,8 @@ RSpec.describe IsoDoc::Iso do
49
49
  INPUT
50
50
  html = File.read("test.html", encoding: "utf-8")
51
51
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
52
- expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "SimSun", serif;]m)
53
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "SimHei", sans-serif;]m)
52
+ expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Source Han Sans", serif;]m)
53
+ expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Source Han Sans", sans-serif;]m)
54
54
  end
55
55
 
56
56
  it "processes isodoc as ISO: user nominated fonts" do
@@ -64,6 +64,7 @@ RSpec.describe IsoDoc::Iso::Metadata do
64
64
  <keyword>kw1</keyword>
65
65
  <ext>
66
66
  <doctype>international-standard</doctype>
67
+ <horizontal>true</horizontal>
67
68
  <editorialgroup>
68
69
  <technical-committee number="34">Food products</technical-committee>
69
70
  <subcommittee number="4">Cereals and pulses</subcommittee>
@@ -106,6 +107,7 @@ INPUT
106
107
  :draftinfo=>" (draft 0.4, 2016-05-01)",
107
108
  :edition=>"2",
108
109
  :editorialgroup=>["TC 34", "SC 4", "WG 3"],
110
+ :horizontal=>"true",
109
111
  :implementeddate=>"XXX",
110
112
  :issueddate=>"XXX",
111
113
  :keywords=>["kw2", "kw1"],
@@ -55,6 +55,9 @@ RSpec.describe IsoDoc do
55
55
  </clause>
56
56
  <appendix id="Q2" inline-header="false" obligation="normative">
57
57
  <title>An Appendix</title>
58
+ <clause id='Q2a' inline-header='false' obligation='normative'>
59
+ <title>Appendix subclause</title>
60
+ </clause>
58
61
  </appendix>
59
62
  <references id="Q3" normative="false"><title>Annex Bibliography</title></references>
60
63
  </annex><bibliography><references id="R" obligation="informative" normative="true">
@@ -140,6 +143,13 @@ RSpec.describe IsoDoc do
140
143
  </clause>
141
144
  <appendix id='Q2' inline-header='false' obligation='normative'>
142
145
  <title depth='2'>Appendix 1<tab/>An Appendix</title>
146
+ <clause id='Q2a' inline-header='false' obligation='normative'>
147
+ <title depth='3'>
148
+ Appendix 1.1
149
+ <tab/>
150
+ Appendix subclause
151
+ </title>
152
+ </clause>
143
153
  </appendix>
144
154
  <references id='Q3' normative='false'>
145
155
  <title depth='2'>A.2<tab/>Annex Bibliography</title>
@@ -222,6 +232,9 @@ RSpec.describe IsoDoc do
222
232
  </div>
223
233
  <div id="Q2">
224
234
  <h2>Appendix 1&#160; An Appendix</h2>
235
+ <div id='Q2a'>
236
+ <h3> Appendix 1.1 &#160; Appendix subclause </h3>
237
+ </div>
225
238
  </div>
226
239
  <div>
227
240
  <h2 class="Section3">A.2&#160; Annex Bibliography</h2>
@@ -318,6 +331,13 @@ OUTPUT
318
331
  </div>
319
332
  <div id="Q2">
320
333
  <h2>Appendix 1<span style="mso-tab-count:1">&#160; </span>An Appendix</h2>
334
+ <div id='Q2a'>
335
+ <h3>
336
+ Appendix 1.1
337
+ <span style='mso-tab-count:1'>&#160; </span>
338
+ Appendix subclause
339
+ </h3>
340
+ </div>
321
341
  </div>
322
342
  <div>
323
343
  <h2 class='Section3'>
@@ -936,6 +936,7 @@ RSpec.describe IsoDoc do
936
936
  <xref target="Q"/>
937
937
  <xref target="Q1"/>
938
938
  <xref target="Q2"/>
939
+ <xref target="Q3"/>
939
940
  <xref target="R"/>
940
941
  </p>
941
942
  </foreword>
@@ -985,6 +986,9 @@ RSpec.describe IsoDoc do
985
986
  </clause>
986
987
  <appendix id="Q2" inline-header="false" obligation="normative">
987
988
  <title>An Appendix</title>
989
+ <clause id='Q3' inline-header='false' obligation='normative'>
990
+ <title>Appendix subclause</title>
991
+ </clause>
988
992
  </appendix>
989
993
  </annex><bibliography><references id="R" obligation="informative" normative="true">
990
994
  <title>Normative References</title>
@@ -1019,6 +1023,7 @@ RSpec.describe IsoDoc do
1019
1023
  <xref target='Q'>A.1</xref>
1020
1024
  <xref target='Q1'>A.1.1</xref>
1021
1025
  <xref target='Q2'>Annex A, Appendix 1</xref>
1026
+ <xref target='Q3'>Annex A, Appendix 1.1</xref>
1022
1027
  <xref target='R'>Clause 2</xref>
1023
1028
  </p>
1024
1029
  </foreword>
@@ -1126,6 +1131,13 @@ RSpec.describe IsoDoc do
1126
1131
  <tab/>
1127
1132
  An Appendix
1128
1133
  </title>
1134
+ <clause id='Q3' inline-header='false' obligation='normative'>
1135
+ <title depth='3'>
1136
+ Appendix 1.1
1137
+ <tab/>
1138
+ Appendix subclause
1139
+ </title>
1140
+ </clause>
1129
1141
  </appendix>
1130
1142
  </annex>
1131
1143
  <bibliography>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.12
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-jing
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.0
33
+ version: 1.5.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2.0
40
+ version: 1.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: metanorma-standoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.6.0
47
+ version: 1.8.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.6.0
54
+ version: 1.8.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: tokenizer
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -261,10 +261,7 @@ extensions: []
261
261
  extra_rdoc_files: []
262
262
  files:
263
263
  - ".gitattributes"
264
- - ".github/workflows/macos.yml"
265
264
  - ".github/workflows/rake.yml"
266
- - ".github/workflows/ubuntu.yml"
267
- - ".github/workflows/windows.yml"
268
265
  - ".gitignore"
269
266
  - ".hound.yml"
270
267
  - ".oss-guides.rubocop.yml"
@@ -295,10 +292,8 @@ files:
295
292
  - lib/asciidoctor/iso/isostandard-amd.rng
296
293
  - lib/asciidoctor/iso/isostandard.rnc
297
294
  - lib/asciidoctor/iso/isostandard.rng
298
- - lib/asciidoctor/iso/macros.rb
299
295
  - lib/asciidoctor/iso/reqt.rng
300
296
  - lib/asciidoctor/iso/section.rb
301
- - lib/asciidoctor/iso/term_lookup_cleanup.rb
302
297
  - lib/asciidoctor/iso/validate.rb
303
298
  - lib/asciidoctor/iso/validate_requirements.rb
304
299
  - lib/asciidoctor/iso/validate_section.rb
@@ -348,7 +343,6 @@ files:
348
343
  - spec/asciidoctor-iso/cleanup_spec.rb
349
344
  - spec/asciidoctor-iso/inline_spec.rb
350
345
  - spec/asciidoctor-iso/lists_spec.rb
351
- - spec/asciidoctor-iso/macros_spec.rb
352
346
  - spec/asciidoctor-iso/refs_spec.rb
353
347
  - spec/asciidoctor-iso/section_spec.rb
354
348
  - spec/asciidoctor-iso/table_spec.rb
@@ -1,49 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/ubuntu.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-macos:
15
- name: Test on Ruby ${{ matrix.ruby }} macOS
16
- runs-on: macos-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Cache gems
33
- uses: actions/cache@preview
34
- with:
35
- path: vendor/bundle
36
- key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('Gemfile') }}
37
- restore-keys: |
38
- ${{ runner.os }}-${{ matrix.ruby }}-gem-
39
- - name: Update gems
40
- run: |
41
- gem install bundler
42
- bundle config --local path vendor/bundle
43
- bundle install --jobs 4 --retry 3
44
- - name: Install PlantUML
45
- run: |
46
- brew install plantuml
47
- - name: Run specs
48
- run: |
49
- bundle exec rake
@@ -1,53 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: ubuntu
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-linux:
15
- name: Test on Ruby ${{ matrix.ruby }} Ubuntu
16
- runs-on: ubuntu-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Cache gems
33
- uses: actions/cache@preview
34
- with:
35
- path: vendor/bundle
36
- key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('Gemfile') }}
37
- restore-keys: |
38
- ${{ runner.os }}-${{ matrix.ruby }}-gem-
39
- - name: Update gems
40
- run: |
41
- gem install bundler
42
- bundle config --local path vendor/bundle
43
- bundle install --jobs 4 --retry 3
44
- - name: Install PlantUML
45
- uses: nick-invision/retry@v1
46
- with:
47
- polling_interval_seconds: 5
48
- timeout_minutes: 5
49
- max_attempts: 3
50
- command: sudo apt-get update -y && sudo bash -c "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
51
- - name: Run specs
52
- run: |
53
- bundle exec rake
@@ -1,50 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: windows
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/ubuntu.yml
12
-
13
- jobs:
14
- test-windows:
15
- name: Test on Ruby ${{ matrix.ruby }} Windows
16
- runs-on: windows-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Cache gems
33
- uses: actions/cache@preview
34
- with:
35
- path: vendor/bundle
36
- key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('Gemfile') }}
37
- restore-keys: |
38
- ${{ runner.os }}-${{ matrix.ruby }}-gem-
39
- - name: Update gems
40
- shell: pwsh
41
- run: |
42
- gem install bundler
43
- bundle config --local path vendor/bundle
44
- bundle install --jobs 4 --retry 3
45
- - name: Install PlantUML
46
- run: |
47
- cinst -y plantuml
48
- - name: Run specs
49
- run: |
50
- bundle exec rake
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'asciidoctor/extensions'
4
-
5
- module Asciidoctor
6
- module Iso
7
- # Macro to transform `term[X,Y]` into em, termxref xml
8
- class TermRefInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
9
- use_dsl
10
-
11
- named :term
12
- name_positional_attributes 'name', 'termxref'
13
- using_format :short
14
-
15
- def process(_parent, _target, attrs)
16
- termref = attrs['termxref'] || attrs['name']
17
- "<em>#{attrs['name']}</em> (<termxref>#{termref}</termxref>)"
18
- end
19
- end
20
- end
21
- end
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true.
2
-
3
- module Asciidoctor
4
- module ISO
5
- # Intelligent term lookup xml modifier
6
- # Lookup all `term` and `calause` tags and replace `termxref` tags with
7
- # `xref`:target tag
8
- class TermLookupCleanup
9
- AUTOMATIC_GENERATED_ID_REGEXP = /\A_/
10
- EXISTING_TERM_REGEXP = /\Aterm-/
11
-
12
- attr_reader :xmldoc, :termlookup, :log
13
-
14
- def initialize(xmldoc, log)
15
- @xmldoc = xmldoc
16
- @log = log
17
- @termlookup = {}
18
- end
19
-
20
- def call
21
- @termlookup = replace_automatic_generated_ids_terms
22
- set_termxref_tags_target
23
- end
24
-
25
- private
26
-
27
- def set_termxref_tags_target
28
- xmldoc.xpath('//termxref').each do |node|
29
- target = normalize_ref_id(node.text)
30
- if termlookup[target].nil?
31
- remove_missing_ref(node, target)
32
- next
33
- end
34
- modify_ref_node(node, target)
35
- end
36
- end
37
-
38
- def remove_missing_ref(node, target)
39
- log.add('AsciiDoc Input', node,
40
- %(Error: Term reference in `term[#{target}]` missing: \
41
- "#{target}" is not defined in document))
42
- term_name_node = node.previous.previous
43
- term_name_node.remove
44
- term_name_node.name = "strong"
45
- term_name_node.children.first.content =
46
- %(term "#{term_name_node.text}" not resolved)
47
- node.add_previous_sibling(term_name_node)
48
- node.remove
49
- end
50
-
51
- def modify_ref_node(node, target)
52
- node.name = 'xref'
53
- node['target'] = termlookup[target]
54
- node.children.remove
55
- node.remove_attribute('defaultref')
56
- end
57
-
58
- def replace_automatic_generated_ids_terms
59
- xmldoc.xpath('//term').each.with_object({}) do |term_node, res|
60
- normalize_id_and_memorize(term_node, res, './preferred')
61
- end
62
- end
63
-
64
- def normalize_id_and_memorize(term_node, res_table, text_selector)
65
- term_text = normalize_ref_id(term_node.at(text_selector).text)
66
- unless AUTOMATIC_GENERATED_ID_REGEXP.match(term_node['id']).nil?
67
- term_node['id'] = unique_text_id(term_text)
68
- end
69
- res_table[term_text] = term_node['id']
70
- end
71
-
72
- def normalize_ref_id(text)
73
- text.downcase.gsub(/[[:space:]]/, '-')
74
- end
75
-
76
- def unique_text_id(text)
77
- return "term-#{text}" if xmldoc.at("//*[@id = 'term-#{text}']").nil?
78
- (1..Float::INFINITY).lazy.each do |index|
79
- if xmldoc.at("//*[@id = 'term-#{text}-#{index}']").nil?
80
- break("term-#{text}-#{index}")
81
- end
82
- end
83
- end
84
- end
85
- end
86
- end