commonmarker 1.0.0.pre → 1.0.0.pre.2
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/ext/commonmarker/Cargo.toml +1 -1
- data/ext/commonmarker/src/comrak_options.rs +105 -76
- data/ext/commonmarker/src/lib.rs +6 -4
- data/lib/commonmarker/config.rb +1 -1
- data/lib/commonmarker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50518c47228bb2c8fa7316a72874bd80441a7461e6763e7c267138a958b8f5bd
|
4
|
+
data.tar.gz: 20df9a9139bef07fbd0748c5b0ceeee9217c61ba521dca4aca9e7e71a5ba9ed7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c64b798bbfb45a53c70e2a07f7a5bd279ff49ebb7518d62d404af71c3d46a1a6f929f33f03b0bf4819bb28a5d7df83962626ca5cef431e07ba4a8d8dea08ef0
|
7
|
+
data.tar.gz: 5d5dbae1cb19fcafbdf9f83ae263ea60bcb0ad59adc2802b52c80af676b755900f875a6cf217f81e9124e519ae45d7b07f4e07e7dcba2cfdd5d64c3957fac846
|
data/ext/commonmarker/Cargo.toml
CHANGED
@@ -1,90 +1,111 @@
|
|
1
|
+
use std::borrow::Cow;
|
2
|
+
|
1
3
|
use comrak::ComrakOptions;
|
2
4
|
|
3
5
|
use magnus::{class, r_hash::ForEach, Error, RHash, Symbol, Value};
|
4
6
|
|
7
|
+
const PARSE_SMART: &str = "smart";
|
8
|
+
const PARSE_DEFAULT_INFO_STRING: &str = "default_info_string";
|
9
|
+
|
5
10
|
fn iterate_parse_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
|
6
|
-
options_hash
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
options_hash
|
12
|
+
.foreach(|key: Symbol, value: Value| {
|
13
|
+
match key.name() {
|
14
|
+
Ok(Cow::Borrowed(PARSE_SMART)) => {
|
15
|
+
comrak_options.parse.smart = value.try_convert::<bool>()?;
|
16
|
+
}
|
17
|
+
Ok(Cow::Borrowed(PARSE_DEFAULT_INFO_STRING)) => {
|
18
|
+
comrak_options.parse.default_info_string = try_convert_string(value);
|
19
|
+
}
|
20
|
+
_ => {}
|
21
|
+
}
|
22
|
+
Ok(ForEach::Continue)
|
23
|
+
})
|
24
|
+
.unwrap();
|
15
25
|
}
|
16
26
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if key.name().unwrap() == "github_pre_lang" {
|
24
|
-
comrak_options.render.github_pre_lang = value.try_convert::<bool>()?;
|
25
|
-
}
|
26
|
-
|
27
|
-
if key.name().unwrap() == "width" {
|
28
|
-
comrak_options.render.width = value.try_convert::<usize>()?;
|
29
|
-
}
|
30
|
-
|
31
|
-
if key.name().unwrap() == "unsafe_" {
|
32
|
-
comrak_options.render.unsafe_ = value.try_convert::<bool>()?;
|
33
|
-
}
|
27
|
+
const RENDER_HARDBREAKS: &str = "hardbreaks";
|
28
|
+
const RENDER_GITHUB_PRE_LANG: &str = "github_pre_lang";
|
29
|
+
const RENDER_WIDTH: &str = "width";
|
30
|
+
const RENDER_UNSAFE: &str = "unsafe_";
|
31
|
+
const RENDER_ESCAPE: &str = "escape";
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
fn iterate_render_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
|
34
|
+
options_hash
|
35
|
+
.foreach(|key: Symbol, value: Value| {
|
36
|
+
match key.name() {
|
37
|
+
Ok(Cow::Borrowed(RENDER_HARDBREAKS)) => {
|
38
|
+
comrak_options.render.hardbreaks = value.try_convert::<bool>()?;
|
39
|
+
}
|
40
|
+
Ok(Cow::Borrowed(RENDER_GITHUB_PRE_LANG)) => {
|
41
|
+
comrak_options.render.github_pre_lang = value.try_convert::<bool>()?;
|
42
|
+
}
|
43
|
+
Ok(Cow::Borrowed(RENDER_WIDTH)) => {
|
44
|
+
comrak_options.render.width = value.try_convert::<usize>()?;
|
45
|
+
}
|
46
|
+
Ok(Cow::Borrowed(RENDER_UNSAFE)) => {
|
47
|
+
comrak_options.render.unsafe_ = value.try_convert::<bool>()?;
|
48
|
+
}
|
49
|
+
Ok(Cow::Borrowed(RENDER_ESCAPE)) => {
|
50
|
+
comrak_options.render.escape = value.try_convert::<bool>()?;
|
51
|
+
}
|
52
|
+
_ => {}
|
53
|
+
}
|
54
|
+
Ok(ForEach::Continue)
|
55
|
+
})
|
56
|
+
.unwrap();
|
41
57
|
}
|
42
58
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
if key.name().unwrap() == "table" {
|
54
|
-
comrak_options.extension.table = value.try_convert::<bool>()?;
|
55
|
-
}
|
59
|
+
const EXTENSION_STRIKETHROUGH: &str = "strikethrough";
|
60
|
+
const EXTENSION_TAGFILTER: &str = "tagfilter";
|
61
|
+
const EXTENSION_TABLE: &str = "table";
|
62
|
+
const EXTENSION_AUTOLINK: &str = "autolink";
|
63
|
+
const EXTENSION_TASKLIST: &str = "tasklist";
|
64
|
+
const EXTENSION_SUPERSCRIPT: &str = "superscript";
|
65
|
+
const EXTENSION_HEADER_IDS: &str = "header_ids";
|
66
|
+
const EXTENSION_FOOTNOTES: &str = "footnotes";
|
67
|
+
const EXTENSION_DESCRIPTION_LISTS: &str = "description_lists";
|
68
|
+
const EXTENSION_FRONT_MATTER_DELIMITER: &str = "front_matter_delimiter";
|
56
69
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
70
|
+
fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
|
71
|
+
options_hash
|
72
|
+
.foreach(|key: Symbol, value: Value| {
|
73
|
+
match key.name() {
|
74
|
+
Ok(Cow::Borrowed(EXTENSION_STRIKETHROUGH)) => {
|
75
|
+
comrak_options.extension.strikethrough = value.try_convert::<bool>()?;
|
76
|
+
}
|
77
|
+
Ok(Cow::Borrowed(EXTENSION_TAGFILTER)) => {
|
78
|
+
comrak_options.extension.tagfilter = value.try_convert::<bool>()?;
|
79
|
+
}
|
80
|
+
Ok(Cow::Borrowed(EXTENSION_TABLE)) => {
|
81
|
+
comrak_options.extension.table = value.try_convert::<bool>()?;
|
82
|
+
}
|
83
|
+
Ok(Cow::Borrowed(EXTENSION_AUTOLINK)) => {
|
84
|
+
comrak_options.extension.autolink = value.try_convert::<bool>()?;
|
85
|
+
}
|
86
|
+
Ok(Cow::Borrowed(EXTENSION_TASKLIST)) => {
|
87
|
+
comrak_options.extension.tasklist = value.try_convert::<bool>()?;
|
88
|
+
}
|
89
|
+
Ok(Cow::Borrowed(EXTENSION_SUPERSCRIPT)) => {
|
90
|
+
comrak_options.extension.superscript = value.try_convert::<bool>()?;
|
91
|
+
}
|
92
|
+
Ok(Cow::Borrowed(EXTENSION_HEADER_IDS)) => {
|
93
|
+
comrak_options.extension.header_ids = try_convert_string(value);
|
94
|
+
}
|
95
|
+
Ok(Cow::Borrowed(EXTENSION_FOOTNOTES)) => {
|
96
|
+
comrak_options.extension.footnotes = value.try_convert::<bool>()?;
|
97
|
+
}
|
98
|
+
Ok(Cow::Borrowed(EXTENSION_DESCRIPTION_LISTS)) => {
|
99
|
+
comrak_options.extension.description_lists = value.try_convert::<bool>()?;
|
100
|
+
}
|
101
|
+
Ok(Cow::Borrowed(EXTENSION_FRONT_MATTER_DELIMITER)) => {
|
102
|
+
comrak_options.extension.front_matter_delimiter = try_convert_string(value);
|
103
|
+
}
|
104
|
+
_ => {}
|
105
|
+
}
|
106
|
+
Ok(ForEach::Continue)
|
107
|
+
})
|
108
|
+
.unwrap();
|
88
109
|
}
|
89
110
|
|
90
111
|
pub fn iterate_options_hash(
|
@@ -105,3 +126,11 @@ pub fn iterate_options_hash(
|
|
105
126
|
}
|
106
127
|
Ok(ForEach::Continue)
|
107
128
|
}
|
129
|
+
|
130
|
+
fn try_convert_string(value: Value) -> Option<String> {
|
131
|
+
if value.is_kind_of(class::string()) {
|
132
|
+
Some(value.try_convert::<String>().unwrap())
|
133
|
+
} else {
|
134
|
+
None
|
135
|
+
}
|
136
|
+
}
|
data/ext/commonmarker/src/lib.rs
CHANGED
@@ -9,10 +9,12 @@ use comrak_options::iterate_options_hash;
|
|
9
9
|
fn commonmark_to_html(rb_commonmark: String, rb_options: magnus::RHash) -> String {
|
10
10
|
let mut comrak_options = ComrakOptions::default();
|
11
11
|
|
12
|
-
rb_options
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
rb_options
|
13
|
+
.foreach(|key: Symbol, value: RHash| {
|
14
|
+
iterate_options_hash(&mut comrak_options, key, value).unwrap();
|
15
|
+
Ok(ForEach::Continue)
|
16
|
+
})
|
17
|
+
.unwrap();
|
16
18
|
|
17
19
|
markdown_to_html(&rb_commonmark, &comrak_options)
|
18
20
|
}
|
data/lib/commonmarker/config.rb
CHANGED
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: 1.0.0.pre
|
4
|
+
version: 1.0.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-11-
|
12
|
+
date: 2022-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb_sys
|