metanorma-standoc 1.6.0 → 1.6.5

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +66 -0
  3. data/README.adoc +1 -3
  4. data/lib/asciidoctor/standoc/base.rb +8 -16
  5. data/lib/asciidoctor/standoc/basicdoc.rng +32 -0
  6. data/lib/asciidoctor/standoc/cleanup.rb +52 -4
  7. data/lib/asciidoctor/standoc/cleanup_block.rb +41 -4
  8. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
  9. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +25 -0
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +6 -2
  11. data/lib/asciidoctor/standoc/cleanup_ref.rb +18 -25
  12. data/lib/asciidoctor/standoc/cleanup_terms.rb +3 -0
  13. data/lib/asciidoctor/standoc/converter.rb +61 -3
  14. data/lib/asciidoctor/standoc/front.rb +9 -3
  15. data/lib/asciidoctor/standoc/front_contributor.rb +34 -10
  16. data/lib/asciidoctor/standoc/isodoc.rng +29 -44
  17. data/lib/asciidoctor/standoc/lists.rb +4 -2
  18. data/lib/asciidoctor/standoc/macros.rb +45 -63
  19. data/lib/asciidoctor/standoc/macros_terms.rb +82 -0
  20. data/lib/asciidoctor/standoc/ref.rb +24 -36
  21. data/lib/asciidoctor/standoc/ref_sect.rb +16 -8
  22. data/lib/asciidoctor/standoc/section.rb +5 -9
  23. data/lib/asciidoctor/standoc/table.rb +12 -0
  24. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +86 -0
  25. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  26. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  27. data/lib/metanorma/standoc/version.rb +1 -1
  28. data/metanorma-standoc.gemspec +6 -3
  29. data/spec/asciidoctor-standoc/base_spec.rb +127 -8
  30. data/spec/asciidoctor-standoc/blocks_spec.rb +8 -8
  31. data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1514 -0
  32. data/spec/asciidoctor-standoc/cleanup_spec.rb +450 -1554
  33. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +22 -31
  34. data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
  35. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +1 -1
  36. data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
  37. data/spec/asciidoctor-standoc/macros_plantuml_spec.rb +307 -0
  38. data/spec/asciidoctor-standoc/macros_spec.rb +378 -169
  39. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +1 -1
  40. data/spec/asciidoctor-standoc/refs_dl_spec.rb +8 -8
  41. data/spec/asciidoctor-standoc/refs_spec.rb +350 -101
  42. data/spec/asciidoctor-standoc/section_spec.rb +11 -11
  43. data/spec/asciidoctor-standoc/table_spec.rb +86 -0
  44. data/spec/asciidoctor-standoc/validate_spec.rb +26 -0
  45. data/spec/fixtures/diagram_definitions.lutaml +22 -0
  46. data/spec/fixtures/test.exp +121 -0
  47. data/spec/spec_helper.rb +33 -0
  48. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +156 -4
  49. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +49 -233
  50. data/spec/vcr_cassettes/isobib_get_123.yml +12 -58
  51. data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -119
  52. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  53. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -58
  54. data/spec/vcr_cassettes/isobib_get_124.yml +11 -57
  55. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  56. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +276 -158
  57. metadata +61 -14
  58. data/.github/workflows/macos.yml +0 -41
  59. data/.github/workflows/ubuntu.yml +0 -45
  60. data/.github/workflows/windows.yml +0 -43
  61. data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +0 -123
  62. data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +0 -44
  63. data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +0 -46
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.5
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-09-26 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.0
47
+ version: 1.3.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.2.0
54
+ version: 1.3.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: iev
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,34 +66,62 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.2.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: metanorma-plugin-datastruct
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: metanorma-plugin-lutaml
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.2.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.2.1
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: relaton-cli
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: 1.4.0
103
+ version: 1.7.0
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: 1.4.0
110
+ version: 1.7.0
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: relaton-iev
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: 1.0.0
117
+ version: 1.1.0
90
118
  type: :runtime
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: 1.0.0
124
+ version: 1.1.0
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: sterile
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +206,20 @@ dependencies:
178
206
  - - ">="
179
207
  - !ruby/object:Gem::Version
180
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: fontist
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: 1.5.0
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: 1.5.0
181
223
  - !ruby/object:Gem::Dependency
182
224
  name: byebug
183
225
  requirement: !ruby/object:Gem::Requirement
@@ -357,9 +399,7 @@ extensions: []
357
399
  extra_rdoc_files: []
358
400
  files:
359
401
  - ".gitattributes"
360
- - ".github/workflows/macos.yml"
361
- - ".github/workflows/ubuntu.yml"
362
- - ".github/workflows/windows.yml"
402
+ - ".github/workflows/rake.yml"
363
403
  - ".gitignore"
364
404
  - ".hound.yml"
365
405
  - ".oss-guides.rubocop.yml"
@@ -376,7 +416,6 @@ files:
376
416
  - bin/rspec
377
417
  - docs/quickstart.adoc
378
418
  - lib/asciidoctor/standoc/base.rb
379
- - lib/asciidoctor/standoc/base_structured_text_preprocessor.rb
380
419
  - lib/asciidoctor/standoc/basicdoc.rng
381
420
  - lib/asciidoctor/standoc/biblio.rng
382
421
  - lib/asciidoctor/standoc/blocks.rb
@@ -398,24 +437,26 @@ files:
398
437
  - lib/asciidoctor/standoc/front_contributor.rb
399
438
  - lib/asciidoctor/standoc/inline.rb
400
439
  - lib/asciidoctor/standoc/isodoc.rng
401
- - lib/asciidoctor/standoc/json2_text_preprocessor.rb
402
440
  - lib/asciidoctor/standoc/lists.rb
403
441
  - lib/asciidoctor/standoc/log.rb
404
442
  - lib/asciidoctor/standoc/macros.rb
405
443
  - lib/asciidoctor/standoc/macros_plantuml.rb
444
+ - lib/asciidoctor/standoc/macros_terms.rb
406
445
  - lib/asciidoctor/standoc/ref.rb
407
446
  - lib/asciidoctor/standoc/ref_sect.rb
408
447
  - lib/asciidoctor/standoc/reqt.rb
409
448
  - lib/asciidoctor/standoc/reqt.rng
410
449
  - lib/asciidoctor/standoc/section.rb
411
450
  - lib/asciidoctor/standoc/table.rb
451
+ - lib/asciidoctor/standoc/term_lookup_cleanup.rb
412
452
  - lib/asciidoctor/standoc/utils.rb
413
453
  - lib/asciidoctor/standoc/validate.rb
414
454
  - lib/asciidoctor/standoc/validate_section.rb
415
455
  - lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb
416
456
  - lib/asciidoctor/standoc/views/datamodel/plantuml_representation.adoc.erb
417
- - lib/asciidoctor/standoc/yaml2_text_preprocessor.rb
418
457
  - lib/liquid/custom_blocks/key_iterator.rb
458
+ - lib/liquid/custom_blocks/with_json_nested_context.rb
459
+ - lib/liquid/custom_blocks/with_yaml_nested_context.rb
419
460
  - lib/liquid/custom_filters/values.rb
420
461
  - lib/metanorma-standoc.rb
421
462
  - lib/metanorma/standoc.rb
@@ -424,6 +465,7 @@ files:
424
465
  - metanorma-standoc.gemspec
425
466
  - spec/asciidoctor-standoc/base_spec.rb
426
467
  - spec/asciidoctor-standoc/blocks_spec.rb
468
+ - spec/asciidoctor-standoc/cleanup_sections_spec.rb
427
469
  - spec/asciidoctor-standoc/cleanup_spec.rb
428
470
  - spec/asciidoctor-standoc/datamodel/attributes_table_preprocessor_spec.rb
429
471
  - spec/asciidoctor-standoc/datamodel/diagram_preprocessor_spec.rb
@@ -431,6 +473,8 @@ files:
431
473
  - spec/asciidoctor-standoc/isobib_cache_spec.rb
432
474
  - spec/asciidoctor-standoc/lists_spec.rb
433
475
  - spec/asciidoctor-standoc/macros_json2text_spec.rb
476
+ - spec/asciidoctor-standoc/macros_lutaml_spec.rb
477
+ - spec/asciidoctor-standoc/macros_plantuml_spec.rb
434
478
  - spec/asciidoctor-standoc/macros_spec.rb
435
479
  - spec/asciidoctor-standoc/macros_yaml2text_spec.rb
436
480
  - spec/asciidoctor-standoc/refs_dl_spec.rb
@@ -497,17 +541,20 @@ files:
497
541
  - spec/examples/rice_images/rice_image3_1.png
498
542
  - spec/examples/rice_images/rice_image3_2.png
499
543
  - spec/examples/rice_images/rice_image3_3.png
544
+ - spec/fixtures/diagram_definitions.lutaml
500
545
  - spec/fixtures/macros_datamodel/address_class_profile.xml
501
546
  - spec/fixtures/macros_datamodel/address_component_profile.xml
502
547
  - spec/fixtures/macros_datamodel/blank_definition_profile.xml
503
548
  - spec/fixtures/macros_datamodel/common_models_diagram.xml
504
549
  - spec/fixtures/macros_datamodel/top_down_diagram.xml
550
+ - spec/fixtures/test.exp
505
551
  - spec/metanorma/processor_spec.rb
506
552
  - spec/spec_helper.rb
507
553
  - spec/support/shared_examples/structured_data_2_text_preprocessor.rb
508
554
  - spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml
509
555
  - spec/vcr_cassettes/isobib_get_123.yml
510
556
  - spec/vcr_cassettes/isobib_get_123_1.yml
557
+ - spec/vcr_cassettes/isobib_get_123_1_fr.yml
511
558
  - spec/vcr_cassettes/isobib_get_123_2001.yml
512
559
  - spec/vcr_cassettes/isobib_get_124.yml
513
560
  - spec/vcr_cassettes/rfcbib_get_rfc8341.yml
@@ -1,41 +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: Update gems
33
- run: |
34
- sudo gem install bundler --force
35
- bundle install --jobs 4 --retry 3
36
- - name: Install PlantUML
37
- run: |
38
- brew install plantuml
39
- - name: Run specs
40
- run: |
41
- bundle exec rake
@@ -1,45 +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: Update gems
33
- run: |
34
- gem install bundler
35
- bundle install --jobs 4 --retry 3
36
- - name: Install PlantUML
37
- uses: nick-invision/retry@v1
38
- with:
39
- polling_interval_seconds: 5
40
- timeout_minutes: 5
41
- max_attempts: 3
42
- command: sudo apt-get update -y && sudo bash -c "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
43
- - name: Run specs
44
- run: |
45
- bundle exec rake
@@ -1,43 +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: Update gems
33
- shell: pwsh
34
- run: |
35
- gem install bundler
36
- bundle config --local path vendor/bundle
37
- bundle install --jobs 4 --retry 3
38
- - name: Install PlantUML
39
- run: |
40
- cinst -y plantuml
41
- - name: Run specs
42
- run: |
43
- bundle exec rake
@@ -1,123 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "liquid/custom_blocks/key_iterator"
4
- require "liquid/custom_filters/values"
5
-
6
- Liquid::Template.register_tag("keyiterator", Liquid::CustomBlocks::KeyIterator)
7
- Liquid::Template.register_filter(Liquid::CustomFilters)
8
-
9
- module Asciidoctor
10
- module Standoc
11
- # Base class for processing structured data blocks(yaml, json)
12
- class BaseStructuredTextPreprocessor < Asciidoctor::Extensions::Preprocessor
13
- BLOCK_START_REGEXP = /\{(.+?)\.\*,(.+),(.+)\}/
14
- BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z/
15
-
16
- def process(document, reader)
17
- input_lines = reader.readlines.to_enum
18
- Reader.new(processed_lines(document, input_lines))
19
- end
20
-
21
- protected
22
-
23
- def content_from_file(_document, _file_path)
24
- raise ArgumentError, "Implement `content_from_file` in your class"
25
- end
26
-
27
- private
28
-
29
- def processed_lines(document, input_lines)
30
- result = []
31
- loop do
32
- result.push(*process_text_blocks(document, input_lines))
33
- end
34
- result
35
- end
36
-
37
- def relative_file_path(document, file_path)
38
- docfile_directory = File.dirname(document.attributes["docfile"] || ".")
39
- document
40
- .path_resolver
41
- .system_path(file_path, docfile_directory)
42
- end
43
-
44
- def process_text_blocks(document, input_lines)
45
- line = input_lines.next
46
- block_match = line.match(/^\[#{config[:block_name]},(.+?),(.+?)\]/)
47
- return [line] if block_match.nil?
48
-
49
- mark = input_lines.next
50
- current_block = []
51
- while (block_line = input_lines.next) != mark
52
- current_block.push(block_line)
53
- end
54
- read_content_and_parse_template(document,
55
- current_block,
56
- block_match)
57
- end
58
-
59
- def read_content_and_parse_template(document, current_block, block_match)
60
- transformed_liquid_lines = current_block
61
- .map(&method(:transform_line_liquid))
62
- context_items = content_from_file(document, block_match[1])
63
- parse_context_block(document: document,
64
- context_lines: transformed_liquid_lines,
65
- context_items: context_items,
66
- context_name: block_match[2])
67
- rescue StandardError => exception
68
- document.logger
69
- .warn("Failed to parse #{config[:block_name]} \
70
- block: #{exception.message}")
71
- []
72
- end
73
-
74
- def transform_line_liquid(line)
75
- if line.match?(BLOCK_START_REGEXP)
76
- line.gsub!(BLOCK_START_REGEXP,
77
- '{% keyiterator \1, \2 %}')
78
- end
79
-
80
- if line.strip.match?(BLOCK_END_REGEXP)
81
- line.gsub!(BLOCK_END_REGEXP, "{% endkeyiterator %}")
82
- end
83
- line
84
- .gsub(/(?<!{){(?!%)([^{}]+)(?<!%)}(?!})/, '{{\1}}')
85
- .gsub(/[a-z\.]+\#/, "index")
86
- .gsub(/{{(.+)\s+\+\s+(\d+)\s*?}}/, '{{ \1 | plus: \2 }}')
87
- .gsub(/{{(.+)\s+\-\s+(\d+)\s*?}}/, '{{ \1 | minus: \2 }}')
88
- .gsub(/{{(.+).values(.*?)}}/,
89
- '{% assign custom_value = \1 | values %}{{custom_value\2}}')
90
- end
91
-
92
- def parse_context_block(context_lines:,
93
- context_items:,
94
- context_name:,
95
- document:)
96
- render_result, errors = render_liquid_string(
97
- template_string: context_lines.join("\n"),
98
- context_items: context_items,
99
- context_name: context_name
100
- )
101
- notify_render_errors(document, errors)
102
- render_result.split("\n")
103
- end
104
-
105
- def render_liquid_string(template_string:, context_items:, context_name:)
106
- liquid_template = Liquid::Template.parse(template_string)
107
- rendered_string = liquid_template
108
- .render(context_name => context_items,
109
- strict_variables: true,
110
- error_mode: :warn)
111
- [rendered_string, liquid_template.errors]
112
- end
113
-
114
- def notify_render_errors(document, errors)
115
- errors.each do |error_obj|
116
- document
117
- .logger
118
- .warn("Liquid render error: #{error_obj.message}")
119
- end
120
- end
121
- end
122
- end
123
- end