commonmarker 2.8.3 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +18 -18
- data/README.md +35 -15
- data/ext/commonmarker/Cargo.toml +2 -2
- data/ext/commonmarker/src/node.rs +113 -3
- data/ext/commonmarker/src/options.rs +11 -0
- data/lib/commonmarker/config.rb +4 -2
- data/lib/commonmarker/node/inspect.rb +2 -4
- data/lib/commonmarker/node.rb +12 -0
- data/lib/commonmarker/version.rb +1 -1
- metadata +1 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23a7f4c3d26ba5e9b9301c9af8db67520fdda959f6cf8faab5564e9276d8d7bc
|
|
4
|
+
data.tar.gz: 7ee7de8566813969b327b94d3e0c8b6a8e536a38906522cb7eb9f13206186811
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eafbbb68ab07ac0ab161437cb6327ea55e232d6c412ea1be6f7d4b6474fae61607d905efc028000c5be2a9c193719e7b5dda16b69d4be2dbcdef112c65c82ed5
|
|
7
|
+
data.tar.gz: f2c79a17c4dec72cdd65979d59952097a286f125a593935986088788cb936f1a99e0dc13f2493afc8c96e309dc175900989956e39fa0044bc9bc8bbd893578c2
|
data/Cargo.lock
CHANGED
|
@@ -82,9 +82,9 @@ dependencies = [
|
|
|
82
82
|
|
|
83
83
|
[[package]]
|
|
84
84
|
name = "cc"
|
|
85
|
-
version = "1.2.
|
|
85
|
+
version = "1.2.67"
|
|
86
86
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
-
checksum = "
|
|
87
|
+
checksum = "e17dd265a7d0f31ef544e1b20e03add05d3b45b491b633b10d67145d2acc1a38"
|
|
88
88
|
dependencies = [
|
|
89
89
|
"find-msvc-tools",
|
|
90
90
|
"shlex 2.0.1",
|
|
@@ -131,9 +131,9 @@ dependencies = [
|
|
|
131
131
|
|
|
132
132
|
[[package]]
|
|
133
133
|
name = "comrak"
|
|
134
|
-
version = "0.
|
|
134
|
+
version = "0.54.0"
|
|
135
135
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
136
|
-
checksum = "
|
|
136
|
+
checksum = "0d5910408554659ed848ff469e67ec83b30f179e72cec286cfdae64d1616f466"
|
|
137
137
|
dependencies = [
|
|
138
138
|
"caseless",
|
|
139
139
|
"emojis",
|
|
@@ -331,9 +331,9 @@ dependencies = [
|
|
|
331
331
|
|
|
332
332
|
[[package]]
|
|
333
333
|
name = "memchr"
|
|
334
|
-
version = "2.8.
|
|
334
|
+
version = "2.8.3"
|
|
335
335
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
336
|
-
checksum = "
|
|
336
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
337
337
|
|
|
338
338
|
[[package]]
|
|
339
339
|
name = "minimal-lexical"
|
|
@@ -442,9 +442,9 @@ checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e"
|
|
|
442
442
|
|
|
443
443
|
[[package]]
|
|
444
444
|
name = "plist"
|
|
445
|
-
version = "1.
|
|
445
|
+
version = "1.10.0"
|
|
446
446
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
447
|
-
checksum = "
|
|
447
|
+
checksum = "7da1d65da6dd5d1e44199ac0f58712d241c0f439f80adea8924d832384087f85"
|
|
448
448
|
dependencies = [
|
|
449
449
|
"base64",
|
|
450
450
|
"indexmap",
|
|
@@ -470,9 +470,9 @@ dependencies = [
|
|
|
470
470
|
|
|
471
471
|
[[package]]
|
|
472
472
|
name = "quick-xml"
|
|
473
|
-
version = "0.
|
|
473
|
+
version = "0.41.0"
|
|
474
474
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
475
|
-
checksum = "
|
|
475
|
+
checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1"
|
|
476
476
|
dependencies = [
|
|
477
477
|
"memchr",
|
|
478
478
|
]
|
|
@@ -533,9 +533,9 @@ checksum = "e03e7866abec1101869ffa8e2c8355c4c2419d0214ece0cc3e428e5b94dea6e9"
|
|
|
533
533
|
|
|
534
534
|
[[package]]
|
|
535
535
|
name = "regex"
|
|
536
|
-
version = "1.
|
|
536
|
+
version = "1.13.0"
|
|
537
537
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
538
|
-
checksum = "
|
|
538
|
+
checksum = "2a0e75113e14dc5acb068cd0786884f214f1312650a3d36d269f5c4f3cdee8a2"
|
|
539
539
|
dependencies = [
|
|
540
540
|
"aho-corasick",
|
|
541
541
|
"memchr",
|
|
@@ -545,9 +545,9 @@ dependencies = [
|
|
|
545
545
|
|
|
546
546
|
[[package]]
|
|
547
547
|
name = "regex-automata"
|
|
548
|
-
version = "0.4.
|
|
548
|
+
version = "0.4.15"
|
|
549
549
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
550
|
-
checksum = "
|
|
550
|
+
checksum = "1f388202e4b80542a0921078cc23b6333bcf1409c1e3f86404cae4766a6131db"
|
|
551
551
|
dependencies = [
|
|
552
552
|
"aho-corasick",
|
|
553
553
|
"memchr",
|
|
@@ -562,9 +562,9 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
|
562
562
|
|
|
563
563
|
[[package]]
|
|
564
564
|
name = "rustc-hash"
|
|
565
|
-
version = "2.1.
|
|
565
|
+
version = "2.1.3"
|
|
566
566
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
567
|
-
checksum = "
|
|
567
|
+
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
568
568
|
|
|
569
569
|
[[package]]
|
|
570
570
|
name = "same-file"
|
|
@@ -744,9 +744,9 @@ dependencies = [
|
|
|
744
744
|
|
|
745
745
|
[[package]]
|
|
746
746
|
name = "tinyvec"
|
|
747
|
-
version = "1.
|
|
747
|
+
version = "1.12.0"
|
|
748
748
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
749
|
-
checksum = "
|
|
749
|
+
checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f"
|
|
750
750
|
dependencies = [
|
|
751
751
|
"tinyvec_macros",
|
|
752
752
|
]
|
data/README.md
CHANGED
|
@@ -140,6 +140,24 @@ doc.to_commonmark
|
|
|
140
140
|
# => # The site\n\nGitHub\n
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
+
### Reading and writing node content
|
|
144
|
+
|
|
145
|
+
`string_content` reads and writes the text of nodes whose content is plain text (like `:text`, `:code`, and `:code_block`).
|
|
146
|
+
|
|
147
|
+
`literal` reads and writes the raw string a node carries, for every node type that has one (like `:text`, `:code`, `:code_block`, `:html_block`, `:html_inline`, `:raw`, `:math`, and `:frontmatter`).
|
|
148
|
+
|
|
149
|
+
The two exist separately because they mean different things. Rewriting `string_content` only ever swaps text for text. Rewriting `literal` on an `:html_block`, `:html_inline`, or `:raw` node writes markup that is emitted unescaped:
|
|
150
|
+
|
|
151
|
+
```ruby
|
|
152
|
+
doc = Commonmarker.parse("A <b>bold</b> claim")
|
|
153
|
+
|
|
154
|
+
doc.walk do |node|
|
|
155
|
+
node.literal = "<i>" if node.type == :html_inline && node.literal == "<b>"
|
|
156
|
+
end
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Note that a `:frontmatter` node's literal includes its delimiters and trailing newlines, so anything you assign must include them too.
|
|
160
|
+
|
|
143
161
|
## Options and plugins
|
|
144
162
|
|
|
145
163
|
### Options
|
|
@@ -169,21 +187,22 @@ Note that there is a distinction in comrak for "parse" options and "render" opti
|
|
|
169
187
|
|
|
170
188
|
### Render options
|
|
171
189
|
|
|
172
|
-
| Name | Description
|
|
173
|
-
| -------------------- |
|
|
174
|
-
| `hardbreaks` | [Soft line breaks](http://spec.commonmark.org/0.27/#soft-line-breaks) translate into hard line breaks.
|
|
175
|
-
| `github_pre_lang` | GitHub-style `<pre lang="xyz">` is used for fenced code blocks with info tags.
|
|
176
|
-
| `full_info_string` | Gives info string data after a space in a `data-meta` attribute on code blocks.
|
|
177
|
-
| `width` | The wrap column when outputting CommonMark.
|
|
178
|
-
| `unsafe` | Allow rendering of raw HTML and potentially dangerous links.
|
|
179
|
-
| `escape` | Escape raw HTML instead of clobbering it.
|
|
180
|
-
| `sourcepos` | Include source position attribute in HTML and XML output.
|
|
181
|
-
| `escaped_char_spans` | Wrap escaped characters in span tags.
|
|
182
|
-
| `ignore_empty_links` | Ignores empty links, leaving the Markdown text in place.
|
|
183
|
-
| `gfm_quirks` | Outputs HTML with GFM-style quirks; namely, not nesting `<strong>` inlines.
|
|
184
|
-
| `prefer_fenced` | Always output fenced code blocks, even where an indented one could be used.
|
|
185
|
-
| `tasklist_classes` | Add CSS classes to the HTML output of the tasklist extension
|
|
186
|
-
| `compact_html` | Suppress newlines in pretty-printed HTML output.
|
|
190
|
+
| Name | Description | Default |
|
|
191
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------ |
|
|
192
|
+
| `hardbreaks` | [Soft line breaks](http://spec.commonmark.org/0.27/#soft-line-breaks) translate into hard line breaks. | `true` |
|
|
193
|
+
| `github_pre_lang` | GitHub-style `<pre lang="xyz">` is used for fenced code blocks with info tags. | `true` |
|
|
194
|
+
| `full_info_string` | Gives info string data after a space in a `data-meta` attribute on code blocks. | `false` |
|
|
195
|
+
| `width` | The wrap column when outputting CommonMark. | `80` |
|
|
196
|
+
| `unsafe` | Allow rendering of raw HTML and potentially dangerous links. | `false` |
|
|
197
|
+
| `escape` | Escape raw HTML instead of clobbering it. | `false` |
|
|
198
|
+
| `sourcepos` | Include source position attribute in HTML and XML output. | `false` |
|
|
199
|
+
| `escaped_char_spans` | Wrap escaped characters in span tags. | `true` |
|
|
200
|
+
| `ignore_empty_links` | Ignores empty links, leaving the Markdown text in place. | `false` |
|
|
201
|
+
| `gfm_quirks` | Outputs HTML with GFM-style quirks; namely, not nesting `<strong>` inlines. | `false` |
|
|
202
|
+
| `prefer_fenced` | Always output fenced code blocks, even where an indented one could be used. | `false` |
|
|
203
|
+
| `tasklist_classes` | Add CSS classes to the HTML output of the tasklist extension | `false` |
|
|
204
|
+
| `compact_html` | Suppress newlines in pretty-printed HTML output. | `false` |
|
|
205
|
+
| `alert_style` | The style of alert output: `"specific"` (`<div class="markdown-alert">`) or `"semantic"` (`<aside class="admonition">`). | `"specific"` |
|
|
187
206
|
|
|
188
207
|
As well, there are several extensions which you can toggle in the same manner:
|
|
189
208
|
|
|
@@ -212,6 +231,7 @@ Commonmarker.to_html('"Hi *there*"', options: {
|
|
|
212
231
|
| `front_matter_delimiter` | Enables the front matter extension. | `""` |
|
|
213
232
|
| `multiline_block_quotes` | Enables the multiline block quotes extension. | `false` |
|
|
214
233
|
| `math_dollars`, `math_code` | Enables the math extension. | `false` |
|
|
234
|
+
| `math_latex` | Enables the math extension with LaTeX-style delimiters (`\(inline\)`, `\[display\]`). | `false` |
|
|
215
235
|
| `shortcodes` | Enables the shortcodes extension. | `true` |
|
|
216
236
|
| `wikilinks_title_before_pipe` | Enables the wikilinks extension, placing the title before the dividing pipe. | `false` |
|
|
217
237
|
| `wikilinks_title_after_pipe` | Enables the wikilinks extension, placing the title after the dividing pipe. | `false` |
|
data/ext/commonmarker/Cargo.toml
CHANGED
|
@@ -21,7 +21,7 @@ syntect = { version = "5.3", default-features = false, features = [
|
|
|
21
21
|
|
|
22
22
|
# Everywhere except Windows: Oniguruma, the faster engine.
|
|
23
23
|
[target.'cfg(not(windows))'.dependencies]
|
|
24
|
-
comrak = { version = "0.
|
|
24
|
+
comrak = { version = "0.54", default-features = false, features = [
|
|
25
25
|
"shortcodes",
|
|
26
26
|
"syntect-onig",
|
|
27
27
|
] }
|
|
@@ -30,7 +30,7 @@ comrak = { version = "0.53", default-features = false, features = [
|
|
|
30
30
|
# linking a second copy (onig_sys) collides at link time and segfaults (xref #467).
|
|
31
31
|
# syntect-fancy swaps in the pure-Rust fancy-regex backend instead.
|
|
32
32
|
[target.'cfg(windows)'.dependencies]
|
|
33
|
-
comrak = { version = "0.
|
|
33
|
+
comrak = { version = "0.54", default-features = false, features = [
|
|
34
34
|
"shortcodes",
|
|
35
35
|
"syntect-fancy",
|
|
36
36
|
] }
|
|
@@ -31,6 +31,39 @@ pub struct CommonmarkerNode {
|
|
|
31
31
|
/// SAFETY: This is safe because we only access this data when the GVL is held.
|
|
32
32
|
unsafe impl Send for CommonmarkerNode {}
|
|
33
33
|
|
|
34
|
+
/// Reports whether a node value supports a given property, where "property" is
|
|
35
|
+
/// a method name with any trailing `=` or `?` removed.
|
|
36
|
+
///
|
|
37
|
+
/// `None` means the property is not type-dependent at all
|
|
38
|
+
/// (`walk`, `type`, `delete`, ...).
|
|
39
|
+
fn value_supports(value: &ComrakNodeValue, property: &str) -> Option<bool> {
|
|
40
|
+
let supported = match property {
|
|
41
|
+
"string_content" => matches!(
|
|
42
|
+
value,
|
|
43
|
+
ComrakNodeValue::Text(_) | ComrakNodeValue::Code(_) | ComrakNodeValue::CodeBlock(_)
|
|
44
|
+
),
|
|
45
|
+
"literal" => matches!(
|
|
46
|
+
value,
|
|
47
|
+
ComrakNodeValue::Text(_)
|
|
48
|
+
| ComrakNodeValue::Code(_)
|
|
49
|
+
| ComrakNodeValue::CodeBlock(_)
|
|
50
|
+
| ComrakNodeValue::HtmlBlock(_)
|
|
51
|
+
| ComrakNodeValue::HtmlInline(_)
|
|
52
|
+
| ComrakNodeValue::Raw(_)
|
|
53
|
+
| ComrakNodeValue::Math(_)
|
|
54
|
+
| ComrakNodeValue::FrontMatter(_)
|
|
55
|
+
),
|
|
56
|
+
"url" | "title" => matches!(value, ComrakNodeValue::Link(_) | ComrakNodeValue::Image(_)),
|
|
57
|
+
"header_level" => matches!(value, ComrakNodeValue::Heading(_)),
|
|
58
|
+
"list_type" | "list_start" | "list_tight" => matches!(value, ComrakNodeValue::List(_)),
|
|
59
|
+
"fenced" | "fence_info" => matches!(value, ComrakNodeValue::CodeBlock(_)),
|
|
60
|
+
"alert_type" => matches!(value, ComrakNodeValue::Alert(_)),
|
|
61
|
+
_ => return None,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
Some(supported)
|
|
65
|
+
}
|
|
66
|
+
|
|
34
67
|
impl CommonmarkerNode {
|
|
35
68
|
pub fn new(ruby: &Ruby, args: &[Value]) -> Result<Self, magnus::Error> {
|
|
36
69
|
let args = scan_args::scan_args::<_, (), (), (), _, ()>(args)?;
|
|
@@ -40,19 +73,31 @@ impl CommonmarkerNode {
|
|
|
40
73
|
"document" => ComrakNodeValue::Document,
|
|
41
74
|
"block_quote" => ComrakNodeValue::BlockQuote,
|
|
42
75
|
"footnote_definition" => {
|
|
43
|
-
|
|
76
|
+
// HACK: For whatever reason, on i686, Ruby's `1` won't scan as
|
|
77
|
+
// Option<u32>, failing with "RangeError: fixnum too big to convert into `u32`".
|
|
78
|
+
// (Fixnum should be 31-bit on i686? Is this not fine?)
|
|
79
|
+
// Scanning as usize (or u64) works, so shrug and move on.
|
|
80
|
+
let kwargs = scan_args::get_kwargs::<_, (String,), (Option<usize>,), ()>(
|
|
44
81
|
args.keywords,
|
|
45
82
|
&["name"],
|
|
46
83
|
&["total_references"],
|
|
47
84
|
)?;
|
|
48
85
|
let (name,) = kwargs.required;
|
|
49
|
-
let (
|
|
86
|
+
let (total_references,) = kwargs.optional;
|
|
87
|
+
|
|
88
|
+
// HACK: Totally a u32 tho.
|
|
89
|
+
let Ok(total_references) = u32::try_from(total_references.unwrap_or(1)) else {
|
|
90
|
+
return Err(magnus::Error::new(
|
|
91
|
+
ruby.exception_range_error(),
|
|
92
|
+
"total_references too big to convert into `u32`",
|
|
93
|
+
));
|
|
94
|
+
};
|
|
50
95
|
|
|
51
96
|
ComrakNodeValue::FootnoteDefinition(NodeFootnoteDefinition {
|
|
52
97
|
// The name of the footnote.
|
|
53
98
|
name,
|
|
54
99
|
// Total number of references to this footnote
|
|
55
|
-
total_references
|
|
100
|
+
total_references,
|
|
56
101
|
})
|
|
57
102
|
}
|
|
58
103
|
"list" => {
|
|
@@ -772,6 +817,63 @@ impl CommonmarkerNode {
|
|
|
772
817
|
}
|
|
773
818
|
}
|
|
774
819
|
|
|
820
|
+
/// Returns `true` or `false` if the given method is only available for
|
|
821
|
+
/// certain node types, and `nil` if its availability does not depend on
|
|
822
|
+
/// the node's type. Backs `Node#respond_to?`.
|
|
823
|
+
fn supports_method(rb_self: &Self, name: Symbol) -> Option<bool> {
|
|
824
|
+
let node = rb_self.inner.borrow();
|
|
825
|
+
let name = name.to_string();
|
|
826
|
+
let property = name.trim_end_matches('=').trim_end_matches('?');
|
|
827
|
+
|
|
828
|
+
value_supports(&node.data.value, property)
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
fn get_literal(ruby: &Ruby, rb_self: &Self) -> Result<String, magnus::Error> {
|
|
832
|
+
let node = rb_self.inner.borrow();
|
|
833
|
+
|
|
834
|
+
match &node.data.value {
|
|
835
|
+
ComrakNodeValue::Text(text) => Ok(text.to_string()),
|
|
836
|
+
ComrakNodeValue::Code(code) => Ok(code.literal.to_string()),
|
|
837
|
+
ComrakNodeValue::CodeBlock(code_block) => Ok(code_block.literal.to_string()),
|
|
838
|
+
ComrakNodeValue::HtmlBlock(html_block) => Ok(html_block.literal.to_string()),
|
|
839
|
+
ComrakNodeValue::HtmlInline(html_inline) => Ok(html_inline.to_string()),
|
|
840
|
+
ComrakNodeValue::Raw(raw) => Ok(raw.to_string()),
|
|
841
|
+
ComrakNodeValue::Math(math) => Ok(math.literal.to_string()),
|
|
842
|
+
ComrakNodeValue::FrontMatter(front_matter) => Ok(front_matter.to_string()),
|
|
843
|
+
_ => Err(magnus::Error::new(
|
|
844
|
+
ruby.exception_type_error(),
|
|
845
|
+
"node does not have a literal",
|
|
846
|
+
)),
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
fn set_literal(
|
|
851
|
+
ruby: &Ruby,
|
|
852
|
+
rb_self: &Self,
|
|
853
|
+
new_literal: String,
|
|
854
|
+
) -> Result<bool, magnus::Error> {
|
|
855
|
+
let mut node = rb_self.inner.borrow_mut();
|
|
856
|
+
|
|
857
|
+
match node.data.value {
|
|
858
|
+
ComrakNodeValue::Text(ref mut text) => *text = new_literal.into(),
|
|
859
|
+
ComrakNodeValue::Code(ref mut code) => code.literal = new_literal,
|
|
860
|
+
ComrakNodeValue::CodeBlock(ref mut code_block) => code_block.literal = new_literal,
|
|
861
|
+
ComrakNodeValue::HtmlBlock(ref mut html_block) => html_block.literal = new_literal,
|
|
862
|
+
ComrakNodeValue::HtmlInline(ref mut html_inline) => *html_inline = new_literal,
|
|
863
|
+
ComrakNodeValue::Raw(ref mut raw) => *raw = new_literal,
|
|
864
|
+
ComrakNodeValue::Math(ref mut math) => math.literal = new_literal,
|
|
865
|
+
ComrakNodeValue::FrontMatter(ref mut front_matter) => *front_matter = new_literal,
|
|
866
|
+
_ => {
|
|
867
|
+
return Err(magnus::Error::new(
|
|
868
|
+
ruby.exception_type_error(),
|
|
869
|
+
"node does not have a literal",
|
|
870
|
+
))
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
Ok(true)
|
|
875
|
+
}
|
|
876
|
+
|
|
775
877
|
fn get_title(ruby: &Ruby, rb_self: &Self) -> Result<String, magnus::Error> {
|
|
776
878
|
let node = rb_self.inner.borrow();
|
|
777
879
|
|
|
@@ -1280,6 +1382,14 @@ pub fn init(ruby: &Ruby, m_commonmarker: RModule) -> Result<(), magnus::Error> {
|
|
|
1280
1382
|
method!(CommonmarkerNode::set_string_content, 1),
|
|
1281
1383
|
)?;
|
|
1282
1384
|
|
|
1385
|
+
c_node.define_method("literal", method!(CommonmarkerNode::get_literal, 0))?;
|
|
1386
|
+
c_node.define_method("literal=", method!(CommonmarkerNode::set_literal, 1))?;
|
|
1387
|
+
|
|
1388
|
+
c_node.define_method(
|
|
1389
|
+
"node_supports?",
|
|
1390
|
+
method!(CommonmarkerNode::supports_method, 1),
|
|
1391
|
+
)?;
|
|
1392
|
+
|
|
1283
1393
|
c_node.define_method("url", method!(CommonmarkerNode::get_url, 0))?;
|
|
1284
1394
|
c_node.define_method("url=", method!(CommonmarkerNode::set_url, 1))?;
|
|
1285
1395
|
c_node.define_method("title", method!(CommonmarkerNode::get_title, 0))?;
|
|
@@ -58,6 +58,7 @@ const RENDER_GFM_QUIRKS: &str = "gfm_quirks";
|
|
|
58
58
|
const RENDER_PREFER_FENCED: &str = "prefer_fenced";
|
|
59
59
|
const RENDER_TASKLIST_CLASSES: &str = "tasklist_classes";
|
|
60
60
|
const RENDER_COMPACT_HTML: &str = "compact_html";
|
|
61
|
+
const RENDER_ALERT_STYLE: &str = "alert_style";
|
|
61
62
|
|
|
62
63
|
pub fn iterate_render_options(comrak_options: &mut comrak::options::Render, options_hash: RHash) {
|
|
63
64
|
options_hash
|
|
@@ -102,6 +103,12 @@ pub fn iterate_render_options(comrak_options: &mut comrak::options::Render, opti
|
|
|
102
103
|
Cow::Borrowed(RENDER_COMPACT_HTML) => {
|
|
103
104
|
comrak_options.compact_html = TryConvert::try_convert(value)?;
|
|
104
105
|
}
|
|
106
|
+
Cow::Borrowed(RENDER_ALERT_STYLE) => {
|
|
107
|
+
comrak_options.alert_style = match try_convert_string(value).as_deref() {
|
|
108
|
+
Some("semantic") => comrak::options::AlertStyleType::Semantic,
|
|
109
|
+
_ => comrak::options::AlertStyleType::Specific,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
105
112
|
_ => {}
|
|
106
113
|
}
|
|
107
114
|
Ok(ForEach::Continue)
|
|
@@ -124,6 +131,7 @@ const EXTENSION_FRONT_MATTER_DELIMITER: &str = "front_matter_delimiter";
|
|
|
124
131
|
const EXTENSION_MULTILINE_BLOCK_QUOTES: &str = "multiline_block_quotes";
|
|
125
132
|
const EXTENSION_MATH_DOLLARS: &str = "math_dollars";
|
|
126
133
|
const EXTENSION_MATH_CODE: &str = "math_code";
|
|
134
|
+
const EXTENSION_MATH_LATEX: &str = "math_latex";
|
|
127
135
|
const EXTENSION_SHORTCODES: &str = "shortcodes";
|
|
128
136
|
const EXTENSION_WIKILINKS_TITLE_AFTER_PIPE: &str = "wikilinks_title_after_pipe";
|
|
129
137
|
const EXTENSION_WIKILINKS_TITLE_BEFORE_PIPE: &str = "wikilinks_title_before_pipe";
|
|
@@ -194,6 +202,9 @@ pub fn iterate_extension_options(
|
|
|
194
202
|
Cow::Borrowed(EXTENSION_MATH_CODE) => {
|
|
195
203
|
comrak_options.math_code = TryConvert::try_convert(value)?;
|
|
196
204
|
}
|
|
205
|
+
Cow::Borrowed(EXTENSION_MATH_LATEX) => {
|
|
206
|
+
comrak_options.math_latex = TryConvert::try_convert(value)?;
|
|
207
|
+
}
|
|
197
208
|
Cow::Borrowed(EXTENSION_SHORTCODES) => {
|
|
198
209
|
comrak_options.shortcodes = TryConvert::try_convert(value)?;
|
|
199
210
|
}
|
data/lib/commonmarker/config.rb
CHANGED
|
@@ -28,6 +28,7 @@ module Commonmarker
|
|
|
28
28
|
prefer_fenced: false,
|
|
29
29
|
tasklist_classes: false,
|
|
30
30
|
compact_html: false,
|
|
31
|
+
alert_style: "specific",
|
|
31
32
|
}.freeze,
|
|
32
33
|
extension: {
|
|
33
34
|
strikethrough: true,
|
|
@@ -45,6 +46,7 @@ module Commonmarker
|
|
|
45
46
|
multiline_block_quotes: false,
|
|
46
47
|
math_dollars: false,
|
|
47
48
|
math_code: false,
|
|
49
|
+
math_latex: false,
|
|
48
50
|
shortcodes: true,
|
|
49
51
|
wikilinks_title_before_pipe: false,
|
|
50
52
|
wikilinks_title_after_pipe: false,
|
|
@@ -66,8 +68,8 @@ module Commonmarker
|
|
|
66
68
|
syntax_highlighter: {
|
|
67
69
|
theme: "base16-ocean.dark",
|
|
68
70
|
path: "",
|
|
69
|
-
},
|
|
70
|
-
}
|
|
71
|
+
}.freeze,
|
|
72
|
+
}.freeze
|
|
71
73
|
|
|
72
74
|
class << self
|
|
73
75
|
include Commonmarker::Utils
|
|
@@ -28,10 +28,8 @@ module Commonmarker
|
|
|
28
28
|
:fence_info,
|
|
29
29
|
:alert_type,
|
|
30
30
|
].filter_map do |name|
|
|
31
|
-
[name, __send__(name)]
|
|
32
|
-
|
|
33
|
-
nil
|
|
34
|
-
end.compact
|
|
31
|
+
[name, __send__(name)] if respond_to?(name)
|
|
32
|
+
end
|
|
35
33
|
|
|
36
34
|
printer.seplist(attrs) do |name, value|
|
|
37
35
|
printer.text("#{name}=")
|
data/lib/commonmarker/node.rb
CHANGED
|
@@ -8,6 +8,18 @@ module Commonmarker
|
|
|
8
8
|
include Enumerable
|
|
9
9
|
include Inspect
|
|
10
10
|
|
|
11
|
+
# Public: Whether this node responds to the given method.
|
|
12
|
+
#
|
|
13
|
+
# name - A {Symbol} or {String} naming the method.
|
|
14
|
+
# include_all - A {Boolean} indicating whether to consider private methods.
|
|
15
|
+
#
|
|
16
|
+
# Returns a {Boolean}.
|
|
17
|
+
def respond_to?(name, include_all = false)
|
|
18
|
+
return false if node_supports?(name.to_sym) == false
|
|
19
|
+
|
|
20
|
+
super
|
|
21
|
+
end
|
|
22
|
+
|
|
11
23
|
# Public: An iterator that "walks the tree," descending into children recursively.
|
|
12
24
|
#
|
|
13
25
|
# blk - A {Proc} representing the action to take for each child
|
data/lib/commonmarker/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: commonmarker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Garen Torikian
|
|
@@ -24,34 +24,6 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0.9'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '13.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '13.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rake-compiler
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '1.2'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '1.2'
|
|
55
27
|
description: A fast, safe, extensible parser for CommonMark. This wraps the comrak
|
|
56
28
|
Rust crate.
|
|
57
29
|
executables: []
|