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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ Commonmarker.to_html('"Hi *there*"', options: {
| `superscript` | Enables the superscript Comrak extension. | `false` |
| `header_ids` | Enables the header IDs Comrak extension. from the GFM spec. | `""` |
| `footnotes` | Enables the footnotes extension per `cmark-gfm`. | `false` |
| `inline_footnotes` | Enables the inline footnotes extension. | `false` |
| `description_lists` | Enables the description lists extension. | `false` |
| `front_matter_delimiter` | Enables the front matter extension. | `""` |
| `multiline_block_quotes` | Enables the multiline block quotes extension. | `false` |
Expand Down
2 changes: 1 addition & 1 deletion ext/commonmarker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ magnus = { version = "0.8", features = ["rb-sys"] }
rb-sys = { version = "*", default-features = false, features = [
"stable-api-compiled-fallback",
] }
comrak = { version = "0.43", features = ["shortcodes"] }
comrak = { version = "0.44", features = ["shortcodes"] }
syntect = { version = "5.3", features = ["plist-load"] }
typed-arena = "2.0"
rctree = "0.6"
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 @@ -109,6 +109,7 @@ const EXTENSION_TASKLIST: &str = "tasklist";
const EXTENSION_SUPERSCRIPT: &str = "superscript";
const EXTENSION_HEADER_IDS: &str = "header_ids";
const EXTENSION_FOOTNOTES: &str = "footnotes";
const EXTENSION_INLINE_FOOTNOTES: &str = "inline_footnotes";
const EXTENSION_DESCRIPTION_LISTS: &str = "description_lists";
const EXTENSION_FRONT_MATTER_DELIMITER: &str = "front_matter_delimiter";
const EXTENSION_MULTILINE_BLOCK_QUOTES: &str = "multiline_block_quotes";
Expand Down Expand Up @@ -152,6 +153,9 @@ fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: R
Cow::Borrowed(EXTENSION_FOOTNOTES) => {
comrak_options.extension.footnotes = TryConvert::try_convert(value)?;
}
Cow::Borrowed(EXTENSION_INLINE_FOOTNOTES) => {
comrak_options.extension.inline_footnotes = TryConvert::try_convert(value)?;
}
Cow::Borrowed(EXTENSION_DESCRIPTION_LISTS) => {
comrak_options.extension.description_lists = TryConvert::try_convert(value)?;
}
Expand Down
1 change: 1 addition & 0 deletions lib/commonmarker/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Config
superscript: false,
header_ids: "",
footnotes: false,
inline_footnotes: false,
description_lists: false,
front_matter_delimiter: "",
multiline_block_quotes: false,
Expand Down
18 changes: 18 additions & 0 deletions test/footnotes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,22 @@ def test_to_html

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

def test_inline_to_html
md = <<~MARKDOWN
Let's render some footnotes^[This is a footnote]
MARKDOWN
expected = <<~HTML
<p>Let's render some footnotes<sup class="footnote-ref"><a href="#fn-__inline_1" id="fnref-__inline_1" data-footnote-ref>1</a></sup></p>
<section class="footnotes" data-footnotes>
<ol>
<li id="fn-__inline_1">
<p>This is a footnote <a href="#fnref-__inline_1" class="footnote-backref" data-footnote-backref data-footnote-backref-idx="1" aria-label="Back to reference 1">↩</a></p>
</li>
</ol>
</section>
HTML

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