govspeak 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,18 @@
1
+ ## 1.5.2
2
+
3
+ * Fixed over-eager step list matching.
4
+
5
+ ## 1.5.1
6
+
7
+ * Fixed newline matching and operating over multiple list blocks.
8
+
1
9
  ## 1.5.0
2
10
 
3
- Added `$PriorityList:x` construct to class the first `x` list items with
4
- `primary-item`.
5
- Fixed `rcov` dependency.
11
+ * Added `$PriorityList:x` construct to class the first `x` list items with
12
+ `primary-item`.
13
+ * Fixed `rcov` dependency.
6
14
 
7
15
  ## 1.4.0
8
16
 
9
- Added `#structured_headers` method to provide heirarchically structured
10
- headers extracted from markdown text heading tags.
17
+ * Added `#structured_headers` method to provide heirarchically structured
18
+ headers extracted from markdown text heading tags.
@@ -159,7 +159,7 @@ module Govspeak
159
159
  %{<div class="address"><div class="adr org fn"><p>\n#{body.sub("\n", "").gsub("\n", "<br />")}\n</p></div></div>\n}
160
160
  }
161
161
 
162
- extension("numbered list", /((s\d+\.\s.*(?:\n|$))+)/) do |body|
162
+ extension("numbered list", /^\s*((s\d+\.\s.*(?:\n|$))+)/) do |body|
163
163
  steps ||= 0
164
164
  body.gsub!(/s(\d+)\.\s(.*)(?:\n|$)/) do |b|
165
165
  "<li>#{Kramdown::Document.new($2.strip).to_html}</li>\n"
@@ -8,6 +8,12 @@ module Govspeak
8
8
  def top_level?
9
9
  level == top_level
10
10
  end
11
+
12
+ def to_h
13
+ Hash[members.zip(values)].merge(
14
+ headers: headers.map(&:to_h),
15
+ )
16
+ end
11
17
  end
12
18
 
13
19
  class StructuredHeaderExtractor
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
@@ -68,6 +68,44 @@ class GovspeakStructuredHeadersTest < Test::Unit::TestCase
68
68
  assert_equal "Sub heading 4.2", structured_headers[3].headers[1].text
69
69
  end
70
70
 
71
+ test "structured headers serialize to hashes recursively serializing sub headers" do
72
+ serialized_headers = structured_headers[1].to_h
73
+
74
+ expected_serialized_headers = {
75
+ :text => "Heading 2",
76
+ :level => 2,
77
+ :id => "heading-2",
78
+ :headers => [
79
+ {
80
+ :text => "Sub heading 2.1",
81
+ :level => 3,
82
+ :id => "sub-heading-21",
83
+ :headers => [],
84
+ },
85
+ {
86
+ :text => "Sub heading 2.2",
87
+ :level => 3,
88
+ :id => "sub-heading-22",
89
+ :headers => [
90
+ {
91
+ :text => "Sub sub heading 2.2.1",
92
+ :level => 4,
93
+ :id => "sub-sub-heading-221",
94
+ :headers => []
95
+ },
96
+ ],
97
+ },
98
+ {
99
+ :text => "Sub heading 2.3",
100
+ :level => 3, :id=>"sub-heading-23",
101
+ :headers => []
102
+ },
103
+ ],
104
+ }
105
+
106
+ assert_equal expected_serialized_headers, serialized_headers
107
+ end
108
+
71
109
  def invalid_document_body
72
110
  %{
73
111
  ### Invalid heading (h3)
@@ -374,6 +374,14 @@ $CTA
374
374
  assert_text_output "zippy bungle george"
375
375
  end
376
376
 
377
+ test_given_govspeak "
378
+ Zippy, Bungle and George did not qualify for the tax exemption in s428. They filled in their tax return accordingly.
379
+ " do
380
+ assert_html_output %{
381
+ <p>Zippy, Bungle and George did not qualify for the tax exemption in s428. They filled in their tax return accordingly.</p>
382
+ }
383
+ end
384
+
377
385
  test_given_govspeak ":scotland: I am very devolved\n and very scottish \n:scotland:" do
378
386
  assert_html_output '
379
387
  <div class="devolved-content scotland">
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govspeak
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-06 00:00:00.000000000 Z
13
+ date: 2014-05-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: kramdown
@@ -60,6 +60,22 @@ dependencies:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: 2.0.3
63
+ - !ruby/object:Gem::Dependency
64
+ name: nokogiri
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 1.5.10
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.5.10
63
79
  - !ruby/object:Gem::Dependency
64
80
  name: rake
65
81
  requirement: !ruby/object:Gem::Requirement
@@ -165,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
181
  version: '0'
166
182
  segments:
167
183
  - 0
168
- hash: -2566926204979886726
184
+ hash: 1265897029881878331
169
185
  required_rubygems_version: !ruby/object:Gem::Requirement
170
186
  none: false
171
187
  requirements:
@@ -174,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
190
  version: '0'
175
191
  segments:
176
192
  - 0
177
- hash: -2566926204979886726
193
+ hash: 1265897029881878331
178
194
  requirements: []
179
195
  rubyforge_project:
180
196
  rubygems_version: 1.8.23