govuk_markdown 2.0.3 → 2.0.5

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: 3752fe30f06aa219d8980f67f509d424bf2151237a26a3ead62cca2357fa5b28
4
- data.tar.gz: 60c9c9ae54297729fb5f7392cdfef6e39e8842524b32b08fa81fcc546787dcfa
3
+ metadata.gz: afc74637316dbd7ed8e352f32d34673c604ec6873cf5218278fdae1f12d3f1a6
4
+ data.tar.gz: 87c0a97cdb053edef4fd4d98fba76f6601835e151fb47c3f01620d073f90df27
5
5
  SHA512:
6
- metadata.gz: 5c598babbcffaf1dd479ccc45f1df91a793af4915f07f17dfbd59b3d7e3716d026cd63dfb84e2a4064915eeae9d152f48e68da0b716e6264f66475f77d93ad7e
7
- data.tar.gz: 8515582240378e430d5c81281aabf84a278fe646df72da79707c636608ead74693193525f0373640f63fb20b583c123d58ae4f7affcb4f8befd1a0e2831d7462
6
+ metadata.gz: 6dc9fb3c8286a1e5f3f64edf8bf7999df87981987a4147d03eda93a399901efc8c7a6333aa0189d3197b52d396fbacc4c77c39da5e58344f4eeac00ec9d2c5d0
7
+ data.tar.gz: f11e1ac3d408e24eb23839d6bed7cb0be021b62764ee6821560a131cf0a63e27ec646737d5676425249055455bcc5c6e147e2f1407f98234072fee691a64d036
@@ -17,7 +17,7 @@ jobs:
17
17
  - name: Set up Ruby
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
20
- ruby-version: '3.1.4'
20
+ ruby-version: .ruby-version
21
21
 
22
22
  - name: Install dependencies
23
23
  run: |
@@ -6,7 +6,7 @@ jobs:
6
6
  strategy:
7
7
  fail-fast: false
8
8
  matrix:
9
- ruby: ['3.1.4', '3.2.3', '3.3.0']
9
+ ruby: ['4.0.9']
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
12
  - uses: actions/checkout@v2
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.4
1
+ 4.0.9
data/Gemfile.lock CHANGED
@@ -1,106 +1,116 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- govuk_markdown (2.0.2)
4
+ govuk_markdown (2.0.4)
5
5
  activesupport
6
6
  redcarpet
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (7.1.3.2)
11
+ activesupport (7.2.4)
12
12
  base64
13
+ benchmark (>= 0.3)
13
14
  bigdecimal
14
- concurrent-ruby (~> 1.0, >= 1.0.2)
15
- connection_pool (>= 2.2.5)
15
+ concurrent-ruby (~> 1.0, >= 1.3.1)
16
+ connection_pool (>= 2.2.5, < 3)
16
17
  drb
17
18
  i18n (>= 1.6, < 2)
18
- minitest (>= 5.1)
19
- mutex_m
20
- tzinfo (~> 2.0)
21
- ast (2.4.2)
22
- base64 (0.2.0)
23
- bigdecimal (3.1.7)
19
+ logger (>= 1.4.2)
20
+ minitest (>= 5.1, < 6)
21
+ securerandom (>= 0.3)
22
+ tzinfo (~> 2.0, >= 2.0.5)
23
+ ast (2.4.3)
24
+ base64 (0.3.0)
25
+ benchmark (0.5.0)
26
+ bigdecimal (4.1.3)
24
27
  coderay (1.1.3)
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)
28
+ concurrent-ruby (1.3.8)
29
+ connection_pool (2.5.5)
30
+ diff-lcs (1.6.2)
31
+ drb (2.2.3)
32
+ i18n (1.15.2)
30
33
  concurrent-ruby (~> 1.0)
31
- json (2.7.2)
32
- language_server-protocol (3.17.0.3)
34
+ io-console (0.9.4)
35
+ json (2.21.2)
36
+ language_server-protocol (3.17.0.6)
37
+ lint_roller (1.1.0)
38
+ logger (1.7.0)
33
39
  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)
40
+ minitest (5.27.0)
41
+ parallel (1.28.0)
42
+ parser (3.3.13.0)
38
43
  ast (~> 2.4.1)
39
44
  racc
40
- pry (0.14.2)
45
+ prism (1.9.0)
46
+ pry (0.16.1)
41
47
  coderay (~> 1.1)
42
48
  method_source (~> 1.0)
43
- racc (1.7.3)
44
- rack (3.0.10)
49
+ reline (>= 0.6.0)
50
+ racc (1.8.1)
51
+ rack (3.2.7)
45
52
  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)
53
+ rake (13.4.2)
54
+ redcarpet (3.6.1)
55
+ regexp_parser (2.13.1)
56
+ reline (0.7.0)
57
+ io-console (~> 0.5)
58
+ rspec (3.13.2)
51
59
  rspec-core (~> 3.13.0)
52
60
  rspec-expectations (~> 3.13.0)
53
61
  rspec-mocks (~> 3.13.0)
54
- rspec-core (3.13.0)
62
+ rspec-core (3.13.6)
55
63
  rspec-support (~> 3.13.0)
56
- rspec-expectations (3.13.0)
64
+ rspec-expectations (3.13.5)
57
65
  diff-lcs (>= 1.2.0, < 2.0)
58
66
  rspec-support (~> 3.13.0)
59
- rspec-mocks (3.13.0)
67
+ rspec-mocks (3.13.8)
60
68
  diff-lcs (>= 1.2.0, < 2.0)
61
69
  rspec-support (~> 3.13.0)
62
- rspec-support (3.13.1)
63
- rubocop (1.62.1)
70
+ rspec-support (3.13.7)
71
+ rubocop (1.86.0)
64
72
  json (~> 2.3)
65
- language_server-protocol (>= 3.17.0)
73
+ language_server-protocol (~> 3.17.0.2)
74
+ lint_roller (~> 1.1.0)
66
75
  parallel (~> 1.10)
67
76
  parser (>= 3.3.0.2)
68
77
  rainbow (>= 2.2.2, < 4.0)
69
- regexp_parser (>= 1.8, < 3.0)
70
- rexml (>= 3.2.5, < 4.0)
71
- rubocop-ast (>= 1.31.1, < 2.0)
78
+ regexp_parser (>= 2.9.3, < 3.0)
79
+ rubocop-ast (>= 1.49.0, < 2.0)
72
80
  ruby-progressbar (~> 1.7)
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)
81
+ unicode-display_width (>= 2.4.0, < 4.0)
82
+ rubocop-ast (1.49.1)
83
+ parser (>= 3.3.7.2)
84
+ prism (~> 1.7)
85
+ rubocop-capybara (2.22.1)
86
+ lint_roller (~> 1.1)
87
+ rubocop (~> 1.72, >= 1.72.1)
88
+ rubocop-govuk (5.2.1)
89
+ rubocop (= 1.86.0)
90
+ rubocop-ast (= 1.49.1)
91
+ rubocop-capybara (= 2.22.1)
92
+ rubocop-rails (= 2.34.3)
93
+ rubocop-rake (= 0.7.1)
94
+ rubocop-rspec (= 3.9.0)
95
+ rubocop-rails (2.34.3)
87
96
  activesupport (>= 4.2.0)
97
+ lint_roller (~> 1.1)
88
98
  rack (>= 1.1)
89
- rubocop (>= 1.33.0, < 2.0)
90
- rubocop-ast (>= 1.31.1, < 2.0)
91
- rubocop-rake (0.6.0)
92
- rubocop (~> 1.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)
99
+ rubocop (>= 1.75.0, < 2.0)
100
+ rubocop-ast (>= 1.44.0, < 2.0)
101
+ rubocop-rake (0.7.1)
102
+ lint_roller (~> 1.1)
103
+ rubocop (>= 1.72.1)
104
+ rubocop-rspec (3.9.0)
105
+ lint_roller (~> 1.1)
106
+ rubocop (~> 1.81)
100
107
  ruby-progressbar (1.13.0)
108
+ securerandom (0.4.1)
101
109
  tzinfo (2.0.6)
102
110
  concurrent-ruby (~> 1.0)
103
- unicode-display_width (2.5.0)
111
+ unicode-display_width (3.3.0)
112
+ unicode-emoji (~> 4.3)
113
+ unicode-emoji (4.3.0)
104
114
 
105
115
  PLATFORMS
106
116
  ruby
@@ -113,4 +123,4 @@ DEPENDENCIES
113
123
  rubocop-govuk
114
124
 
115
125
  BUNDLED WITH
116
- 2.1.4
126
+ 4.0.10
@@ -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(">= 3.1.4")
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 4.0.9")
13
13
 
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
15
  spec.metadata["source_code_uri"] = spec.homepage
@@ -0,0 +1,97 @@
1
+ module GovukMarkdown
2
+ # Renderer::Mixin overrides methods in Redcarpet::Render::HTML.
3
+ # See `GovukMarkdown::Renderer` for an example of how to include it.
4
+ module Renderer::Mixin
5
+ def table(header, body)
6
+ <<~HTML
7
+ <table class='govuk-table'>
8
+ <thead class='govuk-table__head'>
9
+ #{header}
10
+ </thead>
11
+ <tbody class='govuk-table__body'>
12
+ #{body}
13
+ </tbody>
14
+ </table>
15
+ HTML
16
+ end
17
+
18
+ def table_row(content)
19
+ <<~HTML
20
+ <tr class='govuk-table__row'>
21
+ #{content}
22
+ </tr>
23
+ HTML
24
+ end
25
+
26
+ def table_cell(content, _alignment, header)
27
+ if header
28
+ <<~HTML
29
+ <th class='govuk-table__header'>
30
+ #{content}
31
+ </th>
32
+ HTML
33
+ else
34
+ <<~HTML
35
+ <td class='govuk-table__cell'>
36
+ #{content}
37
+ </td>
38
+ HTML
39
+ end
40
+ end
41
+
42
+ def header(text, header_level)
43
+ valid_header_sizes = %w[xl l m s].freeze
44
+
45
+ start_size = valid_header_sizes.include?(@headings_start_with) ? @headings_start_with : "xl"
46
+
47
+ start_size_index = valid_header_sizes.find_index(start_size)
48
+
49
+ header_size = valid_header_sizes[start_size_index + header_level - 1] || "s"
50
+
51
+ id_attribute = @options[:with_toc_data] ? " id=\"#{text.parameterize}\"" : ""
52
+ <<~HTML
53
+ <h#{header_level}#{id_attribute} class="govuk-heading-#{header_size}">#{text}</h#{header_level}>
54
+ HTML
55
+ end
56
+
57
+ def paragraph(text)
58
+ <<~HTML
59
+ <p class="govuk-body-m">#{text}</p>
60
+ HTML
61
+ end
62
+
63
+ def list(contents, list_type)
64
+ case list_type
65
+ when :unordered
66
+ <<~HTML
67
+ <ul class="govuk-list govuk-list--bullet">
68
+ #{contents}
69
+ </ul>
70
+ HTML
71
+ when :ordered
72
+ <<~HTML
73
+ <ol class="govuk-list govuk-list--number">
74
+ #{contents}
75
+ </ol>
76
+ HTML
77
+ else
78
+ raise "Unexpected type #{list_type.inspect}"
79
+ end
80
+ end
81
+
82
+ def hrule
83
+ <<~HTML
84
+ <hr class="govuk-section-break govuk-section-break--xl govuk-section-break--visible">
85
+ HTML
86
+ end
87
+
88
+ def preprocess(document)
89
+ Preprocessor
90
+ .new(document)
91
+ .inject_inset_text
92
+ .inject_details
93
+ .strip_front_matter(@strip_front_matter)
94
+ .output
95
+ end
96
+ end
97
+ end
@@ -1,6 +1,9 @@
1
1
  module GovukMarkdown
2
2
  class Renderer < ::Redcarpet::Render::HTML
3
- include Redcarpet::Render::SmartyPants
3
+ autoload :Mixin, "govuk_markdown/renderer/mixin"
4
+
5
+ include ::Redcarpet::Render::SmartyPants
6
+ include Mixin
4
7
 
5
8
  def initialize(govuk_options, options = {})
6
9
  @headings_start_with = govuk_options[:headings_start_with]
@@ -8,97 +11,5 @@ module GovukMarkdown
8
11
 
9
12
  super options
10
13
  end
11
-
12
- def table(header, body)
13
- <<~HTML
14
- <table class='govuk-table'>
15
- <thead class='govuk-table__head'>
16
- #{header}
17
- </thead>
18
- <tbody class='govuk-table__body'>
19
- #{body}
20
- </tbody>
21
- </table>
22
- HTML
23
- end
24
-
25
- def table_row(content)
26
- <<~HTML
27
- <tr class='govuk-table__row'>
28
- #{content}
29
- </tr>
30
- HTML
31
- end
32
-
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
47
- end
48
-
49
- def header(text, header_level)
50
- valid_header_sizes = %w[xl l m s].freeze
51
-
52
- start_size = valid_header_sizes.include?(@headings_start_with) ? @headings_start_with : "xl"
53
-
54
- start_size_index = valid_header_sizes.find_index(start_size)
55
-
56
- header_size = valid_header_sizes[start_size_index + header_level - 1] || "s"
57
-
58
- id_attribute = @options[:with_toc_data] ? " id=\"#{text.parameterize}\"" : ""
59
- <<~HTML
60
- <h#{header_level}#{id_attribute} class="govuk-heading-#{header_size}">#{text}</h#{header_level}>
61
- HTML
62
- end
63
-
64
- def paragraph(text)
65
- <<~HTML
66
- <p class="govuk-body-m">#{text}</p>
67
- HTML
68
- end
69
-
70
- def list(contents, list_type)
71
- case list_type
72
- when :unordered
73
- <<~HTML
74
- <ul class="govuk-list govuk-list--bullet">
75
- #{contents}
76
- </ul>
77
- HTML
78
- when :ordered
79
- <<~HTML
80
- <ol class="govuk-list govuk-list--number">
81
- #{contents}
82
- </ol>
83
- HTML
84
- else
85
- raise "Unexpected type #{list_type.inspect}"
86
- end
87
- end
88
-
89
- def hrule
90
- <<~HTML
91
- <hr class="govuk-section-break govuk-section-break--xl govuk-section-break--visible">
92
- HTML
93
- end
94
-
95
- def preprocess(document)
96
- Preprocessor
97
- .new(document)
98
- .inject_inset_text
99
- .inject_details
100
- .strip_front_matter(@strip_front_matter)
101
- .output
102
- end
103
14
  end
104
15
  end
@@ -1,3 +1,3 @@
1
1
  module GovukMarkdown
2
- VERSION = "2.0.3".freeze
2
+ VERSION = "2.0.5".freeze
3
3
  end
@@ -4,10 +4,11 @@ require "redcarpet"
4
4
  require_relative "./govuk_markdown/version"
5
5
  require_relative "./govuk_markdown/preprocessor"
6
6
  require_relative "./govuk_markdown/renderer"
7
+ require_relative "./govuk_markdown/renderer/mixin"
7
8
 
8
9
  module GovukMarkdown
9
- def self.render(markdown, govuk_options = {})
10
+ def self.render(markdown, govuk_options = {}, redcarpet_options = {})
10
11
  renderer = GovukMarkdown::Renderer.new(govuk_options, { with_toc_data: true, strip_front_matter: true, link_attributes: { class: "govuk-link" } })
11
- Redcarpet::Markdown.new(renderer, tables: true, no_intra_emphasis: true).render(markdown).strip
12
+ Redcarpet::Markdown.new(renderer, tables: true, no_intra_emphasis: true, **redcarpet_options).render(markdown).strip
12
13
  end
13
14
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tijmen Brommet
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-04-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -123,6 +122,7 @@ files:
123
122
  - lib/govuk_markdown.rb
124
123
  - lib/govuk_markdown/preprocessor.rb
125
124
  - lib/govuk_markdown/renderer.rb
125
+ - lib/govuk_markdown/renderer/mixin.rb
126
126
  - lib/govuk_markdown/version.rb
127
127
  homepage: https://github.com/DFE-Digital/govuk_markdown
128
128
  licenses: []
@@ -130,7 +130,6 @@ 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:
134
133
  rdoc_options: []
135
134
  require_paths:
136
135
  - lib
@@ -138,15 +137,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
137
  requirements:
139
138
  - - ">="
140
139
  - !ruby/object:Gem::Version
141
- version: 3.1.4
140
+ version: 4.0.9
142
141
  required_rubygems_version: !ruby/object:Gem::Requirement
143
142
  requirements:
144
143
  - - ">="
145
144
  - !ruby/object:Gem::Version
146
145
  version: '0'
147
146
  requirements: []
148
- rubygems_version: 3.3.26
149
- signing_key:
147
+ rubygems_version: 4.0.20
150
148
  specification_version: 4
151
149
  summary: Convert Markdown into GOV.UK styled HTML
152
150
  test_files: []