Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump heading sizes down a level #12

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@

## Released

### [0.2.1] - 2023-08-21

- Bump heading sizes down a level [#12](https://github.com/alphagov/govuk-forms-markdown/pull/12/)

### [0.2.0] - 2023-08-015

- All links should open in a new tab [#9](https://github.com/alphagov/govuk-forms-markdown/issues/9)

### [0.1.0] - 2023-08-03

- Initial release
- Adds custom render methods for markdown syntax we would like to support.

- Heading levels 2 & 3, anything else returns as unstyled text
- Links styled like GOV.UK
- Links styled like GOV.UK
- Lists (ordered and unordered)

- We do not support the following

- Heading level 1
- tables
- horizontal rules
- emphasis
- code blocks
- custom HTML

2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
govuk-forms-markdown (0.2.0)
govuk-forms-markdown (0.2.1)
redcarpet (~> 3.6)

GEM
Expand Down
4 changes: 2 additions & 2 deletions lib/govuk-forms-markdown/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def initialize(options = {})

def header(text, header_level)
heading_size = case header_level
when 2 then "l"
when 3 then "m"
when 2 then "m"
when 3 then "s"
end

if heading_size.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/govuk-forms-markdown/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module GovukFormsMarkdown
VERSION = "0.2.0"
VERSION = "0.2.1"
end
6 changes: 3 additions & 3 deletions spec/govuk-forms-markdown/govuk_forms_markdown_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
end

it "renders H2s and GOV.UK classes" do
expect(render("## Top heading")).to eq('<h2 class="govuk-heading-l">Top heading</h2>')
expect(render("## Top heading")).to eq('<h2 class="govuk-heading-m">Top heading</h2>')
end

it "renders H3s with ids and GOV.UK classes" do
expect(render("### A heading")).to eq('<h3 class="govuk-heading-m">A heading</h3>')
expect(render("### A heading")).to eq('<h3 class="govuk-heading-s">A heading</h3>')
end

it "renders paragraphs with GOV.UK classes" do
Expand Down Expand Up @@ -91,7 +91,7 @@

context "when unsafe content is used it should be escaped" do
it "renders escaped H2s and GOV.UK classes" do
expect(render("## <script>alert('Hacked');</script>")).to eq('<h2 class="govuk-heading-l">&lt;script&gt;alert(&#39;Hacked&#39;);&lt;/script&gt;</h2>')
expect(render("## <script>alert('Hacked');</script>")).to eq('<h2 class="govuk-heading-m">&lt;script&gt;alert(&#39;Hacked&#39;);&lt;/script&gt;</h2>')
end

it "renders escaped p and GOV.UK classes" do
Expand Down
2 changes: 1 addition & 1 deletion spec/govuk-forms-markdown/renderer/header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
supported_heading_levels = [2, 3]
supported_heading_levels.each do |level|
it "does format heading level #{level}" do
heading_size = level == 2 ? "l" : "m"
heading_size = level == 2 ? "m" : "s"
expect(renderer.header("Heading level #{level}", level).strip).to eq "<h#{level} class=\"govuk-heading-#{heading_size}\">Heading level #{level}</h#{level}>"
end
end
Expand Down