metanorma-standoc 1.5.3 → 1.6.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 (61) 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 +6 -1
  5. data/lib/asciidoctor/standoc/basicdoc.rng +4 -11
  6. data/lib/asciidoctor/standoc/cleanup.rb +78 -12
  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 +3 -4
  12. data/lib/asciidoctor/standoc/converter.rb +58 -3
  13. data/lib/asciidoctor/standoc/front.rb +9 -3
  14. data/lib/asciidoctor/standoc/front_contributor.rb +43 -11
  15. data/lib/asciidoctor/standoc/inline.rb +18 -40
  16. data/lib/asciidoctor/standoc/isodoc.rng +27 -50
  17. data/lib/asciidoctor/standoc/lists.rb +4 -2
  18. data/lib/asciidoctor/standoc/macros.rb +28 -2
  19. data/lib/asciidoctor/standoc/ref.rb +46 -48
  20. data/lib/asciidoctor/standoc/ref_sect.rb +16 -8
  21. data/lib/asciidoctor/standoc/section.rb +5 -9
  22. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  23. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  24. data/lib/metanorma/standoc.rb +0 -5
  25. data/lib/metanorma/standoc/version.rb +20 -1
  26. data/metanorma-standoc.gemspec +7 -3
  27. data/spec/asciidoctor-standoc/base_spec.rb +246 -9
  28. data/spec/asciidoctor-standoc/blocks_spec.rb +1 -1
  29. data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1514 -0
  30. data/spec/asciidoctor-standoc/cleanup_spec.rb +384 -1547
  31. data/spec/asciidoctor-standoc/inline_spec.rb +128 -4
  32. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +15 -22
  33. data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
  34. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +1 -1
  35. data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
  36. data/spec/asciidoctor-standoc/macros_spec.rb +258 -0
  37. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +1 -1
  38. data/spec/asciidoctor-standoc/refs_dl_spec.rb +8 -8
  39. data/spec/asciidoctor-standoc/refs_spec.rb +362 -104
  40. data/spec/asciidoctor-standoc/validate_spec.rb +26 -0
  41. data/spec/fixtures/diagram_definitions.lutaml +22 -0
  42. data/spec/fixtures/test.exp +121 -0
  43. data/spec/spec_helper.rb +34 -1
  44. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +201 -3
  45. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +47 -231
  46. data/spec/vcr_cassettes/isobib_get_123.yml +14 -60
  47. data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -116
  48. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  49. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
  50. data/spec/vcr_cassettes/isobib_get_124.yml +12 -58
  51. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  52. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +292 -162
  53. metadata +59 -17
  54. data/.github/workflows/macos.yml +0 -46
  55. data/.github/workflows/ubuntu.yml +0 -49
  56. data/.github/workflows/windows.yml +0 -53
  57. data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +0 -123
  58. data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +0 -43
  59. data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +0 -43
  60. data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
  61. data/lib/metanorma/standoc/requirement.rb +0 -13
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.5.3
4
+ version: 1.6.4
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-11 00:00:00.000000000 Z
11
+ date: 2020-11-30 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
@@ -67,33 +67,61 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.2.1
69
69
  - !ruby/object:Gem::Dependency
70
- name: relaton
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
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 1.3.0
89
+ version: 0.2.1
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 1.3.0
96
+ version: 0.2.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: relaton-cli
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.7.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
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,7 +437,6 @@ 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
@@ -414,18 +452,18 @@ files:
414
452
  - lib/asciidoctor/standoc/validate_section.rb
415
453
  - lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb
416
454
  - lib/asciidoctor/standoc/views/datamodel/plantuml_representation.adoc.erb
417
- - lib/asciidoctor/standoc/yaml2_text_preprocessor.rb
418
455
  - lib/liquid/custom_blocks/key_iterator.rb
456
+ - lib/liquid/custom_blocks/with_json_nested_context.rb
457
+ - lib/liquid/custom_blocks/with_yaml_nested_context.rb
419
458
  - lib/liquid/custom_filters/values.rb
420
459
  - lib/metanorma-standoc.rb
421
460
  - lib/metanorma/standoc.rb
422
- - lib/metanorma/standoc/latexml_requirement.rb
423
461
  - lib/metanorma/standoc/processor.rb
424
- - lib/metanorma/standoc/requirement.rb
425
462
  - lib/metanorma/standoc/version.rb
426
463
  - metanorma-standoc.gemspec
427
464
  - spec/asciidoctor-standoc/base_spec.rb
428
465
  - spec/asciidoctor-standoc/blocks_spec.rb
466
+ - spec/asciidoctor-standoc/cleanup_sections_spec.rb
429
467
  - spec/asciidoctor-standoc/cleanup_spec.rb
430
468
  - spec/asciidoctor-standoc/datamodel/attributes_table_preprocessor_spec.rb
431
469
  - spec/asciidoctor-standoc/datamodel/diagram_preprocessor_spec.rb
@@ -433,6 +471,7 @@ files:
433
471
  - spec/asciidoctor-standoc/isobib_cache_spec.rb
434
472
  - spec/asciidoctor-standoc/lists_spec.rb
435
473
  - spec/asciidoctor-standoc/macros_json2text_spec.rb
474
+ - spec/asciidoctor-standoc/macros_lutaml_spec.rb
436
475
  - spec/asciidoctor-standoc/macros_spec.rb
437
476
  - spec/asciidoctor-standoc/macros_yaml2text_spec.rb
438
477
  - spec/asciidoctor-standoc/refs_dl_spec.rb
@@ -499,17 +538,20 @@ files:
499
538
  - spec/examples/rice_images/rice_image3_1.png
500
539
  - spec/examples/rice_images/rice_image3_2.png
501
540
  - spec/examples/rice_images/rice_image3_3.png
541
+ - spec/fixtures/diagram_definitions.lutaml
502
542
  - spec/fixtures/macros_datamodel/address_class_profile.xml
503
543
  - spec/fixtures/macros_datamodel/address_component_profile.xml
504
544
  - spec/fixtures/macros_datamodel/blank_definition_profile.xml
505
545
  - spec/fixtures/macros_datamodel/common_models_diagram.xml
506
546
  - spec/fixtures/macros_datamodel/top_down_diagram.xml
547
+ - spec/fixtures/test.exp
507
548
  - spec/metanorma/processor_spec.rb
508
549
  - spec/spec_helper.rb
509
550
  - spec/support/shared_examples/structured_data_2_text_preprocessor.rb
510
551
  - spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml
511
552
  - spec/vcr_cassettes/isobib_get_123.yml
512
553
  - spec/vcr_cassettes/isobib_get_123_1.yml
554
+ - spec/vcr_cassettes/isobib_get_123_1_fr.yml
513
555
  - spec/vcr_cassettes/isobib_get_123_2001.yml
514
556
  - spec/vcr_cassettes/isobib_get_124.yml
515
557
  - spec/vcr_cassettes/rfcbib_get_rfc8341.yml
@@ -1,46 +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: Install LaTeXML
33
- run: |
34
- brew install libxml2 cpanminus
35
- env PATH=$(brew --prefix libxml2)/bin:$PATH \
36
- cpanm --notest XML::LibXSLT@1.96 git://github.com/brucemiller/LaTeXML.git@9a0e7dc5
37
- - name: Install PlantUML
38
- run: |
39
- brew install plantuml
40
- - name: Update gems
41
- run: |
42
- sudo gem install bundler --force
43
- bundle install --jobs 4 --retry 3
44
- - name: Run specs
45
- run: |
46
- env PATH=$(brew --prefix perl)/bin:$PATH bundle exec rake
@@ -1,49 +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 LaTeXML
37
- run: |
38
- sudo snap install latexml --edge
39
- echo "::add-path::/snap/bin"
40
- - name: Install PlantUML
41
- uses: nick-invision/retry@v1
42
- with:
43
- polling_interval_seconds: 5
44
- timeout_minutes: 5
45
- max_attempts: 3
46
- command: sudo apt-get update -y && sudo bash -c "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
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: 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: Install MN Windows dependencies
33
- shell: pwsh
34
- run: |
35
- choco install --no-progress plantuml make sed gnuwin32-coreutils.install grep
36
- - name: Update gems
37
- shell: pwsh
38
- run: |
39
- gem install bundler
40
- bundle config --local path vendor/bundle
41
- bundle install --jobs 4 --retry 3
42
- - name: Install LaTeXML
43
- shell: cmd
44
- run: |
45
- cinst -y latexml
46
- refreshenv
47
- set PATH=C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;%PATH%
48
- where latexmlmath
49
- - name: Run specs
50
- shell: pwsh
51
- run: |
52
- $env:Path = "C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;$env:Path"
53
- 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