middleman-commonmarker 0.2.0 → 0.3.0
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/CHANGELOG.md +7 -0
- data/README.md +6 -3
- data/lib/middleman-commonmarker/commonmarker_template.rb +2 -1
- data/lib/middleman-commonmarker/version.rb +1 -1
- data/test/commonmarker_template_test.rb +18 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7938f5a8afb2d9e01bb037c4b62fefcc9f5b84a92a4886b33134a95055fbc32e
|
|
4
|
+
data.tar.gz: 0f0fd975884df03a1a25cde357c61bd87230430b6ac683ecea52c8b8c1dee876
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35421d08c87e2ef6de283ac036951ebca03136bbb4a0f08610ccf5f4252618563287d89d70936545447857ab6630387a375dc035bf25f9659bca8fd760e9da09
|
|
7
|
+
data.tar.gz: decc3cedac0273958f0dbe2854a2f6a9df04349253dd80c7290aff344c4767a0d57fe13acaa1fb62519f6d9d2cb97f17bf0205decb27e42081a7380bbf48c9c5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.3.0] - 2026-12-05
|
|
4
|
+
|
|
5
|
+
- Support commonmarker 3.0 ([#32](https://github.com/unasuke/middleman-commonmarker/pull/32)). This follows commonmarker 3.0's new defaults, which changes the rendered HTML:
|
|
6
|
+
- Fenced code blocks are no longer syntax highlighted unless `plugins` is set. Set `plugins: {syntax_highlighter: {}}` to get the previous `base16-ocean.dark` highlighting back.
|
|
7
|
+
- Backslash-escaped characters are no longer wrapped in `<span data-escaped-char>`. Set `escaped_char_spans: true` (newly accepted in `set :markdown` and `activate :commonmarker, options:`) to get the previous output back.
|
|
8
|
+
- Invalid `plugins` values raise `TypeError` (instead of `NoMethodError` for a non-Hash), and `plugins: {syntax_highlighter: {}}` now enables the default theme instead of raising.
|
|
9
|
+
|
|
3
10
|
## [0.2.0] - 2026-10-25
|
|
4
11
|
|
|
5
12
|
- Add `plugins` option to pass commonmarker plugins (e.g. syntax highlighter theme) ([#18](https://github.com/unasuke/middleman-commonmarker/pull/18))
|
data/README.md
CHANGED
|
@@ -48,11 +48,14 @@ These flat options are mapped onto commonmarker's `parse` / `render` / `extensio
|
|
|
48
48
|
|
|
49
49
|
### Syntax highlighting
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
Fenced code blocks are not syntax highlighted by default (commonmarker 3.0 and later turn the highlighter off unless you ask for it).
|
|
52
52
|
|
|
53
|
-
Use the `plugins` option to
|
|
53
|
+
Use the `plugins` option to enable it. Its value is passed as-is to commonmarker's `plugins:` argument; see [commonmarker's README](https://github.com/gjtorikian/commonmarker#plugins) for the available values. The highlighter writes the colors as inline `style` attributes.
|
|
54
54
|
|
|
55
55
|
```ruby
|
|
56
|
+
# Use the default theme (base16-ocean.dark), as commonmarker 2.x did without any option
|
|
57
|
+
set :markdown, plugins: {syntax_highlighter: {}}
|
|
58
|
+
|
|
56
59
|
# Use another built-in theme
|
|
57
60
|
set :markdown, plugins: {syntax_highlighter: {theme: "InspiredGitHub"}}
|
|
58
61
|
|
|
@@ -61,7 +64,7 @@ set :markdown, plugins: {
|
|
|
61
64
|
syntax_highlighter: {theme: "my-theme", path: File.expand_path("syntax_themes", __dir__)}
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
# Disable syntax highlighting
|
|
67
|
+
# Disable syntax highlighting (the default)
|
|
65
68
|
set :markdown, plugins: {syntax_highlighter: nil}
|
|
66
69
|
```
|
|
67
70
|
|
|
@@ -14,7 +14,8 @@ module Middleman
|
|
|
14
14
|
|
|
15
15
|
DEFAULT_PARSE_OPTIONS = {smart: false, default_info_string: nil}.freeze
|
|
16
16
|
DEFAULT_RENDER_OPTIONS = {hardbreaks: false, github_pre_lang: false, width: 80,
|
|
17
|
-
unsafe: false, escape: false, sourcepos: false
|
|
17
|
+
unsafe: false, escape: false, sourcepos: false,
|
|
18
|
+
escaped_char_spans: false}.freeze
|
|
18
19
|
DEFAULT_EXTENSION_OPTIONS = {strikethrough: false, tagfilter: false, table: false,
|
|
19
20
|
autolink: false, tasklist: false, superscript: false,
|
|
20
21
|
header_ids: nil, footnotes: false, description_lists: false,
|
|
@@ -37,6 +37,16 @@ class CommonmarkerTemplateTest < Minitest::Test
|
|
|
37
37
|
assert_equal true, opts[:render][:hardbreaks]
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
def test_escaped_char_spans_is_off_by_default
|
|
41
|
+
assert_equal "<p>a * b</p>\n", build({}, "a \\* b\n").render
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_escaped_char_spans_maps_to_render
|
|
45
|
+
assert_equal true, options_for(escaped_char_spans: true)[:render][:escaped_char_spans]
|
|
46
|
+
assert_equal "<p>a <span data-escaped-char>*</span> b</p>\n",
|
|
47
|
+
build({escaped_char_spans: true}, "a \\* b\n").render
|
|
48
|
+
end
|
|
49
|
+
|
|
40
50
|
def test_smartypants_maps_to_parse_smart
|
|
41
51
|
assert_equal true, options_for(smartypants: true)[:parse][:smart]
|
|
42
52
|
end
|
|
@@ -70,6 +80,7 @@ class CommonmarkerTemplateTest < Minitest::Test
|
|
|
70
80
|
opts = template.send(:render_options_with_unsafe)
|
|
71
81
|
expected = Commonmarker.parse(CODE_BLOCK, options: opts).to_html(options: opts)
|
|
72
82
|
assert_equal expected, template.render
|
|
83
|
+
refute_includes template.render, "style="
|
|
73
84
|
end
|
|
74
85
|
|
|
75
86
|
def test_plugins_with_builtin_theme
|
|
@@ -82,8 +93,9 @@ class CommonmarkerTemplateTest < Minitest::Test
|
|
|
82
93
|
assert_includes html, "background-color:#123456"
|
|
83
94
|
end
|
|
84
95
|
|
|
85
|
-
def
|
|
86
|
-
|
|
96
|
+
def test_plugins_with_path_only_uses_default_theme
|
|
97
|
+
html = html_for(plugins: {syntax_highlighter: {path: THEMES_DIR}})
|
|
98
|
+
assert_includes html, "background-color:#2b303b"
|
|
87
99
|
end
|
|
88
100
|
|
|
89
101
|
def test_plugins_with_empty_theme_outputs_classes
|
|
@@ -117,8 +129,8 @@ class CommonmarkerTemplateTest < Minitest::Test
|
|
|
117
129
|
assert_raises(ArgumentError) { html_for(plugins: {syntax_highlighter: {theme: "no-such-theme"}}) }
|
|
118
130
|
end
|
|
119
131
|
|
|
120
|
-
def
|
|
121
|
-
|
|
132
|
+
def test_plugins_with_empty_highlighter_uses_default_theme
|
|
133
|
+
assert_includes html_for(plugins: {syntax_highlighter: {}}), "background-color:#2b303b"
|
|
122
134
|
end
|
|
123
135
|
|
|
124
136
|
def test_plugins_with_nil_theme_raises
|
|
@@ -126,8 +138,8 @@ class CommonmarkerTemplateTest < Minitest::Test
|
|
|
126
138
|
end
|
|
127
139
|
|
|
128
140
|
def test_plugins_with_non_hash_value_raises
|
|
129
|
-
|
|
130
|
-
assert_raises(
|
|
141
|
+
["x", [1]].each do |plugins|
|
|
142
|
+
assert_raises(TypeError, "plugins: #{plugins.inspect}") { html_for(plugins:) }
|
|
131
143
|
end
|
|
132
144
|
end
|
|
133
145
|
|