commonmarker 1.0.0.pre → 1.0.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/commonmarker/Cargo.toml +2 -2
- 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: da5f808bdc6b8da3d906a59415bf48e54a87f2422bac68c93cc3c4ccaafb7768
|
4
|
+
data.tar.gz: f4f09bc3ec9805601fae7343fec173e720a2a10d49d1f96203c940d827a7aa3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14ac414938023c18c37d487b230bdeeb9cd866393fca75846af13b8f2e8f1558980470eec679db127f38b8512bd20c730537d49803d81fce4917b08f7bfaeabf
|
7
|
+
data.tar.gz: 520453ba4666fb5b68346560b9f0fe2de8e299b6ed5998c741109f848a7a94eb9731e6509b9421bdd4c5f820a5dfb373f217d49d1cc5047ba539574482ef03c7
|
data/ext/commonmarker/Cargo.toml
CHANGED
@@ -4,8 +4,8 @@ version = "1.0.0"
|
|
4
4
|
edition = "2021"
|
5
5
|
|
6
6
|
[dependencies]
|
7
|
-
magnus =
|
8
|
-
comrak = "0.14
|
7
|
+
magnus = "0.4"
|
8
|
+
comrak = "0.14"
|
9
9
|
|
10
10
|
[lib]
|
11
11
|
name = "commonmarker"
|
@@ -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.
|
4
|
+
version: 1.0.0.pre3
|
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-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb_sys
|