metanorma-plugin-datastruct 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc634fc7a6b9a9f552e22cc95a4ca8175398003670fb00a8e6570f12adf735ac
|
4
|
+
data.tar.gz: 5a39bb7f4053fcfba93e50a0f78eca3d127c0a088f48c1f8db4c4606fc8fc3af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e09440e5e49f8293720973e657b93dd46bf51c0a5952364aa45b8638dc7605ce27ec146bc0057fa677f4e6ae4b26f08576b3c729956473ffbf099e882bf2a4c9
|
7
|
+
data.tar.gz: a7da83aabbfaa3907355af04304551eb7eb829d304ddca8ef0e06072801f082e842565c79b2fce6ddd483503cac17fcacfc88dfb454699f376662b9db97ebd84
|
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
|
@@ -19,6 +19,14 @@ Liquid::Template
|
|
19
19
|
Liquid::CustomBlocks::WithJsonNestedContext)
|
20
20
|
Liquid::Template.register_filter(Liquid::CustomFilters)
|
21
21
|
|
22
|
+
module Asciidoctor
|
23
|
+
class PreprocessorNoIfdefsReader < PreprocessorReader
|
24
|
+
def preprocess_conditional_directive(_keyword, _target, _delimiter, _text)
|
25
|
+
false # decline to resolve idefs
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
22
30
|
module Metanorma
|
23
31
|
module Plugin
|
24
32
|
module Datastruct
|
@@ -29,15 +37,15 @@ module Metanorma
|
|
29
37
|
BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z/.freeze
|
30
38
|
|
31
39
|
def process(document, reader)
|
32
|
-
|
40
|
+
r = ::Asciidoctor::PreprocessorNoIfdefsReader
|
41
|
+
.new document, reader.lines
|
42
|
+
input_lines = r.readlines
|
33
43
|
Metanorma::Plugin::Datastruct::SourceExtractor.extract(
|
34
44
|
document,
|
35
45
|
input_lines,
|
36
46
|
)
|
37
|
-
|
38
|
-
|
39
|
-
processed_lines(document, input_lines.to_enum),
|
40
|
-
)
|
47
|
+
Asciidoctor::PreprocessorNoIfdefsReader
|
48
|
+
.new(document, processed_lines(document, input_lines.to_enum))
|
41
49
|
end
|
42
50
|
|
43
51
|
protected
|
@@ -62,7 +70,7 @@ module Metanorma
|
|
62
70
|
|
63
71
|
def relative_file_path(document, file_path)
|
64
72
|
docfile_directory = File.dirname(
|
65
|
-
document.attributes["docfile"] || "."
|
73
|
+
document.attributes["docfile"] || ".",
|
66
74
|
)
|
67
75
|
document
|
68
76
|
.path_resolver
|
@@ -151,7 +159,7 @@ module Metanorma
|
|
151
159
|
.gsub(/(?<!{){(?!%)([^{}]+)(?<!%)}(?!})/, '{{\1}}')
|
152
160
|
.gsub(/[a-z\.]+\#/, "index")
|
153
161
|
.gsub(/{{(.+)\s+\+\s+(\d+)\s*?}}/, '{{ \1 | plus: \2 }}')
|
154
|
-
.gsub(/{{(.+)\s
|
162
|
+
.gsub(/{{(.+)\s+-\s+(\d+)\s*?}}/, '{{ \1 | minus: \2 }}')
|
155
163
|
.gsub(/{{(.+)\.values(.*?)}}/,
|
156
164
|
'{% assign custom_value = \1 | values %}{{custom_value\2}}')
|
157
165
|
end
|
@@ -164,7 +172,7 @@ module Metanorma
|
|
164
172
|
template_string: context_lines.join("\n"),
|
165
173
|
context_items: context_items,
|
166
174
|
context_name: context_name,
|
167
|
-
document: document
|
175
|
+
document: document,
|
168
176
|
)
|
169
177
|
notify_render_errors(document, errors)
|
170
178
|
render_result.split("\n")
|
@@ -174,7 +182,8 @@ module Metanorma
|
|
174
182
|
context_name:, document:)
|
175
183
|
liquid_template = Liquid::Template.parse(template_string)
|
176
184
|
# Allow includes for the template
|
177
|
-
liquid_template.registers[:file_system] =
|
185
|
+
liquid_template.registers[:file_system] =
|
186
|
+
::Liquid::LocalFileSystem.new(relative_file_path(document, ""))
|
178
187
|
rendered_string = liquid_template
|
179
188
|
.render(context_name => context_items,
|
180
189
|
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
|
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.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|