slaw 0.10.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93a820ba2ec4e18e12c5a9935a954ad314dfc614
4
- data.tar.gz: 6bed26afa25207e66575795a1f94b8504e040009
3
+ metadata.gz: 6e97aa37515b9c1ca126afd8a7ede5e1e614ffea
4
+ data.tar.gz: c2c85c2ac10c4da253edcde157f8a8b9ae3ad27e
5
5
  SHA512:
6
- metadata.gz: 7ff709e7d9931573ae661cad219350917bb352120aa7507d18589df6c47f2bd5e1e2066cc924393e1a98f2a40884363603b8e0e73ef82a125cb942af238e4860
7
- data.tar.gz: 0d8f14587a3d706cdf32450dafc0a28e0a28b6bf9f6ca968a64f0c044f0072a21d36e62061457011a5b68ca42b14be6863bf1b05a7a1e6b48b01c1684acc3749
6
+ metadata.gz: 34332cfccb221e26870c8e1dfc29238b1471b8d8e7babc6fb7b66cf80faddf10a00b6d2d8b0dd1c001abf26e1940e7d15fafda2e90929630d9901d81562864e4
7
+ data.tar.gz: 57c9065e4f9031295ad7082ceed7d69201510939952b072f1dfa8baeadaa32432bc69777b389a651c58aea2b80865a785cea54d29ab3e41d02faf825ec08333b
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.1.0
5
- - 2.1.1
3
+ - 2.1.10
4
+ - 2.2.5
5
+ - 2.3.1
6
6
  before_install:
7
7
  - gem update bundler
data/README.md CHANGED
@@ -218,6 +218,10 @@ Akoma Ntoso `component` elements at the end of the XML document, with a name of
218
218
 
219
219
  ## Changelog
220
220
 
221
+ ### 0.10.1
222
+
223
+ * Ensure backslash escaping handles listIntroductions and partial words correctly
224
+
221
225
  ### 0.10.0
222
226
 
223
227
  * New command `unparse FILE` which transforms an Akoma Ntoso XML document into plain text, suitable for re-parsing
data/lib/slaw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -6,6 +6,28 @@
6
6
  <xsl:output method="text" indent="no" omit-xml-declaration="yes" />
7
7
  <xsl:strip-space elements="*"/>
8
8
 
9
+ <!-- adds a backslash to the start of the value param, if necessary -->
10
+ <xsl:template name="escape">
11
+ <xsl:param name="value"/>
12
+
13
+ <xsl:variable name="prefix" select="translate(substring($value, 1, 10), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
14
+ <xsl:variable name="numprefix" select="translate(substring($value, 1, 3), '1234567890', 'NNNNNNNNNN')" />
15
+
16
+ <!-- p tags must escape initial content that looks like a block element marker -->
17
+ <xsl:if test="$prefix = 'BODY' or
18
+ $prefix = 'PREAMBLE' or
19
+ $prefix = 'PREFACE' or
20
+ starts-with($prefix, 'CHAPTER ') or
21
+ starts-with($prefix, 'PART ') or
22
+ starts-with($prefix, 'SCHEDULE ') or
23
+ starts-with($prefix, '{|') or
24
+ starts-with($numprefix, '(') or
25
+ starts-with($numprefix, 'N.')">
26
+ <xsl:text>\</xsl:text>
27
+ </xsl:if>
28
+ <xsl:value-of select="$value"/>
29
+ </xsl:template>
30
+
9
31
  <xsl:template match="a:act">
10
32
  <xsl:apply-templates select="a:coverPage" />
11
33
  <xsl:apply-templates select="a:preface" />
@@ -81,28 +103,21 @@
81
103
  </xsl:template>
82
104
 
83
105
  <xsl:template match="a:p">
84
- <xsl:variable name="prefix" select="translate(substring(., 1, 10), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
85
- <xsl:variable name="numprefix" select="translate(substring(., 1, 3), '1234567890', 'NNNNNNNNNN')" />
86
-
87
- <!-- p tags must escape initial content that looks like a block element marker -->
88
- <xsl:if test="starts-with($prefix, 'BODY') or
89
- starts-with($prefix, 'CHAPTER') or
90
- starts-with($prefix, 'PART') or
91
- starts-with($prefix, 'PREAMBLE') or
92
- starts-with($prefix, 'PREFACE') or
93
- starts-with($prefix, 'SCHEDULE') or
94
- starts-with($prefix, '{|') or
95
- starts-with($numprefix, '(') or
96
- starts-with($numprefix, 'N.')">
97
- <xsl:text>\</xsl:text>
98
- </xsl:if>
99
- <xsl:value-of select="."/>
106
+ <xsl:call-template name="escape">
107
+ <xsl:with-param name="value" select="." />
108
+ </xsl:call-template>
100
109
  <!-- p tags must end with a newline -->
101
110
  <xsl:text>
102
111
 
103
112
  </xsl:text>
104
113
  </xsl:template>
105
114
 
115
+ <xsl:template match="a:listIntroduction|a:intro">
116
+ <xsl:call-template name="escape">
117
+ <xsl:with-param name="value" select="." />
118
+ </xsl:call-template>
119
+ </xsl:template>
120
+
106
121
  <xsl:template match="a:blockList">
107
122
  <xsl:if test="a:listIntroduction != ''">
108
123
  <xsl:apply-templates select="a:listIntroduction" />
@@ -47,11 +47,17 @@ Some content.
47
47
  <paragraph id="section-1.paragraph-0">
48
48
  <content>
49
49
  <p>Chapter 2 ignored</p>
50
+ <p>Chapters</p>
50
51
  <p>Part 2 ignored</p>
52
+ <p>participation</p>
51
53
  <p>Schedule 2 ignored</p>
52
- <p>BODY ignored</p>
53
- <p>PREAMBLE ignored</p>
54
- <p>PREFACE ignored</p>
54
+ <p>Schedules</p>
55
+ <p>BODY not escaped</p>
56
+ <p>BODY</p>
57
+ <p>PREAMBLE not escaped</p>
58
+ <p>PREAMBLE</p>
59
+ <p>PREFACE not escaped</p>
60
+ <p>PREFACE</p>
55
61
  <p>2. ignored</p>
56
62
  <p>2.1 ignored</p>
57
63
  <p>(2) ignored</p>
@@ -68,15 +74,27 @@ XML
68
74
 
69
75
  \Chapter 2 ignored
70
76
 
77
+ Chapters
78
+
71
79
  \Part 2 ignored
72
80
 
81
+ participation
82
+
73
83
  \Schedule 2 ignored
74
84
 
75
- \BODY ignored
85
+ Schedules
86
+
87
+ BODY not escaped
88
+
89
+ \BODY
90
+
91
+ PREAMBLE not escaped
92
+
93
+ \PREAMBLE
76
94
 
77
- \PREAMBLE ignored
95
+ PREFACE not escaped
78
96
 
79
- \PREFACE ignored
97
+ \PREFACE
80
98
 
81
99
  \2. ignored
82
100
 
@@ -90,6 +108,40 @@ XML
90
108
 
91
109
  \{| ignored
92
110
 
111
+ '
112
+ end
113
+
114
+ it 'should escape listIntros when unparsing' do
115
+ doc = xml2doc(section(<<XML
116
+ <num>1.</num>
117
+ <heading>Section</heading>
118
+ <paragraph id="section-9.paragraph-0">
119
+ <content>
120
+ <blockList id="section-9.paragraph-0.list1">
121
+ <listIntroduction>(2) A special meeting:</listIntroduction>
122
+ <item id="section-9.paragraph-0.list1.a">
123
+ <num>(a)</num>
124
+ <p>the chairperson so directs; or</p>
125
+ </item>
126
+ <item id="section-9.paragraph-0.list1.b">
127
+ <num>(b)</num>
128
+ <p>a majority of the members</p>
129
+ </item>
130
+ </blockList>
131
+ </content>
132
+ </paragraph>
133
+ XML
134
+ ))
135
+
136
+ text = subject.text_from_act(doc)
137
+ text.should == '1. Section
138
+
139
+ \(2) A special meeting:
140
+
141
+ (a) the chairperson so directs; or
142
+
143
+ (b) a majority of the members
144
+
93
145
  '
94
146
  end
95
147
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slaw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Kempe