govuk_markdown 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6d0bb270e6c3987985f3da0f956b8a9871c112cc09ca232715a2440773cd8ab
4
- data.tar.gz: 6f34ac1e30578e6c6c912e93fc8c6fd410ace73b73903f7c8141559299832c91
3
+ metadata.gz: 04e0653c66e2b3caa406acdfd07269a638ad834fd0791858f9d71dfa3eb43bbd
4
+ data.tar.gz: 1b1350d46fc9937987c5077a9130dc0602852afd72f8c57433cb746957290351
5
5
  SHA512:
6
- metadata.gz: 02aba1d2ccc9623234849df49f3d3fbf90b4b4c180c8e7496d36ca341af39bf16c6cec9a735981906ed94949b21e192fdc200f92f22596f5740db3cb01404d71
7
- data.tar.gz: eea2c0cf468653aac44d138fb928292daaaab5fb9d296d1149e6cc28a3ab30a84b2afd7291e47a0ede5a5f5929b5f669a91bc21d5d19adafb7e10cdd6842f75e
6
+ metadata.gz: 0cb66e8911fc9c18b9a7b05e2737400acc32a6fc444ceccbc0cf1da1e48515f299d793d55be2ec8310fb8b9be759f05fa2abe90b2b7e98ab82fa7d2f1514550c
7
+ data.tar.gz: 707d0d37111906368efd76b9f9086a7e026ee502ce1e0e31a3651d3b6b952507dad4b262946f4feea980ded9a2dfd22008580f5c61822fee054a9cc2ead7b5ba
@@ -10,14 +10,14 @@ jobs:
10
10
  name: Publish to RubyGems.org
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v2
13
+ - uses: actions/checkout@v3
14
14
  with:
15
15
  ref: ${{ github.event.inputs.tag }}
16
16
 
17
17
  - name: Set up Ruby
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
20
- ruby-version: '2.7.6'
20
+ ruby-version: '3.1.4'
21
21
 
22
22
  - name: Install dependencies
23
23
  run: |
@@ -26,5 +26,5 @@ jobs:
26
26
 
27
27
  - name: Publish gem
28
28
  uses: dawidd6/action-publish-gem@v1
29
- with:
29
+ with:
30
30
  api_key: ${{ secrets.RUBYGEMS_API_KEY }}
@@ -6,7 +6,7 @@ jobs:
6
6
  strategy:
7
7
  fail-fast: false
8
8
  matrix:
9
- ruby: ['2.7.6', '3.0.4', '3.1.2']
9
+ ruby: ['3.1.4', '3.2.3', '3.3.0']
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
12
  - uses: actions/checkout@v2
@@ -23,4 +23,4 @@ jobs:
23
23
  run: bundle exec rubocop .
24
24
 
25
25
  - name: Run tests
26
- run: bundle exec rake
26
+ run: bundle exec rspec
data/.rubocop.yml CHANGED
@@ -5,3 +5,6 @@ inherit_gem:
5
5
  inherit_mode:
6
6
  merge:
7
7
  - Exclude
8
+
9
+ Style/EmptyCaseCondition:
10
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.2
1
+ 3.1.4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 2.0.0
2
+
3
+ * Add test matrix for Ruby versions 2.7.6, 3.0.4 and 3.1.2
4
+ * Update Publish Gem workflow to run manually
5
+ * Add support for configurable start heading size
6
+ * Add preprocessor for markdown files
7
+ * Add support for inset text component
8
+ * Add support for details component
9
+ * Add pry as developer dependency
10
+
1
11
  ## 1.0.0
2
12
 
3
13
  * Increase minimum supported Ruby version to >= 2.7.0
data/Gemfile.lock CHANGED
@@ -1,83 +1,106 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- govuk_markdown (2.0.0)
4
+ govuk_markdown (2.0.2)
5
5
  activesupport
6
6
  redcarpet
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.1.4)
11
+ activesupport (7.1.3.2)
12
+ base64
13
+ bigdecimal
12
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ connection_pool (>= 2.2.5)
16
+ drb
13
17
  i18n (>= 1.6, < 2)
14
18
  minitest (>= 5.1)
19
+ mutex_m
15
20
  tzinfo (~> 2.0)
16
- zeitwerk (~> 2.3)
17
21
  ast (2.4.2)
22
+ base64 (0.2.0)
23
+ bigdecimal (3.1.7)
18
24
  coderay (1.1.3)
19
- concurrent-ruby (1.1.9)
20
- diff-lcs (1.4.4)
21
- i18n (1.8.10)
25
+ concurrent-ruby (1.2.3)
26
+ connection_pool (2.4.1)
27
+ diff-lcs (1.5.1)
28
+ drb (2.2.1)
29
+ i18n (1.14.4)
22
30
  concurrent-ruby (~> 1.0)
23
- method_source (1.0.0)
24
- minitest (5.14.4)
25
- parallel (1.20.1)
26
- parser (3.0.2.0)
31
+ json (2.7.2)
32
+ language_server-protocol (3.17.0.3)
33
+ method_source (1.1.0)
34
+ minitest (5.22.3)
35
+ mutex_m (0.2.0)
36
+ parallel (1.24.0)
37
+ parser (3.3.0.5)
27
38
  ast (~> 2.4.1)
28
- pry (0.14.1)
39
+ racc
40
+ pry (0.14.2)
29
41
  coderay (~> 1.1)
30
42
  method_source (~> 1.0)
31
- rack (3.0.0)
32
- rainbow (3.0.0)
33
- rake (13.0.6)
34
- redcarpet (3.5.1)
35
- regexp_parser (2.1.1)
36
- rexml (3.2.5)
37
- rspec (3.10.0)
38
- rspec-core (~> 3.10.0)
39
- rspec-expectations (~> 3.10.0)
40
- rspec-mocks (~> 3.10.0)
41
- rspec-core (3.10.1)
42
- rspec-support (~> 3.10.0)
43
- rspec-expectations (3.10.1)
43
+ racc (1.7.3)
44
+ rack (3.0.10)
45
+ rainbow (3.1.1)
46
+ rake (13.2.1)
47
+ redcarpet (3.6.0)
48
+ regexp_parser (2.9.0)
49
+ rexml (3.2.6)
50
+ rspec (3.13.0)
51
+ rspec-core (~> 3.13.0)
52
+ rspec-expectations (~> 3.13.0)
53
+ rspec-mocks (~> 3.13.0)
54
+ rspec-core (3.13.0)
55
+ rspec-support (~> 3.13.0)
56
+ rspec-expectations (3.13.0)
44
57
  diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.10.0)
46
- rspec-mocks (3.10.2)
58
+ rspec-support (~> 3.13.0)
59
+ rspec-mocks (3.13.0)
47
60
  diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.10.0)
49
- rspec-support (3.10.2)
50
- rubocop (1.15.0)
61
+ rspec-support (~> 3.13.0)
62
+ rspec-support (3.13.1)
63
+ rubocop (1.62.1)
64
+ json (~> 2.3)
65
+ language_server-protocol (>= 3.17.0)
51
66
  parallel (~> 1.10)
52
- parser (>= 3.0.0.0)
67
+ parser (>= 3.3.0.2)
53
68
  rainbow (>= 2.2.2, < 4.0)
54
69
  regexp_parser (>= 1.8, < 3.0)
55
- rexml
56
- rubocop-ast (>= 1.5.0, < 2.0)
70
+ rexml (>= 3.2.5, < 4.0)
71
+ rubocop-ast (>= 1.31.1, < 2.0)
57
72
  ruby-progressbar (~> 1.7)
58
- unicode-display_width (>= 1.4.0, < 3.0)
59
- rubocop-ast (1.6.0)
60
- parser (>= 3.0.1.1)
61
- rubocop-govuk (4.0.0)
62
- rubocop (~> 1.15.0)
63
- rubocop-ast (~> 1.6.0)
64
- rubocop-rails (~> 2.10.0)
65
- rubocop-rake (= 0.5.1)
66
- rubocop-rspec (~> 2.3.0)
67
- rubocop-rails (2.10.1)
73
+ unicode-display_width (>= 2.4.0, < 3.0)
74
+ rubocop-ast (1.31.2)
75
+ parser (>= 3.3.0.4)
76
+ rubocop-capybara (2.20.0)
77
+ rubocop (~> 1.41)
78
+ rubocop-factory_bot (2.25.1)
79
+ rubocop (~> 1.41)
80
+ rubocop-govuk (4.16.1)
81
+ rubocop (= 1.62.1)
82
+ rubocop-ast (= 1.31.2)
83
+ rubocop-rails (= 2.24.1)
84
+ rubocop-rake (= 0.6.0)
85
+ rubocop-rspec (= 2.28.0)
86
+ rubocop-rails (2.24.1)
68
87
  activesupport (>= 4.2.0)
69
88
  rack (>= 1.1)
70
- rubocop (>= 1.7.0, < 2.0)
71
- rubocop-rake (0.5.1)
72
- rubocop
73
- rubocop-rspec (2.3.0)
89
+ rubocop (>= 1.33.0, < 2.0)
90
+ rubocop-ast (>= 1.31.1, < 2.0)
91
+ rubocop-rake (0.6.0)
74
92
  rubocop (~> 1.0)
75
- rubocop-ast (>= 1.1.0)
76
- ruby-progressbar (1.11.0)
77
- tzinfo (2.0.4)
93
+ rubocop-rspec (2.28.0)
94
+ rubocop (~> 1.40)
95
+ rubocop-capybara (~> 2.17)
96
+ rubocop-factory_bot (~> 2.22)
97
+ rubocop-rspec_rails (~> 2.28)
98
+ rubocop-rspec_rails (2.28.3)
99
+ rubocop (~> 1.40)
100
+ ruby-progressbar (1.13.0)
101
+ tzinfo (2.0.6)
78
102
  concurrent-ruby (~> 1.0)
79
- unicode-display_width (2.0.0)
80
- zeitwerk (2.4.2)
103
+ unicode-display_width (2.5.0)
81
104
 
82
105
  PLATFORMS
83
106
  ruby
data/README.md CHANGED
@@ -4,6 +4,8 @@ This Ruby gem converts Markdown into [GOV.UK Frontend](https://github.com/alphag
4
4
 
5
5
  Don't confuse this gem with [govspeak](https://github.com/alphagov/govspeak), which is a Markdown dialect specifically built for the GOV.UK publishing system (www.gov.uk).
6
6
 
7
+ Note that this gem supports [GOV.UK Design System](https://design-system.service.gov.uk/) version 5.3.0.
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -14,6 +16,8 @@ gem 'govuk_markdown'
14
16
 
15
17
  ## Usage
16
18
 
19
+ ### Basic usage
20
+
17
21
  ```rb
18
22
  GovukMarkdown.render(markdown)
19
23
  ```
@@ -32,6 +36,48 @@ Will output:
32
36
  </p>
33
37
  ```
34
38
 
39
+ ### Editing the start heading size of headings
40
+
41
+ By default, H1 headings will be set to XL. You can override the start heading size, for example if you want to start with size L instead.
42
+
43
+ All subsequent headings i.e. H2, H3, will be sized correctly according to the start heading size.
44
+
45
+ Values can be "xl", "l", "m" and "s".
46
+
47
+ To specify the start heading size for your markdown content, add the below option into your GovukMarkdown.render() method:
48
+
49
+ ```ruby
50
+ GovukMarkdown.render(markdown, headings_start_with: "l")
51
+ ```
52
+
53
+ ### Adding inset text to your markdown
54
+
55
+ To add [inset text](https://design-system.service.gov.uk/components/inset-text/) to your markdown document, use the following tags:
56
+
57
+ ```
58
+ {inset-text}Text to be inset goes here{/inset-text}
59
+ ```
60
+
61
+ The renderer also handles multi-line text as well as multiple paragraphs inside the tags:
62
+
63
+ ```markdown
64
+ {inset-text}
65
+ Text to be
66
+ inset goes
67
+ here
68
+ {/inset-text}
69
+ ```
70
+
71
+ ### Adding details sections to your markdown
72
+
73
+ To add the [details component](https://design-system.service.gov.uk/components/details/) to your markdown, use the following tags:
74
+
75
+ ```
76
+ {details} Find out about the fox and the dog. Whilst the fox is quick and brown, the dog is lazy.{/details}
77
+ ```
78
+
79
+ The first sentence is rendered as the details summary text. The remaining text is rendered as the details text. The renderer handles multiple paragraphs for the details text.
80
+
35
81
  ## Development
36
82
 
37
83
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -40,15 +86,6 @@ To install this gem onto your local machine, run `bundle exec rake install`.
40
86
 
41
87
  You can regenerate the example HTML file from Markdown using `bundle exec rake generate_example`.
42
88
 
43
- ## Release a new version
44
-
45
- 1. Update the version in [lib/govuk_markdown/version.rb](lib/govuk_markdown/version.rb)
46
- 2. Run `bundle install`
47
- 3. Update [CHANGELOG.md](CHANGELOG.md)
48
- 4. Create a pull request
49
-
50
- When changes are merged into the `main` branch, a new version will be released using a GitHub action.
51
-
52
89
  ## Contributing
53
90
 
54
- Bug reports and pull requests are welcome on GitHub at https://github.com/DfE-digital/govuk_markdown.
91
+ Bug reports and pull requests are welcome on GitHub at https://github.com/DfE-digital/govuk-markdown.
data/Rakefile CHANGED
@@ -1,4 +1,9 @@
1
+ require "mkmf"
1
2
  require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
2
7
  task default: :spec
3
8
 
4
9
  desc "Regenerate the example HTML in example/example.html"
@@ -9,7 +14,15 @@ task :generate_example do
9
14
  html = GovukMarkdown.render(markdown)
10
15
 
11
16
  File.write("example/example.html", ERB.new(File.read("example/example_layout.html.erb")).result(binding))
12
- sh "open example/example.html"
17
+
18
+ case
19
+ when find_executable("xdg-open") # linux
20
+ sh("xdg-open example/example.html")
21
+ when find_executable("open") # mac
22
+ sh("open example/example.html")
23
+ else
24
+ puts "View the example in example/example.html"
25
+ end
13
26
  end
14
27
 
15
28
  desc "Print the current version of the gem"
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.summary = "Convert Markdown into GOV.UK styled HTML"
10
10
  spec.description = "Convert Markdown into GOV.UK styled HTML"
11
11
  spec.homepage = "https://github.com/DFE-Digital/govuk_markdown"
12
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.1.4")
13
13
 
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
15
  spec.metadata["source_code_uri"] = spec.homepage
@@ -7,7 +7,7 @@ module GovukMarkdown
7
7
  end
8
8
 
9
9
  def inject_inset_text
10
- output.gsub!(build_regexp("inset-text")) do
10
+ @output = output.gsub(build_regexp("inset-text")) do
11
11
  <<~HTML
12
12
  <div class="govuk-inset-text">
13
13
  #{nested_markdown(Regexp.last_match(1))}
@@ -18,7 +18,7 @@ module GovukMarkdown
18
18
  end
19
19
 
20
20
  def inject_details
21
- output.gsub!(build_regexp("details")) do
21
+ @output = output.gsub(build_regexp("details")) do
22
22
  summary, details = *construct_details_from(Regexp.last_match(1))
23
23
 
24
24
  <<~HTML
@@ -26,12 +26,20 @@ module GovukMarkdown
26
26
  HTML
27
27
  end
28
28
 
29
- def table_cell(content, _alignment)
30
- <<~HTML
31
- <td class='govuk-table__cell'>
32
- #{content}
33
- </td>
34
- HTML
29
+ def table_cell(content, _alignment, header)
30
+ if header
31
+ <<~HTML
32
+ <th class='govuk-table__header'>
33
+ #{content}
34
+ </th>
35
+ HTML
36
+ else
37
+ <<~HTML
38
+ <td class='govuk-table__cell'>
39
+ #{content}
40
+ </td>
41
+ HTML
42
+ end
35
43
  end
36
44
 
37
45
  def header(text, header_level)
@@ -1,3 +1,3 @@
1
1
  module GovukMarkdown
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tijmen Brommet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-15 00:00:00.000000000 Z
11
+ date: 2024-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -138,14 +138,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
139
  - - ">="
140
140
  - !ruby/object:Gem::Version
141
- version: 2.7.0
141
+ version: 3.1.4
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ">="
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.1.4
148
+ rubygems_version: 3.3.26
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Convert Markdown into GOV.UK styled HTML