Skip to content

Commit

Permalink
Merge pull request #303 from gjtorikian/dependabot/cargo/comrak-0.25.0
Browse files Browse the repository at this point in the history
Bump comrak from 0.24.1 to 0.25.0
  • Loading branch information
kivikakk authored Jul 12, 2024
2 parents 9639202 + a852d36 commit 4a59b35
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 39 deletions.
39 changes: 37 additions & 2 deletions Cargo.lock

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

55 changes: 33 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,50 +151,61 @@ Note that there is a distinction in comrak for "parse" options and "render" opti

### Parse options

| Name | Description | Default |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
| `smart` | Punctuation (quotes, full-stops and hyphens) are converted into 'smart' punctuation. | `false` |
| `default_info_string` | The default info string for fenced code blocks. | `""` |
| `relaxed_autolinks` | Enable relaxing of the autolink extension parsing, allowing links to be recognized when in brackets, as well as permitting any url scheme. | `false` |
| Name | Description | Default |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `smart` | Punctuation (quotes, full-stops and hyphens) are converted into 'smart' punctuation. | `false` |
| `default_info_string` | The default info string for fenced code blocks. | `""` |
| `relaxed_tasklist_matching` | Enables relaxing of the tasklist extension matching, allowing any non-space to be used for the "checked" state instead of only `x` and `X`. | `false` |
| `relaxed_autolinks` | Enable relaxing of the autolink extension parsing, allowing links to be recognized when in brackets, as well as permitting any url scheme. | `false` |

### Render options

| Name | Description | Default |
| -------------------- | ------------------------------------------------------------------------------------------------------ | ------- |
| `hardbreaks` | [Soft line breaks](http://spec.commonmark.org/0.27/#soft-line-breaks) translate into hard line breaks. | `true` |
| `github_pre_lang` | GitHub-style `<pre lang="xyz">` is used for fenced code blocks with info tags. | `true` |
| `full_info_string` | Gives info string data after a space in a `data-meta` attribute on code blocks. | `false` |
| `width` | The wrap column when outputting CommonMark. | `80` |
| `unsafe` | Allow rendering of raw HTML and potentially dangerous links. | `false` |
| `escape` | Escape raw HTML instead of clobbering it. | `false` |
| `sourcepos` | Include source position attribute in HTML and XML output. | `false` |
| `escaped_char_spans` | Wrap escaped characters in span tags | `true` |
| `escaped_char_spans` | Wrap escaped characters in span tags. | `true` |
| `ignore_setext` | Ignores setext-style headings. | `false` |
| `ignore_empty_links` | Ignores empty links, leaving the Markdown text in place. | `false` |
| `gfm_quirks` | Outputs HTML with GFM-style quirks; namely, not nesting `<strong>` inlines. | `false` |
| `prefer_fenced` | Always output fenced code blocks, even where an indented one could be used. | `false` |

As well, there are several extensions which you can toggle in the same manner:

```ruby
Commonmarker.to_html('"Hi *there*"', options: {
extension: { footnotes: true, description_lists: true },
render: { hardbreaks: false}
render: { hardbreaks: false }
})
```

### Extension options

| Name | Description | Default |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------- |
| `strikethrough` | Enables the [strikethrough extension](https://github.github.com/gfm/#strikethrough-extension-) from the GFM spec. | `true` |
| `tagfilter` | Enables the [tagfilter extension](https://github.github.com/gfm/#disallowed-raw-html-extension-) from the GFM spec. | `true` |
| `table` | Enables the [table extension](https://github.github.com/gfm/#tables-extension-) from the GFM spec. | `true` |
| `autolink` | Enables the [autolink extension](https://github.github.com/gfm/#autolinks-extension-) from the GFM spec. | `true` |
| `tasklist` | Enables the [task list extension](https://github.github.com/gfm/#task-list-items-extension-) from the GFM spec. | `true` |
| `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` |
| `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` |
| `math_dollars`, `math_code` | Enables the math extension. | `false` |
| Name | Description | Default |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------- |
| `strikethrough` | Enables the [strikethrough extension](https://github.github.com/gfm/#strikethrough-extension-) from the GFM spec. | `true` |
| `tagfilter` | Enables the [tagfilter extension](https://github.github.com/gfm/#disallowed-raw-html-extension-) from the GFM spec. | `true` |
| `table` | Enables the [table extension](https://github.github.com/gfm/#tables-extension-) from the GFM spec. | `true` |
| `autolink` | Enables the [autolink extension](https://github.github.com/gfm/#autolinks-extension-) from the GFM spec. | `true` |
| `tasklist` | Enables the [task list extension](https://github.github.com/gfm/#task-list-items-extension-) from the GFM spec. | `true` |
| `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` |
| `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` |
| `math_dollars`, `math_code` | Enables the math extension. | `false` |
| `shortcodes` | Enables the shortcodes extension. | `true` |
| `wikilinks_title_before_pipe` | Enables the wikilinks extension, placing the title before the dividing pipe. | `false` |
| `wikilinks_title_after_pipe` | Enables the shortcodes extension, placing the title after the dividing pipe. | `false` |
| `underline` | Enables the underline extension. | `false` |
| `spoiler` | Enables the spoiler extension. | `false` |
| `greentext` | Enables the greentext extension. | `false` |

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

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.7", features = ["rb-sys"] }
rb-sys = { version = "*", default-features = false, features = [
"stable-api-compiled-fallback",
] }
comrak = { version = "0.24", features = ["shortcodes"] }
comrak = { version = "0.25", features = ["shortcodes"] }
syntect = { version = "5.2", features = ["plist-load"] }
typed-arena = "2.0"
rctree = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion ext/commonmarker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn commonmark_to_html(args: &[Value]) -> Result<String, magnus::Error> {
))
}

fn format_options(rb_options: Option<RHash>) -> Result<comrak::Options, magnus::Error> {
fn format_options<'c>(rb_options: Option<RHash>) -> Result<comrak::Options<'c>, magnus::Error> {
let mut comrak_options = ComrakOptions::default();

if let Some(rb_options) = rb_options {
Expand Down
19 changes: 11 additions & 8 deletions ext/commonmarker/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ impl CommonmarkerNode {
let (alignments, num_columns, num_rows, num_nonempty_cells) = kwargs.required;

let mut comrak_alignments = vec![];
alignments.each().for_each(|alignment| {
match alignment.unwrap().to_string().as_str() {
alignments
.into_iter()
.for_each(|alignment| match alignment.to_string().as_str() {
"left" => {
comrak_alignments.push(TableAlignment::Left);
}
Expand All @@ -252,8 +253,7 @@ impl CommonmarkerNode {
_ => {
comrak_alignments.push(TableAlignment::None);
}
}
});
});
ComrakNodeValue::Table(NodeTable {
// The table alignments
alignments: comrak_alignments,
Expand Down Expand Up @@ -401,12 +401,12 @@ impl CommonmarkerNode {

let (code,) = kwargs.required;

match NodeShortCode::try_from(code.as_str()) {
Ok(shortcode) => ComrakNodeValue::ShortCode(shortcode),
_ => {
match NodeShortCode::resolve(code.as_str()) {
Some(shortcode) => ComrakNodeValue::ShortCode(shortcode),
None => {
return Err(magnus::Error::new(
magnus::exception::arg_error(),
"list type must be `bullet` or `ordered`",
"could not resolve shortcode",
));
}
}
Expand Down Expand Up @@ -549,6 +549,9 @@ impl CommonmarkerNode {
ComrakNodeValue::Escaped => Symbol::new("escaped"),
ComrakNodeValue::Math(..) => Symbol::new("math"),
ComrakNodeValue::WikiLink(..) => Symbol::new("wikilink"),
ComrakNodeValue::Underline => Symbol::new("underline"),
ComrakNodeValue::SpoileredText => Symbol::new("spoilered_text"),
ComrakNodeValue::EscapedTag(_) => Symbol::new("escaped_tag"),
}
}

Expand Down
Loading

0 comments on commit 4a59b35

Please sign in to comment.