govuk_markdown 2.0.1 → 2.0.3

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: 975a784ccde8bc595764bf9bbff9dc0377b00d43e3114a0870f75fb9a74dc828
4
- data.tar.gz: a648e648e2a72505e45f9100a3f4c7599287cca3c0bdd78fb34d5110cfcac62d
3
+ metadata.gz: 3752fe30f06aa219d8980f67f509d424bf2151237a26a3ead62cca2357fa5b28
4
+ data.tar.gz: 60c9c9ae54297729fb5f7392cdfef6e39e8842524b32b08fa81fcc546787dcfa
5
5
  SHA512:
6
- metadata.gz: a2309375dd6555cc7ca361513a9147844611519ad5c19a765e24a018cab5725faa2d91e50ca7698080d2efa7dc526876096f0ff97f7c7984945ab8da517e7a48
7
- data.tar.gz: 8ad79ffc90dae8461e019b18ad5371e94943df3e39d58697089a4a8510d856a1d0859b5b8792f0e4118f99715af106043db4e7ed1b96085794fa58b95f8da7c9
6
+ metadata.gz: 5c598babbcffaf1dd479ccc45f1df91a793af4915f07f17dfbd59b3d7e3716d026cd63dfb84e2a4064915eeae9d152f48e68da0b716e6264f66475f77d93ad7e
7
+ data.tar.gz: 8515582240378e430d5c81281aabf84a278fe646df72da79707c636608ead74693193525f0373640f63fb20b583c123d58ae4f7affcb4f8befd1a0e2831d7462
@@ -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/Gemfile.lock CHANGED
@@ -1,83 +1,106 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- govuk_markdown (2.0.1)
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.7.3)
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.2.2)
20
- diff-lcs (1.4.4)
21
- i18n (1.12.0)
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.18.0)
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.7)
32
- rainbow (3.0.0)
33
- rake (13.0.6)
43
+ racc (1.7.3)
44
+ rack (3.0.10)
45
+ rainbow (3.1.1)
46
+ rake (13.2.1)
34
47
  redcarpet (3.6.0)
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)
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)
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)
77
101
  tzinfo (2.0.6)
78
102
  concurrent-ruby (~> 1.0)
79
- unicode-display_width (2.0.0)
80
- zeitwerk (2.6.7)
103
+ unicode-display_width (2.5.0)
81
104
 
82
105
  PLATFORMS
83
106
  ruby
data/README.md CHANGED
@@ -4,7 +4,7 @@ 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 Components](https://github.com/DFE-Digital/govuk-components) version 4.0.0
7
+ Note that this gem supports [GOV.UK Design System](https://design-system.service.gov.uk/) version 5.3.0.
8
8
 
9
9
  ## Installation
10
10
 
@@ -52,9 +52,9 @@ GovukMarkdown.render(markdown, headings_start_with: "l")
52
52
 
53
53
  ### Adding inset text to your markdown
54
54
 
55
- To add [inset text](https://govuk-components.netlify.app/components/inset-text/) to your markdown document, use the following tags:
55
+ To add [inset text](https://design-system.service.gov.uk/components/inset-text/) to your markdown document, use the following tags:
56
56
 
57
- ```markdown
57
+ ```
58
58
  {inset-text}Text to be inset goes here{/inset-text}
59
59
  ```
60
60
 
@@ -70,10 +70,10 @@ The renderer also handles multi-line text as well as multiple paragraphs inside
70
70
 
71
71
  ### Adding details sections to your markdown
72
72
 
73
- To add the [details component](https://govuk-components.netlify.app/components/details/) to your markdown, use the following tags:
73
+ To add the [details component](https://design-system.service.gov.uk/components/details/) to your markdown, use the following tags:
74
74
 
75
- ```markdown
76
- {details} Find out about the fox and the dog. Whilst the fox is quick and brown, the dog is lazy. {/details}
75
+ ```
76
+ {details} Find out about the fox and the dog. Whilst the fox is quick and brown, the dog is lazy.{/details}
77
77
  ```
78
78
 
79
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.
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
@@ -37,6 +37,14 @@ module GovukMarkdown
37
37
  self
38
38
  end
39
39
 
40
+ def strip_front_matter(enabled)
41
+ return self unless enabled
42
+
43
+ @output = output.gsub(%r{^---\n.*\n---}m, "")
44
+
45
+ self
46
+ end
47
+
40
48
  private
41
49
 
42
50
  # parse as markdown if there are multiple lines of content
@@ -1,7 +1,11 @@
1
1
  module GovukMarkdown
2
2
  class Renderer < ::Redcarpet::Render::HTML
3
+ include Redcarpet::Render::SmartyPants
4
+
3
5
  def initialize(govuk_options, options = {})
4
6
  @headings_start_with = govuk_options[:headings_start_with]
7
+ @strip_front_matter = govuk_options[:strip_front_matter]
8
+
5
9
  super options
6
10
  end
7
11
 
@@ -26,12 +30,20 @@ module GovukMarkdown
26
30
  HTML
27
31
  end
28
32
 
29
- def table_cell(content, _alignment)
30
- <<~HTML
31
- <td class='govuk-table__cell'>
32
- #{content}
33
- </td>
34
- HTML
33
+ def table_cell(content, _alignment, header)
34
+ if header
35
+ <<~HTML
36
+ <th class='govuk-table__header'>
37
+ #{content}
38
+ </th>
39
+ HTML
40
+ else
41
+ <<~HTML
42
+ <td class='govuk-table__cell'>
43
+ #{content}
44
+ </td>
45
+ HTML
46
+ end
35
47
  end
36
48
 
37
49
  def header(text, header_level)
@@ -85,6 +97,7 @@ module GovukMarkdown
85
97
  .new(document)
86
98
  .inject_inset_text
87
99
  .inject_details
100
+ .strip_front_matter(@strip_front_matter)
88
101
  .output
89
102
  end
90
103
  end
@@ -1,3 +1,3 @@
1
1
  module GovukMarkdown
2
- VERSION = "2.0.1".freeze
2
+ VERSION = "2.0.3".freeze
3
3
  end
@@ -7,7 +7,7 @@ require_relative "./govuk_markdown/renderer"
7
7
 
8
8
  module GovukMarkdown
9
9
  def self.render(markdown, govuk_options = {})
10
- renderer = GovukMarkdown::Renderer.new(govuk_options, { with_toc_data: true, link_attributes: { class: "govuk-link" } })
10
+ renderer = GovukMarkdown::Renderer.new(govuk_options, { with_toc_data: true, strip_front_matter: true, link_attributes: { class: "govuk-link" } })
11
11
  Redcarpet::Markdown.new(renderer, tables: true, no_intra_emphasis: true).render(markdown).strip
12
12
  end
13
13
  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.1
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tijmen Brommet
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2025-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -130,7 +130,7 @@ metadata:
130
130
  homepage_uri: https://github.com/DFE-Digital/govuk_markdown
131
131
  source_code_uri: https://github.com/DFE-Digital/govuk_markdown
132
132
  changelog_uri: https://github.com/DFE-Digital/govuk_markdown
133
- post_install_message:
133
+ post_install_message:
134
134
  rdoc_options: []
135
135
  require_paths:
136
136
  - lib
@@ -138,15 +138,15 @@ 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
149
- signing_key:
148
+ rubygems_version: 3.3.26
149
+ signing_key:
150
150
  specification_version: 4
151
151
  summary: Convert Markdown into GOV.UK styled HTML
152
152
  test_files: []