slaw 3.3.2 → 3.4.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.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/slaw/generator.rb +1 -1
- data/lib/slaw/grammars/za/act.treetop +13 -6
- data/lib/slaw/grammars/za/act_nodes.rb +17 -11
- data/lib/slaw/version.rb +1 -1
- data/spec/generator_spec.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82626011b387d28e9bdf0228b027fc2fcd643a8644fa0556c03c5ee7461dc7dd
|
|
4
|
+
data.tar.gz: f2e8cd8e854a5bcb3cd29b14acb9f7f48fa3461dc0e7627caec70c16d7c7d194
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5b854023c84d5c07696fdb8ca62c92774afdd9ad52ede40657e40bf6d280683a000c8d4a2d58ad09a8d4c87ef1d8f621050fdfc46d422c45306b0964da284177
|
|
7
|
+
data.tar.gz: 5359da9d43cd6ebf8e1351a6004db43eb644fab20b312bc86df47361a9b4e267bc9b43e2eacc0014149e5ee898f75e65ff658ea5cf7f6ddd6e37314aa7f51d54
|
data/README.md
CHANGED
|
@@ -81,6 +81,14 @@ You can create your own grammar by creating a gem that provides these files and
|
|
|
81
81
|
|
|
82
82
|
## Changelog
|
|
83
83
|
|
|
84
|
+
### 3.4.0 (20 May 2019)
|
|
85
|
+
|
|
86
|
+
* Restructure subsections to support generic block elements, starting with an inline block element
|
|
87
|
+
|
|
88
|
+
### 3.3.3 (17 May 2019)
|
|
89
|
+
|
|
90
|
+
* FIX bug where unparse was returning XML, not text
|
|
91
|
+
|
|
84
92
|
### 3.3.2 (15 May 2019)
|
|
85
93
|
|
|
86
94
|
* Internal adjustments to make rules easier to override
|
data/lib/slaw/generator.rb
CHANGED
|
@@ -87,7 +87,7 @@ module Slaw
|
|
|
87
87
|
|
|
88
88
|
if dir = $LOAD_PATH.find { |p| File.exist?(p + filename) }
|
|
89
89
|
xslt = Nokogiri::XSLT(File.read(dir + filename))
|
|
90
|
-
xslt.
|
|
90
|
+
xslt.apply_to(doc).gsub(/^( *\n){2,}/, "\n")
|
|
91
91
|
else
|
|
92
92
|
raise "Unable to find text XSL for grammar #{@grammar}: #{fragment}"
|
|
93
93
|
end
|
|
@@ -60,12 +60,7 @@ module Slaw
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
rule subsection
|
|
63
|
-
space? subsection_prefix space?
|
|
64
|
-
# eg: (2) (a) foo
|
|
65
|
-
first_child:inline_block_element?
|
|
66
|
-
# eg: (2)
|
|
67
|
-
eol?
|
|
68
|
-
children:block_element* <Subsection>
|
|
63
|
+
space? subsection_prefix space? block_elements_with_inline <Subsection>
|
|
69
64
|
end
|
|
70
65
|
|
|
71
66
|
rule generic_container
|
|
@@ -77,6 +72,18 @@ module Slaw
|
|
|
77
72
|
<Crossheading>
|
|
78
73
|
end
|
|
79
74
|
|
|
75
|
+
# An option inline block element, followed by consecutive non-structured content.
|
|
76
|
+
# This is useful after a rule that can start a new container and have
|
|
77
|
+
# the first element of the container on the same line, eg.:
|
|
78
|
+
#
|
|
79
|
+
# (1) subsection with content
|
|
80
|
+
# (a) list a...
|
|
81
|
+
#
|
|
82
|
+
rule block_elements_with_inline
|
|
83
|
+
first_child:inline_block_element?
|
|
84
|
+
children:block_element* <BlockElementsWithInline>
|
|
85
|
+
end
|
|
86
|
+
|
|
80
87
|
# Consecutive non-structured content. We allow many elements
|
|
81
88
|
# here so that we wrap consecutive block elements in one <content> tag,
|
|
82
89
|
# rather than multiple containers for each.
|
|
@@ -262,6 +262,22 @@ module Slaw
|
|
|
262
262
|
end
|
|
263
263
|
end
|
|
264
264
|
|
|
265
|
+
class BlockElementsWithInline < Treetop::Runtime::SyntaxNode
|
|
266
|
+
def to_xml(b, idprefix='')
|
|
267
|
+
b.content { |b|
|
|
268
|
+
kids = [first_child] + children.elements
|
|
269
|
+
kids = kids.select { |k| k and !k.text_value.strip.empty? }
|
|
270
|
+
|
|
271
|
+
if kids.empty?
|
|
272
|
+
# schema requires a non-empty content element
|
|
273
|
+
b.p
|
|
274
|
+
else
|
|
275
|
+
kids.each_with_index { |e, i| e.to_xml(b, idprefix, i) }
|
|
276
|
+
end
|
|
277
|
+
}
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
265
281
|
class BlockElements < Treetop::Runtime::SyntaxNode
|
|
266
282
|
@@counters = {}
|
|
267
283
|
|
|
@@ -292,19 +308,9 @@ module Slaw
|
|
|
292
308
|
id = idprefix + num.gsub(/[()]/, '')
|
|
293
309
|
idprefix = id + "."
|
|
294
310
|
|
|
295
|
-
kids = children.elements
|
|
296
|
-
kids = [first_child] + kids if first_child and !first_child.empty?
|
|
297
|
-
|
|
298
311
|
b.subsection(id: id) { |b|
|
|
299
312
|
b.num(num)
|
|
300
|
-
b
|
|
301
|
-
if kids.empty?
|
|
302
|
-
# schema requires a non-empty content element
|
|
303
|
-
b.p
|
|
304
|
-
else
|
|
305
|
-
kids.each_with_index { |e, i| e.to_xml(b, idprefix, i) }
|
|
306
|
-
end
|
|
307
|
-
}
|
|
313
|
+
block_elements_with_inline.to_xml(b, idprefix)
|
|
308
314
|
}
|
|
309
315
|
end
|
|
310
316
|
end
|
data/lib/slaw/version.rb
CHANGED
data/spec/generator_spec.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slaw
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Kempe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-05-
|
|
11
|
+
date: 2019-05-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|