Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ Commonmarker.to_html('"Hi *there*"', options: {
| `alerts` | Enables the alerts extension. | `false` |
| `cjk_friendly_emphasis` | Enables the [CJK friendly emphasis](https://github.com/tats-u/markdown-cjk-friendly) extension. | `false` |
| `highlight` | Enables highlighting via `==` | `false` |
| `insert` | Enables the insert extension, rendering `++text++` as `<ins>text</ins>`. | `false` |

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

Expand Down
4 changes: 4 additions & 0 deletions ext/commonmarker/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const EXTENSION_SUBTEXT: &str = "subtext";
const EXTENSION_ALERTS: &str = "alerts";
const EXTENSION_CJK_FRIENDLY_EMPHASIS: &str = "cjk_friendly_emphasis";
const EXTENSION_HIGHLIGHT: &str = "highlight";
const EXTENSION_INSERT: &str = "insert";

pub fn iterate_extension_options(
comrak_options: &mut comrak::options::Extension,
Expand Down Expand Up @@ -213,6 +214,9 @@ pub fn iterate_extension_options(
Cow::Borrowed(EXTENSION_HIGHLIGHT) => {
comrak_options.highlight = TryConvert::try_convert(value)?;
}
Cow::Borrowed(EXTENSION_INSERT) => {
comrak_options.insert = TryConvert::try_convert(value)?;
}
_ => {}
}
Ok(ForEach::Continue)
Expand Down
1 change: 1 addition & 0 deletions lib/commonmarker/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module Config
alerts: false,
cjk_friendly_emphasis: false,
highlight: false,
insert: false,
}.freeze,
format: [:html].freeze,
}.freeze
Expand Down
14 changes: 14 additions & 0 deletions test/extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,18 @@ def test_highlight_extension
Commonmarker.to_html("This is ==important!==.", options: options),
)
end

def test_insert_extension
assert_equal(
"<p>This is ++important!++.</p>\n",
Commonmarker.to_html("This is ++important!++."),
)

options = { extension: { insert: true } }

assert_equal(
"<p>This is <ins>important!</ins>.</p>\n",
Commonmarker.to_html("This is ++important!++.", options: options),
)
end
end
Loading