govuk_markdown 2.0.2 → 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: 04e0653c66e2b3caa406acdfd07269a638ad834fd0791858f9d71dfa3eb43bbd
4
- data.tar.gz: 1b1350d46fc9937987c5077a9130dc0602852afd72f8c57433cb746957290351
3
+ metadata.gz: 3752fe30f06aa219d8980f67f509d424bf2151237a26a3ead62cca2357fa5b28
4
+ data.tar.gz: 60c9c9ae54297729fb5f7392cdfef6e39e8842524b32b08fa81fcc546787dcfa
5
5
  SHA512:
6
- metadata.gz: 0cb66e8911fc9c18b9a7b05e2737400acc32a6fc444ceccbc0cf1da1e48515f299d793d55be2ec8310fb8b9be759f05fa2abe90b2b7e98ab82fa7d2f1514550c
7
- data.tar.gz: 707d0d37111906368efd76b9f9086a7e026ee502ce1e0e31a3651d3b6b952507dad4b262946f4feea980ded9a2dfd22008580f5c61822fee054a9cc2ead7b5ba
6
+ metadata.gz: 5c598babbcffaf1dd479ccc45f1df91a793af4915f07f17dfbd59b3d7e3716d026cd63dfb84e2a4064915eeae9d152f48e68da0b716e6264f66475f77d93ad7e
7
+ data.tar.gz: 8515582240378e430d5c81281aabf84a278fe646df72da79707c636608ead74693193525f0373640f63fb20b583c123d58ae4f7affcb4f8befd1a0e2831d7462
@@ -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
 
@@ -93,6 +97,7 @@ module GovukMarkdown
93
97
  .new(document)
94
98
  .inject_inset_text
95
99
  .inject_details
100
+ .strip_front_matter(@strip_front_matter)
96
101
  .output
97
102
  end
98
103
  end
@@ -1,3 +1,3 @@
1
1
  module GovukMarkdown
2
- VERSION = "2.0.2".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.2
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: 2024-04-18 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
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  requirements: []
148
148
  rubygems_version: 3.3.26
149
- signing_key:
149
+ signing_key:
150
150
  specification_version: 4
151
151
  summary: Convert Markdown into GOV.UK styled HTML
152
152
  test_files: []