metanorma-plugin-datastruct 0.2.4 → 0.3.1
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.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +4 -3
- data/Gemfile +6 -2
- data/lib/metanorma/plugin/datastruct/base_structured_text_preprocessor.rb +27 -16
- data/lib/metanorma/plugin/datastruct/source_extractor.rb +2 -1
- data/lib/metanorma/plugin/datastruct/version.rb +1 -1
- data/lib/metanorma/plugin/datastruct/yaml2_text_preprocessor.rb +8 -1
- data/metanorma-plugin-datastruct.gemspec +1 -0
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9afcd660bc9aa57c185e892b9654545e5665ca4fd1dfe6766936929e4103788f
|
4
|
+
data.tar.gz: 027c3feec5d5f497a814aa8a6326b15256055cc18c8e148bd823f9d7b5d8a2e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1d96b5d3628b6995799de038d408df8c6ae26867fac238166f386c3de63ada247154275e7dd42122a2a8493ca5ef7479ec40581d4bc76aa91e9bcd8c8a7d6fc
|
7
|
+
data.tar.gz: d131b05dcb593a958d1de557a66ea960a6bf412fbe922ab7c19b054efa2fb5e453d162468d0d6cd41817d8f95099c7947e772189688709ea3889e795335db719
|
@@ -7,11 +7,12 @@ on:
|
|
7
7
|
inputs:
|
8
8
|
next_version:
|
9
9
|
description: |
|
10
|
-
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
|
11
|
+
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
|
11
12
|
required: true
|
12
13
|
default: 'skip'
|
13
|
-
|
14
|
-
|
14
|
+
repository_dispatch:
|
15
|
+
types: [ do-release ]
|
15
16
|
|
16
17
|
jobs:
|
17
18
|
release:
|
data/Gemfile
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
Encoding.default_external = Encoding::UTF_8
|
2
|
+
Encoding.default_internal = Encoding::UTF_8
|
3
|
+
|
1
4
|
source "https://rubygems.org"
|
5
|
+
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
2
6
|
|
3
|
-
# Specify your gem's dependencies in metanorma-plugin-datastruct.gemspec
|
4
7
|
gemspec
|
5
|
-
|
8
|
+
|
9
|
+
eval_gemfile("Gemfile.devel") rescue nil
|
@@ -10,14 +10,23 @@ require "liquid/custom_filters/values"
|
|
10
10
|
require "liquid/custom_filters/replace_regex"
|
11
11
|
require "metanorma/plugin/datastruct/source_extractor"
|
12
12
|
|
13
|
-
Liquid::
|
14
|
-
Liquid::
|
13
|
+
Liquid::Environment.default
|
14
|
+
.register_tag("keyiterator", Liquid::CustomBlocks::KeyIterator)
|
15
|
+
Liquid::Environment.default
|
15
16
|
.register_tag("with_yaml_nested_context",
|
16
17
|
Liquid::CustomBlocks::WithYamlNestedContext)
|
17
|
-
Liquid::
|
18
|
+
Liquid::Environment.default
|
18
19
|
.register_tag("with_json_nested_context",
|
19
20
|
Liquid::CustomBlocks::WithJsonNestedContext)
|
20
|
-
Liquid::
|
21
|
+
Liquid::Environment.default.register_filter(Liquid::CustomFilters)
|
22
|
+
|
23
|
+
module Asciidoctor
|
24
|
+
class PreprocessorNoIfdefsReader < PreprocessorReader
|
25
|
+
def preprocess_conditional_directive(_keyword, _target, _delimiter, _text)
|
26
|
+
false # decline to resolve idefs
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
21
30
|
|
22
31
|
module Metanorma
|
23
32
|
module Plugin
|
@@ -29,15 +38,15 @@ module Metanorma
|
|
29
38
|
BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z/.freeze
|
30
39
|
|
31
40
|
def process(document, reader)
|
32
|
-
|
41
|
+
r = ::Asciidoctor::PreprocessorNoIfdefsReader
|
42
|
+
.new document, reader.lines
|
43
|
+
input_lines = r.readlines
|
33
44
|
Metanorma::Plugin::Datastruct::SourceExtractor.extract(
|
34
45
|
document,
|
35
46
|
input_lines,
|
36
47
|
)
|
37
|
-
|
38
|
-
|
39
|
-
processed_lines(document, input_lines.to_enum),
|
40
|
-
)
|
48
|
+
Asciidoctor::PreprocessorNoIfdefsReader
|
49
|
+
.new(document, processed_lines(document, input_lines.to_enum))
|
41
50
|
end
|
42
51
|
|
43
52
|
protected
|
@@ -62,7 +71,7 @@ module Metanorma
|
|
62
71
|
|
63
72
|
def relative_file_path(document, file_path)
|
64
73
|
docfile_directory = File.dirname(
|
65
|
-
document.attributes["docfile"] || "."
|
74
|
+
document.attributes["docfile"] || ".",
|
66
75
|
)
|
67
76
|
document
|
68
77
|
.path_resolver
|
@@ -128,14 +137,15 @@ module Metanorma
|
|
128
137
|
content_from_file(document, block_match[1])
|
129
138
|
end
|
130
139
|
|
140
|
+
return if context_items.nil?
|
141
|
+
|
131
142
|
parse_context_block(document: document,
|
132
143
|
context_lines: transformed_liquid_lines,
|
133
144
|
context_items: context_items,
|
134
145
|
context_name: block_match[2].strip)
|
135
146
|
rescue StandardError => e
|
136
|
-
|
137
|
-
|
138
|
-
block: #{e.message}")
|
147
|
+
::Metanorma::Util.log("Failed to parse #{config[:block_name]} \
|
148
|
+
block: #{e.message}", :error)
|
139
149
|
[]
|
140
150
|
end
|
141
151
|
|
@@ -151,7 +161,7 @@ module Metanorma
|
|
151
161
|
.gsub(/(?<!{){(?!%)([^{}]+)(?<!%)}(?!})/, '{{\1}}')
|
152
162
|
.gsub(/[a-z\.]+\#/, "index")
|
153
163
|
.gsub(/{{(.+)\s+\+\s+(\d+)\s*?}}/, '{{ \1 | plus: \2 }}')
|
154
|
-
.gsub(/{{(.+)\s
|
164
|
+
.gsub(/{{(.+)\s+-\s+(\d+)\s*?}}/, '{{ \1 | minus: \2 }}')
|
155
165
|
.gsub(/{{(.+)\.values(.*?)}}/,
|
156
166
|
'{% assign custom_value = \1 | values %}{{custom_value\2}}')
|
157
167
|
end
|
@@ -164,7 +174,7 @@ module Metanorma
|
|
164
174
|
template_string: context_lines.join("\n"),
|
165
175
|
context_items: context_items,
|
166
176
|
context_name: context_name,
|
167
|
-
document: document
|
177
|
+
document: document,
|
168
178
|
)
|
169
179
|
notify_render_errors(document, errors)
|
170
180
|
render_result.split("\n")
|
@@ -174,7 +184,8 @@ module Metanorma
|
|
174
184
|
context_name:, document:)
|
175
185
|
liquid_template = Liquid::Template.parse(template_string)
|
176
186
|
# Allow includes for the template
|
177
|
-
liquid_template.registers[:file_system] =
|
187
|
+
liquid_template.registers[:file_system] =
|
188
|
+
::Liquid::LocalFileSystem.new(relative_file_path(document, ""))
|
178
189
|
rendered_string = liquid_template
|
179
190
|
.render(context_name => context_items,
|
180
191
|
strict_variables: true,
|
@@ -34,7 +34,7 @@ module Metanorma
|
|
34
34
|
line = lines.next
|
35
35
|
|
36
36
|
if /^embed::|^include::/.match?(line.strip)
|
37
|
-
file_lines = read(filename(@document, line))
|
37
|
+
file_lines = read(filename(@document, line)) or next
|
38
38
|
SourceExtractor.extract(@document, file_lines)
|
39
39
|
elsif m = match_anchor(line)
|
40
40
|
@document.attributes["source_blocks"][m[:id]] = read_section lines
|
@@ -57,6 +57,7 @@ module Metanorma
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def read(inc_path)
|
60
|
+
inc_path or return nil
|
60
61
|
::File.open inc_path, "r" do |fd|
|
61
62
|
readlines_safe(fd).map(&:chomp)
|
62
63
|
end
|
@@ -39,8 +39,15 @@ module Metanorma
|
|
39
39
|
|
40
40
|
# https://ruby-doc.org/stdlib-2.5.1/libdoc/psych/rdoc/Psych.html#method-c-safe_load
|
41
41
|
def content_from_file(document, file_path)
|
42
|
+
resolved_file_path = relative_file_path(document, file_path)
|
43
|
+
|
44
|
+
unless File.exist?(resolved_file_path)
|
45
|
+
::Metanorma::Util.log("YAML file referenced in [yaml2text] block not found: #{resolved_file_path}", :error)
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
42
49
|
YAML.safe_load(
|
43
|
-
File.read(
|
50
|
+
File.read(resolved_file_path, encoding: "UTF-8"),
|
44
51
|
permitted_classes: [Date, Time],
|
45
52
|
permitted_symbols: [],
|
46
53
|
aliases: true,
|
@@ -40,5 +40,6 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency "timecop", "~> 0.9"
|
41
41
|
spec.add_development_dependency "vcr", "~> 6.1.0"
|
42
42
|
spec.add_development_dependency "webmock"
|
43
|
+
spec.add_development_dependency "xml-c14n"
|
43
44
|
spec.metadata["rubygems_mfa_required"] = "false"
|
44
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-plugin-datastruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: xml-c14n
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
209
223
|
description: Metanorma plugin for yaml2text and json2text
|
210
224
|
email:
|
211
225
|
- open.source@ribose.com
|
@@ -243,7 +257,7 @@ licenses:
|
|
243
257
|
- BSD-2-Clause
|
244
258
|
metadata:
|
245
259
|
rubygems_mfa_required: 'false'
|
246
|
-
post_install_message:
|
260
|
+
post_install_message:
|
247
261
|
rdoc_options: []
|
248
262
|
require_paths:
|
249
263
|
- lib
|
@@ -258,8 +272,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
272
|
- !ruby/object:Gem::Version
|
259
273
|
version: '0'
|
260
274
|
requirements: []
|
261
|
-
rubygems_version: 3.
|
262
|
-
signing_key:
|
275
|
+
rubygems_version: 3.5.22
|
276
|
+
signing_key:
|
263
277
|
specification_version: 4
|
264
278
|
summary: Metanorma plugin for yaml2text and json2text
|
265
279
|
test_files: []
|