Skip to content

Commit

Permalink
Add multiline_block_quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed Apr 30, 2024
1 parent c9de6ac commit 5ac1dc9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Commonmarker.to_html('"Hi *there*"', options: {
| `description_lists` | Enables the description lists extension. | `false` |
| `front_matter_delimiter` | Enables the front matter extension. | `""` |
| `shortcodes` | Enables the shortcodes extension. | `true` |
| `multiline_block_quotes` | Enables the multiline block quotes extension. | `false` |

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

Expand Down
5 changes: 5 additions & 0 deletions ext/commonmarker/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const EXTENSION_FOOTNOTES: &str = "footnotes";
const EXTENSION_DESCRIPTION_LISTS: &str = "description_lists";
const EXTENSION_FRONT_MATTER_DELIMITER: &str = "front_matter_delimiter";
const EXTENSION_SHORTCODES: &str = "shortcodes";
const EXTENSION_MULTILINE_BLOCK_QUOTES: &str = "multiline_block_quotes";

fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
options_hash
Expand Down Expand Up @@ -117,6 +118,10 @@ fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: R
Ok(Cow::Borrowed(EXTENSION_SHORTCODES)) => {
comrak_options.extension.shortcodes = TryConvert::try_convert(value)?;
}
Ok(Cow::Borrowed(EXTENSION_MULTILINE_BLOCK_QUOTES)) => {
comrak_options.extension.multiline_block_quotes =
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 @@ -29,6 +29,7 @@ module Config
description_lists: false,
front_matter_delimiter: "",
shortcodes: true,
multiline_block_quotes: false,
},
format: [:html].freeze,
}.freeze
Expand Down
23 changes: 23 additions & 0 deletions test/multiline_block_quotes_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require "test_helper"

class MultilineBlockQuotesTest < Minitest::Test
def test_to_html
md = <<~MARKDOWN
>>>
Paragraph 1
Paragraph 2
>>>
MARKDOWN
expected = <<~HTML
<blockquote>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
</blockquote>
HTML

assert_equal(expected, Commonmarker.to_html(md, options: { extension: { multiline_block_quotes: true } }))
end
end

0 comments on commit 5ac1dc9

Please sign in to comment.