slaw 6.0.0 → 6.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdb72dfa4cdb03a7ff80f8d22e6f6dc5801b95902fb483b50df587a7618ce45b
4
- data.tar.gz: 50df42fb88aa1a011598d6a021c19b4ecc49d8d32de51652ac3f9900da412160
3
+ metadata.gz: 14d30911a95f4b2df4507204aaa258648e85b7ff5db433bee29a09e00db590cb
4
+ data.tar.gz: 78daa536d0a071cffe417ad1725c5efc91eeadee0d586614c7367da91276c4d7
5
5
  SHA512:
6
- metadata.gz: dded061c797a8d698c81a649816f6201bf1f7214e93531a5a41a3156c75c3ff06ef76aacf6d65bdd7aa5abbab05dfe8c61d37a5daa3d261106b8c1729c750d7a
7
- data.tar.gz: 1e071331cac41c9a65455c0053c9ba36f6c52d34d733ac59de547612075b322b4f3fd5393bba2d471049c6e8aaf2715eeb06c1a6d7f09b742cfd447f0260b5a5
6
+ metadata.gz: 2ad32f72ce446e4df09fd5ef9bf8bd613edec1e4f3444c8ca6814da455157c8c57abda56896faff5bb0a1cff6b0d3a8f054f364daaab86ee620fc2f83c26db28
7
+ data.tar.gz: 4c87efed3e68c8b304a8ae41984d0ef5198d649f8f24d2c85d3053ccfed3fe787b8d4bcab29bd7cfe346131f350035d93ec24df449042e0e80bbf6ab49476f18
data/README.md CHANGED
@@ -81,6 +81,10 @@ You can create your own grammar by creating a gem that provides these files and
81
81
 
82
82
  ## Changelog
83
83
 
84
+ ### 6.1.0 (6 Jan 2020)
85
+
86
+ * Support Chapters inside Parts
87
+
84
88
  ### 6.0.0 (7 Nov 2019)
85
89
 
86
90
  * Give grammars the opportunity to post-process generated XML
@@ -47,18 +47,34 @@ module Slaw
47
47
  children:(chapter / part / section / subsection / generic_container)* <Body>
48
48
  end
49
49
 
50
+ # chapter (parts allowed)
50
51
  rule chapter
51
52
  heading:chapter_heading
52
- children:(part / section / subsection / generic_container)*
53
+ children:(part_no_chapter / section / subsection / generic_container)*
53
54
  <Chapter>
54
55
  end
55
56
 
57
+ # part (chapters allowed)
56
58
  rule part
59
+ heading:part_heading
60
+ children:(chapter_no_part / section / subsection / generic_container)*
61
+ <Part>
62
+ end
63
+
64
+ # part (no chapters)
65
+ rule part_no_chapter
57
66
  heading:part_heading
58
67
  children:(section / subsection / generic_container)*
59
68
  <Part>
60
69
  end
61
70
 
71
+ # chapter (no parts)
72
+ rule chapter_no_part
73
+ heading:chapter_heading
74
+ children:(section / subsection / generic_container)*
75
+ <Chapter>
76
+ end
77
+
62
78
  rule section
63
79
  section_title
64
80
  children:(subsection / generic_container)* <Section>
@@ -106,10 +122,18 @@ module Slaw
106
122
  children:chapter+ <GroupNode>
107
123
  end
108
124
 
125
+ rule chapters_no_parts
126
+ children:chapter_no_part+ <GroupNode>
127
+ end
128
+
109
129
  rule parts
110
130
  children:part+ <GroupNode>
111
131
  end
112
132
 
133
+ rule parts_no_chapters
134
+ children:part_no_chapter+ <GroupNode>
135
+ end
136
+
113
137
  rule sections
114
138
  children:section+ <GroupNode>
115
139
  end
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "6.0.0"
2
+ VERSION = "6.1.0"
3
3
  end
@@ -429,6 +429,42 @@ EOS
429
429
  <p>More stuff</p>
430
430
  </content>
431
431
  </paragraph>
432
+ </chapter>'
433
+ end
434
+
435
+ it 'should allow parts in chapters' do
436
+ node = parse :chapter, <<EOS
437
+ Chapter 1 - Chapter One
438
+
439
+ Part 1 - Chapter One Part One
440
+
441
+ one-one
442
+
443
+ Part 2 - Chapter One Part Two
444
+
445
+ one-two
446
+ EOS
447
+ to_xml(node).should == '<chapter id="chapter-1">
448
+ <num>1</num>
449
+ <heading>Chapter One</heading>
450
+ <part id="chapter-1.part-1">
451
+ <num>1</num>
452
+ <heading>Chapter One Part One</heading>
453
+ <paragraph id="chapter-1.part-1.paragraph0">
454
+ <content>
455
+ <p>one-one</p>
456
+ </content>
457
+ </paragraph>
458
+ </part>
459
+ <part id="chapter-1.part-2">
460
+ <num>2</num>
461
+ <heading>Chapter One Part Two</heading>
462
+ <paragraph id="chapter-1.part-2.paragraph0">
463
+ <content>
464
+ <p>one-two</p>
465
+ </content>
466
+ </paragraph>
467
+ </part>
432
468
  </chapter>'
433
469
  end
434
470
  end
@@ -682,6 +718,42 @@ EOS
682
718
  </part>
683
719
  </body>'
684
720
  end
721
+
722
+ it 'should allow chapters in parts' do
723
+ node = parse :part, <<EOS
724
+ Part 1 - Part One
725
+
726
+ Chapter 1 - Part One Chapter One
727
+
728
+ one-one
729
+
730
+ Chapter 2 - Part One Chapter Two
731
+
732
+ one-two
733
+ EOS
734
+ to_xml(node).should == '<part id="part-1">
735
+ <num>1</num>
736
+ <heading>Part One</heading>
737
+ <chapter id="part-1.chapter-1">
738
+ <num>1</num>
739
+ <heading>Part One Chapter One</heading>
740
+ <paragraph id="part-1.chapter-1.paragraph0">
741
+ <content>
742
+ <p>one-one</p>
743
+ </content>
744
+ </paragraph>
745
+ </chapter>
746
+ <chapter id="part-1.chapter-2">
747
+ <num>2</num>
748
+ <heading>Part One Chapter Two</heading>
749
+ <paragraph id="part-1.chapter-2.paragraph0">
750
+ <content>
751
+ <p>one-two</p>
752
+ </content>
753
+ </paragraph>
754
+ </chapter>
755
+ </part>'
756
+ end
685
757
  end
686
758
 
687
759
  #-------------------------------------------------------------------------------
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: 6.0.0
4
+ version: 6.1.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-11-07 00:00:00.000000000 Z
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake