govuk_markdown 2.0.0b1 → 2.0.1
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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +9 -9
- data/README.md +47 -10
- data/lib/govuk_markdown/preprocessor.rb +11 -4
- data/lib/govuk_markdown/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 975a784ccde8bc595764bf9bbff9dc0377b00d43e3114a0870f75fb9a74dc828
|
4
|
+
data.tar.gz: a648e648e2a72505e45f9100a3f4c7599287cca3c0bdd78fb34d5110cfcac62d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2309375dd6555cc7ca361513a9147844611519ad5c19a765e24a018cab5725faa2d91e50ca7698080d2efa7dc526876096f0ff97f7c7984945ab8da517e7a48
|
7
|
+
data.tar.gz: 8ad79ffc90dae8461e019b18ad5371e94943df3e39d58697089a4a8510d856a1d0859b5b8792f0e4118f99715af106043db4e7ed1b96085794fa58b95f8da7c9
|
data/.gitignore
CHANGED
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,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
govuk_markdown (2.0.
|
4
|
+
govuk_markdown (2.0.1)
|
5
5
|
activesupport
|
6
6
|
redcarpet
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.1.
|
11
|
+
activesupport (6.1.7.3)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 1.6, < 2)
|
14
14
|
minitest (>= 5.1)
|
@@ -16,22 +16,22 @@ GEM
|
|
16
16
|
zeitwerk (~> 2.3)
|
17
17
|
ast (2.4.2)
|
18
18
|
coderay (1.1.3)
|
19
|
-
concurrent-ruby (1.
|
19
|
+
concurrent-ruby (1.2.2)
|
20
20
|
diff-lcs (1.4.4)
|
21
|
-
i18n (1.
|
21
|
+
i18n (1.12.0)
|
22
22
|
concurrent-ruby (~> 1.0)
|
23
23
|
method_source (1.0.0)
|
24
|
-
minitest (5.
|
24
|
+
minitest (5.18.0)
|
25
25
|
parallel (1.20.1)
|
26
26
|
parser (3.0.2.0)
|
27
27
|
ast (~> 2.4.1)
|
28
28
|
pry (0.14.1)
|
29
29
|
coderay (~> 1.1)
|
30
30
|
method_source (~> 1.0)
|
31
|
-
rack (3.0.
|
31
|
+
rack (3.0.7)
|
32
32
|
rainbow (3.0.0)
|
33
33
|
rake (13.0.6)
|
34
|
-
redcarpet (3.
|
34
|
+
redcarpet (3.6.0)
|
35
35
|
regexp_parser (2.1.1)
|
36
36
|
rexml (3.2.5)
|
37
37
|
rspec (3.10.0)
|
@@ -74,10 +74,10 @@ GEM
|
|
74
74
|
rubocop (~> 1.0)
|
75
75
|
rubocop-ast (>= 1.1.0)
|
76
76
|
ruby-progressbar (1.11.0)
|
77
|
-
tzinfo (2.0.
|
77
|
+
tzinfo (2.0.6)
|
78
78
|
concurrent-ruby (~> 1.0)
|
79
79
|
unicode-display_width (2.0.0)
|
80
|
-
zeitwerk (2.
|
80
|
+
zeitwerk (2.6.7)
|
81
81
|
|
82
82
|
PLATFORMS
|
83
83
|
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 Components](https://github.com/DFE-Digital/govuk-components) version 4.0.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://govuk-components.netlify.app/components/inset-text/) to your markdown document, use the following tags:
|
56
|
+
|
57
|
+
```markdown
|
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://govuk-components.netlify.app/components/details/) to your markdown, use the following tags:
|
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}
|
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/
|
91
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/DfE-digital/govuk-markdown.
|
@@ -7,10 +7,10 @@ module GovukMarkdown
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def inject_inset_text
|
10
|
-
output.gsub
|
10
|
+
@output = output.gsub(build_regexp("inset-text")) do
|
11
11
|
<<~HTML
|
12
12
|
<div class="govuk-inset-text">
|
13
|
-
#{Regexp.last_match(1)}
|
13
|
+
#{nested_markdown(Regexp.last_match(1))}
|
14
14
|
</div>
|
15
15
|
HTML
|
16
16
|
end
|
@@ -18,7 +18,7 @@ module GovukMarkdown
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def inject_details
|
21
|
-
output.gsub
|
21
|
+
@output = output.gsub(build_regexp("details")) do
|
22
22
|
summary, details = *construct_details_from(Regexp.last_match(1))
|
23
23
|
|
24
24
|
<<~HTML
|
@@ -29,7 +29,7 @@ module GovukMarkdown
|
|
29
29
|
</span>
|
30
30
|
</summary>
|
31
31
|
<div class="govuk-details__text">
|
32
|
-
#{details}
|
32
|
+
#{nested_markdown(details)}
|
33
33
|
</div>
|
34
34
|
</details>
|
35
35
|
HTML
|
@@ -39,6 +39,13 @@ module GovukMarkdown
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
+
# parse as markdown if there are multiple lines of content
|
43
|
+
def nested_markdown(content)
|
44
|
+
return content unless content =~ /\n/
|
45
|
+
|
46
|
+
GovukMarkdown.render(content)
|
47
|
+
end
|
48
|
+
|
42
49
|
def build_regexp(tag_name, pre_tag: "{", post_tag: "}", closing: "/")
|
43
50
|
start_tag = pre_tag + tag_name + post_tag
|
44
51
|
end_tag = pre_tag + closing + tag_name + post_tag
|
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.
|
4
|
+
version: 2.0.1
|
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-
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -141,9 +141,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
141
|
version: 2.7.0
|
142
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- - "
|
144
|
+
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
146
|
+
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubygems_version: 3.1.4
|
149
149
|
signing_key:
|