Skip to content

Commit 399a52e

Browse files
authored
Merge pull request #446 from gjtorikian/add-insert-extension
Add `insert` extension for rendering `++text++` as `<ins>text</ins>`
2 parents 886dfb7 + 22f957b commit 399a52e

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ Commonmarker.to_html('"Hi *there*"', options: {
219219
| `alerts` | Enables the alerts extension. | `false` |
220220
| `cjk_friendly_emphasis` | Enables the [CJK friendly emphasis](https://github.com/tats-u/markdown-cjk-friendly) extension. | `false` |
221221
| `highlight` | Enables highlighting via `==` | `false` |
222+
| `insert` | Enables the insert extension, rendering `++text++` as `<ins>text</ins>`. | `false` |
222223

223224
For more information on these options, see [the comrak documentation](https://github.com/kivikakk/comrak#usage).
224225

ext/commonmarker/src/options.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ const EXTENSION_SUBTEXT: &str = "subtext";
126126
const EXTENSION_ALERTS: &str = "alerts";
127127
const EXTENSION_CJK_FRIENDLY_EMPHASIS: &str = "cjk_friendly_emphasis";
128128
const EXTENSION_HIGHLIGHT: &str = "highlight";
129+
const EXTENSION_INSERT: &str = "insert";
129130

130131
pub fn iterate_extension_options(
131132
comrak_options: &mut comrak::options::Extension,
@@ -213,6 +214,9 @@ pub fn iterate_extension_options(
213214
Cow::Borrowed(EXTENSION_HIGHLIGHT) => {
214215
comrak_options.highlight = TryConvert::try_convert(value)?;
215216
}
217+
Cow::Borrowed(EXTENSION_INSERT) => {
218+
comrak_options.insert = TryConvert::try_convert(value)?;
219+
}
216220
_ => {}
217221
}
218222
Ok(ForEach::Continue)

lib/commonmarker/config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module Config
5353
alerts: false,
5454
cjk_friendly_emphasis: false,
5555
highlight: false,
56+
insert: false,
5657
}.freeze,
5758
format: [:html].freeze,
5859
}.freeze

test/extensions_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,18 @@ def test_highlight_extension
127127
Commonmarker.to_html("This is ==important!==.", options: options),
128128
)
129129
end
130+
131+
def test_insert_extension
132+
assert_equal(
133+
"<p>This is ++important!++.</p>\n",
134+
Commonmarker.to_html("This is ++important!++."),
135+
)
136+
137+
options = { extension: { insert: true } }
138+
139+
assert_equal(
140+
"<p>This is <ins>important!</ins>.</p>\n",
141+
Commonmarker.to_html("This is ++important!++.", options: options),
142+
)
143+
end
130144
end

0 commit comments

Comments
 (0)