govspeak 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/govspeak.rb +5 -1
  2. data/test/govspeak_test.rb +6 -6
  3. metadata +42 -34
data/lib/govspeak.rb CHANGED
@@ -55,6 +55,10 @@ module Govspeak
55
55
  content = parser ? parser.new("#{body.strip}\n").to_html : body.strip
56
56
  %{<div class="#{class_name}">\n#{content}</div>\n}
57
57
  }
58
+ end
59
+
60
+ def self.insert_strong_inside_p(body, parser=Kramdown::Document)
61
+ parser.new(body.strip).to_html.sub(/^<p>(.*)<\/p>$/,"<p><strong>\\1</strong></p>")
58
62
  end
59
63
 
60
64
  extension('reverse') { |body|
@@ -71,7 +75,7 @@ module Govspeak
71
75
  }
72
76
 
73
77
  extension('important', surrounded_by("@")) { |body|
74
- %{\n\n<h3 class="advisory">#{Kramdown::Document.new(body.strip).to_html}</h3>\n}
78
+ %{\n\n<div class="advisory">#{insert_strong_inside_p(body)}</div>\n}
75
79
  }
76
80
 
77
81
  extension('helpful', surrounded_by("%")) { |body|
@@ -67,15 +67,15 @@ class GovspeakTest < Test::Unit::TestCase
67
67
  </div>}
68
68
  }, {
69
69
  input: "@ I am very important @",
70
- output: %{<h3 class="advisory"><p>I am very important</p>
71
- </h3>}
70
+ output: %{<div class="advisory"><p><strong>I am very important</strong></p>
71
+ </div>}
72
72
  }, {
73
73
  input: "The following is very important
74
74
  @ I am very important @",
75
75
  output: %{<p>The following is very important</p>
76
76
 
77
- <h3 class="advisory"><p>I am very important</p>
78
- </h3>}
77
+ <div class="advisory"><p><strong>I am very important</strong></p>
78
+ </div>}
79
79
  }, {
80
80
  input: "% I am very helpful %",
81
81
  output: %{<div class="application-notice help-notice">
@@ -196,8 +196,8 @@ end
196
196
  test "links inside markdown boxes" do
197
197
  input = "@ Message with [a link](http://foo.bar/)@"
198
198
  output = %{
199
- <h3 class="advisory"><p>Message with <a href="http://foo.bar/">a link</a></p>
200
- </h3>
199
+ <div class="advisory"><p><strong>Message with <a href="http://foo.bar/">a link</a></strong></p>
200
+ </div>
201
201
  }
202
202
 
203
203
  assert_equal output, Govspeak::Document.new(input).to_html
metadata CHANGED
@@ -1,48 +1,53 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: govspeak
3
- version: !ruby/object:Gem::Version
4
- version: 0.8.5
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.8.6
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Ben Griffiths
9
9
  - James Stewart
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-12-20 00:00:00.000000000Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
13
+
14
+ date: 2011-12-20 00:00:00 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
16
17
  name: kramdown
17
- requirement: &70126712036920 !ruby/object:Gem::Requirement
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
18
20
  none: false
19
- requirements:
21
+ requirements:
20
22
  - - ~>
21
- - !ruby/object:Gem::Version
23
+ - !ruby/object:Gem::Version
22
24
  version: 0.13.3
23
25
  type: :runtime
24
- prerelease: false
25
- version_requirements: *70126712036920
26
- - !ruby/object:Gem::Dependency
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
27
28
  name: rake
28
- requirement: &70126712036220 !ruby/object:Gem::Requirement
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
29
31
  none: false
30
- requirements:
32
+ requirements:
31
33
  - - ~>
32
- - !ruby/object:Gem::Version
34
+ - !ruby/object:Gem::Version
33
35
  version: 0.8.0
34
36
  type: :development
35
- prerelease: false
36
- version_requirements: *70126712036220
37
- description: ! "A set of extensions to markdown layered on top of the kramdown \nlibrary
38
- for use in the UK Government Single Domain project"
39
- email:
37
+ version_requirements: *id002
38
+ description: |-
39
+ A set of extensions to markdown layered on top of the kramdown
40
+ library for use in the UK Government Single Domain project
41
+ email:
40
42
  - ben@alphagov.co.uk
41
43
  - james.stewart@digital.cabinet-office.gov.uk
42
44
  executables: []
45
+
43
46
  extensions: []
47
+
44
48
  extra_rdoc_files: []
45
- files:
49
+
50
+ files:
46
51
  - lib/govspeak/header_extractor.rb
47
52
  - lib/govspeak.rb
48
53
  - Gemfile
@@ -51,28 +56,31 @@ files:
51
56
  - test/test_helper.rb
52
57
  homepage: http://github.com/alphagov/govspeak
53
58
  licenses: []
59
+
54
60
  post_install_message:
55
61
  rdoc_options: []
56
- require_paths:
62
+
63
+ require_paths:
57
64
  - lib
58
- required_ruby_version: !ruby/object:Gem::Requirement
65
+ required_ruby_version: !ruby/object:Gem::Requirement
59
66
  none: false
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
63
- version: '0'
64
- required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
72
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
70
77
  requirements: []
78
+
71
79
  rubyforge_project:
72
80
  rubygems_version: 1.8.12
73
81
  signing_key:
74
82
  specification_version: 3
75
83
  summary: Markup language for single domain
76
- test_files:
84
+ test_files:
77
85
  - test/govspeak_test.rb
78
86
  - test/test_helper.rb