slaw 8.0.1 → 9.0.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 +4 -0
- data/lib/slaw/grammars/za/act.treetop +26 -7
- data/lib/slaw/grammars/za/act_nodes.rb +30 -0
- data/lib/slaw/grammars/za/act_text.xsl +11 -0
- data/lib/slaw/version.rb +1 -1
- data/spec/za/act_block_spec.rb +75 -0
- 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: 6784c4dd73555dd25e51d2f2bc75e547a6c6b067f5c097695d70a00c9b2cedff
|
4
|
+
data.tar.gz: f8424f209e1f681fcb3ea3841b9af2f608a691fe3e929979c4f184b6fe558049
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c3116bf7d489212f239a8b15ec2082141eb92c749109144b49071b4cce35775c1a9753c2117975ec7406b0d6a73d5c1e8ce9f82d213c8a83bf4140d658b5965
|
7
|
+
data.tar.gz: 74ec26e6b94f4417cb50187d0ec183c5b47b9fbf21119e4e814f1c7f57f729ade48440950d669b9cec9e60c355c0eb03eb9efecccdad42b8e11d4a05edb52dd3
|
data/README.md
CHANGED
@@ -44,37 +44,43 @@ module Slaw
|
|
44
44
|
|
45
45
|
rule body
|
46
46
|
('BODY' space? eol)?
|
47
|
-
children:(chapter / part / section / subsection / generic_container)* <Body>
|
47
|
+
children:(chapter / part / subpart / section / subsection / generic_container)* <Body>
|
48
48
|
end
|
49
49
|
|
50
50
|
# chapter (parts allowed)
|
51
51
|
rule chapter
|
52
52
|
heading:chapter_heading
|
53
|
-
children:(part_no_chapter / section / subsection / generic_container)*
|
53
|
+
children:(part_no_chapter / subpart / section / subsection / generic_container)*
|
54
54
|
<Chapter>
|
55
55
|
end
|
56
56
|
|
57
57
|
# part (chapters allowed)
|
58
58
|
rule part
|
59
59
|
heading:part_heading
|
60
|
-
children:(chapter_no_part / section / subsection / generic_container)*
|
60
|
+
children:(chapter_no_part / subpart / section / subsection / generic_container)*
|
61
61
|
<Part>
|
62
62
|
end
|
63
63
|
|
64
64
|
# part (no chapters)
|
65
65
|
rule part_no_chapter
|
66
66
|
heading:part_heading
|
67
|
-
children:(section / subsection / generic_container)*
|
67
|
+
children:(subpart / section / subsection / generic_container)*
|
68
68
|
<Part>
|
69
69
|
end
|
70
70
|
|
71
71
|
# chapter (no parts)
|
72
72
|
rule chapter_no_part
|
73
73
|
heading:chapter_heading
|
74
|
-
children:(section / subsection / generic_container)*
|
74
|
+
children:(subpart / section / subsection / generic_container)*
|
75
75
|
<Chapter>
|
76
76
|
end
|
77
77
|
|
78
|
+
rule subpart
|
79
|
+
heading:subpart_heading
|
80
|
+
children:(section / subsection / generic_container)*
|
81
|
+
<Subpart>
|
82
|
+
end
|
83
|
+
|
78
84
|
rule section
|
79
85
|
section_title
|
80
86
|
children:(subsection / generic_container)* <Section>
|
@@ -134,6 +140,10 @@ module Slaw
|
|
134
140
|
children:part_no_chapter+ <GroupNode>
|
135
141
|
end
|
136
142
|
|
143
|
+
rule subparts
|
144
|
+
children:subpart+ <GroupNode>
|
145
|
+
end
|
146
|
+
|
137
147
|
rule sections
|
138
148
|
children:section+ <GroupNode>
|
139
149
|
end
|
@@ -151,6 +161,11 @@ module Slaw
|
|
151
161
|
<PartHeading>
|
152
162
|
end
|
153
163
|
|
164
|
+
rule subpart_heading
|
165
|
+
space? subpart_heading_prefix heading:(newline? space? inline_items)? eol
|
166
|
+
<SubpartHeading>
|
167
|
+
end
|
168
|
+
|
154
169
|
rule section_title
|
155
170
|
section_title_1 / section_1_title
|
156
171
|
end
|
@@ -241,6 +256,10 @@ module Slaw
|
|
241
256
|
'part'i space alphanums [ :-]*
|
242
257
|
end
|
243
258
|
|
259
|
+
rule subpart_heading_prefix
|
260
|
+
'subpart'i space alphanums [ :-]*
|
261
|
+
end
|
262
|
+
|
244
263
|
rule chapter_heading_prefix
|
245
264
|
'chapter'i space alphanums [ :-]*
|
246
265
|
end
|
@@ -275,12 +294,12 @@ module Slaw
|
|
275
294
|
|
276
295
|
rule body_hierarchy_prefix
|
277
296
|
# Text that indicates the start of a hierarchy element, in the body
|
278
|
-
chapter_heading / part_heading / section_title / schedule_title / subsection_prefix / crossheading
|
297
|
+
chapter_heading / part_heading / subpart_heading / section_title / schedule_title / subsection_prefix / crossheading
|
279
298
|
end
|
280
299
|
|
281
300
|
rule non_body_hierarchy_prefix
|
282
301
|
# Text that indicates the start of a hierarchy element, in the preamble or preface
|
283
|
-
chapter_heading / part_heading / section_title / schedule_title / crossheading
|
302
|
+
chapter_heading / part_heading / subpart_heading / section_title / schedule_title / crossheading
|
284
303
|
end
|
285
304
|
|
286
305
|
include Slaw::Grammars::Inlines
|
@@ -162,6 +162,36 @@ module Slaw
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
+
class Subpart < Treetop::Runtime::SyntaxNode
|
166
|
+
def num
|
167
|
+
heading.num
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_xml(b, id_prefix='', *args)
|
171
|
+
id = id_prefix + "subpart-#{num}"
|
172
|
+
|
173
|
+
b.subpart(id: id) { |b|
|
174
|
+
heading.to_xml(b)
|
175
|
+
children.elements.each_with_index { |e, i| e.to_xml(b, id + '.', i) }
|
176
|
+
}
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
class SubpartHeading < Treetop::Runtime::SyntaxNode
|
181
|
+
def num
|
182
|
+
subpart_heading_prefix.alphanums.text_value
|
183
|
+
end
|
184
|
+
|
185
|
+
def to_xml(b)
|
186
|
+
b.num(num)
|
187
|
+
if heading.respond_to? :inline_items
|
188
|
+
b.heading { |b|
|
189
|
+
heading.inline_items.to_xml(b)
|
190
|
+
}
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
165
195
|
class Chapter < Treetop::Runtime::SyntaxNode
|
166
196
|
def num
|
167
197
|
heading.num
|
@@ -23,6 +23,7 @@
|
|
23
23
|
$prefix = 'PREFACE' or
|
24
24
|
starts-with($prefix, 'CHAPTER ') or
|
25
25
|
starts-with($prefix, 'PART ') or
|
26
|
+
starts-with($prefix, 'SUBPART ') or
|
26
27
|
starts-with($prefix, 'SCHEDULE ') or
|
27
28
|
starts-with($prefix, 'HEADING ') or
|
28
29
|
starts-with($prefix, 'SUBHEADING ') or
|
@@ -74,6 +75,16 @@
|
|
74
75
|
<xsl:apply-templates select="./*[not(self::a:num) and not(self::a:heading)]" />
|
75
76
|
</xsl:template>
|
76
77
|
|
78
|
+
<xsl:template match="a:subpart">
|
79
|
+
<xsl:text>Subpart </xsl:text>
|
80
|
+
<xsl:value-of select="a:num" />
|
81
|
+
<xsl:text> - </xsl:text>
|
82
|
+
<xsl:apply-templates select="a:heading" />
|
83
|
+
<xsl:text> </xsl:text>
|
84
|
+
|
85
|
+
<xsl:apply-templates select="./*[not(self::a:num) and not(self::a:heading)]" />
|
86
|
+
</xsl:template>
|
87
|
+
|
77
88
|
<xsl:template match="a:chapter">
|
78
89
|
<xsl:text>Chapter </xsl:text>
|
79
90
|
<xsl:value-of select="a:num" />
|
data/lib/slaw/version.rb
CHANGED
data/spec/za/act_block_spec.rb
CHANGED
@@ -755,6 +755,81 @@ EOS
|
|
755
755
|
end
|
756
756
|
end
|
757
757
|
|
758
|
+
#-------------------------------------------------------------------------------
|
759
|
+
# Subparts
|
760
|
+
|
761
|
+
describe 'subparts' do
|
762
|
+
it 'should handle subparts' do
|
763
|
+
node = parse :subpart, <<EOS
|
764
|
+
SUBPART 2 - Heading
|
765
|
+
|
766
|
+
1. Section
|
767
|
+
Hello there
|
768
|
+
EOS
|
769
|
+
to_xml(node).should == '<subpart id="subpart-2">
|
770
|
+
<num>2</num>
|
771
|
+
<heading>Heading</heading>
|
772
|
+
<section id="section-1">
|
773
|
+
<num>1.</num>
|
774
|
+
<heading>Section</heading>
|
775
|
+
<paragraph id="section-1.paragraph0">
|
776
|
+
<content>
|
777
|
+
<p>Hello there</p>
|
778
|
+
</content>
|
779
|
+
</paragraph>
|
780
|
+
</section>
|
781
|
+
</subpart>'
|
782
|
+
end
|
783
|
+
|
784
|
+
it 'should handle subparts in parts' do
|
785
|
+
node = parse :part, <<EOS
|
786
|
+
PART A - The Part
|
787
|
+
|
788
|
+
SUBPART 1 - The Subpart 1
|
789
|
+
|
790
|
+
1. Section
|
791
|
+
|
792
|
+
Hello
|
793
|
+
|
794
|
+
SUBPART 2 - The Subpart 2
|
795
|
+
|
796
|
+
2. Section
|
797
|
+
|
798
|
+
Bye
|
799
|
+
EOS
|
800
|
+
to_xml(node).should == '<part id="part-A">
|
801
|
+
<num>A</num>
|
802
|
+
<heading>The Part</heading>
|
803
|
+
<subpart id="part-A.subpart-1">
|
804
|
+
<num>1</num>
|
805
|
+
<heading>The Subpart 1</heading>
|
806
|
+
<section id="section-1">
|
807
|
+
<num>1.</num>
|
808
|
+
<heading>Section</heading>
|
809
|
+
<paragraph id="section-1.paragraph0">
|
810
|
+
<content>
|
811
|
+
<p>Hello</p>
|
812
|
+
</content>
|
813
|
+
</paragraph>
|
814
|
+
</section>
|
815
|
+
</subpart>
|
816
|
+
<subpart id="part-A.subpart-2">
|
817
|
+
<num>2</num>
|
818
|
+
<heading>The Subpart 2</heading>
|
819
|
+
<section id="section-2">
|
820
|
+
<num>2.</num>
|
821
|
+
<heading>Section</heading>
|
822
|
+
<paragraph id="section-2.paragraph0">
|
823
|
+
<content>
|
824
|
+
<p>Bye</p>
|
825
|
+
</content>
|
826
|
+
</paragraph>
|
827
|
+
</section>
|
828
|
+
</subpart>
|
829
|
+
</part>'
|
830
|
+
end
|
831
|
+
end
|
832
|
+
|
758
833
|
#-------------------------------------------------------------------------------
|
759
834
|
# Subsections
|
760
835
|
|
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:
|
4
|
+
version: 9.0.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: 2020-
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|