commonmarker 1.0.0.pre7 → 1.0.0.pre11
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 +326 -385
- data/Cargo.toml +6 -0
- data/README.md +8 -1
- data/ext/commonmarker/Cargo.toml +3 -2
- data/ext/commonmarker/extconf.rb +0 -2
- data/ext/commonmarker/src/lib.rs +78 -12
- data/ext/commonmarker/src/options.rs +22 -16
- data/ext/commonmarker/src/plugins/syntax_highlighting.rs +31 -2
- data/ext/commonmarker/src/plugins.rs +0 -18
- data/ext/commonmarker/src/utils.rs +2 -2
- data/lib/commonmarker/config.rb +3 -2
- data/lib/commonmarker/version.rb +1 -1
- data/lib/commonmarker.rb +0 -5
- metadata +8 -22
- data/ext/commonmarker/_util.rb +0 -102
data/Cargo.toml
ADDED
data/README.md
CHANGED
@@ -131,9 +131,16 @@ Commonmarker.to_html(code, plugins: { syntax_highlighter: nil })
|
|
131
131
|
Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: nil } })
|
132
132
|
```
|
133
133
|
|
134
|
+
You can also provide a `path` to a directory containing `.tmtheme` files to load:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
|
138
|
+
Commonmarker.to_html(code, plugins: { syntax_highlighter: { theme: "Monokai", path: "./themes" } })
|
139
|
+
```
|
140
|
+
|
134
141
|
##### Available themes
|
135
142
|
|
136
|
-
Here's [a list of available
|
143
|
+
Here's [a list of themes available by default](https://docs.rs/syntect/5.0.0/syntect/highlighting/struct.ThemeSet.html#implementations):
|
137
144
|
|
138
145
|
- `"base16-ocean.dark"`
|
139
146
|
- `"base16-eighties.dark"`
|
data/ext/commonmarker/Cargo.toml
CHANGED
@@ -4,8 +4,9 @@ version = "1.0.0"
|
|
4
4
|
edition = "2021"
|
5
5
|
|
6
6
|
[dependencies]
|
7
|
-
magnus = "0.
|
8
|
-
comrak = { version = "0.
|
7
|
+
magnus = "0.6"
|
8
|
+
comrak = { version = "0.19", features = ["shortcodes"] }
|
9
|
+
syntect = { version = "5.1", features = ["plist-load"] }
|
9
10
|
|
10
11
|
[lib]
|
11
12
|
name = "commonmarker"
|
data/ext/commonmarker/extconf.rb
CHANGED
data/ext/commonmarker/src/lib.rs
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
extern crate core;
|
2
2
|
|
3
|
+
use std::path::PathBuf;
|
4
|
+
|
5
|
+
use ::syntect::highlighting::ThemeSet;
|
3
6
|
use comrak::{
|
4
|
-
adapters::SyntaxHighlighterAdapter,
|
5
|
-
|
7
|
+
adapters::SyntaxHighlighterAdapter,
|
8
|
+
markdown_to_html, markdown_to_html_with_plugins,
|
9
|
+
plugins::syntect::{SyntectAdapter, SyntectAdapterBuilder},
|
10
|
+
ComrakOptions, ComrakPlugins,
|
11
|
+
};
|
12
|
+
use magnus::{
|
13
|
+
define_module, exception, function, r_hash::ForEach, scan_args, Error, RHash, Symbol, Value,
|
6
14
|
};
|
7
|
-
use magnus::{define_module, function, r_hash::ForEach, scan_args, Error, RHash, Symbol, Value};
|
8
15
|
|
9
16
|
mod options;
|
10
17
|
use options::iterate_options_hash;
|
@@ -12,7 +19,8 @@ use options::iterate_options_hash;
|
|
12
19
|
mod plugins;
|
13
20
|
use plugins::{
|
14
21
|
syntax_highlighting::{
|
15
|
-
|
22
|
+
fetch_syntax_highlighter_path, fetch_syntax_highlighter_theme,
|
23
|
+
SYNTAX_HIGHLIGHTER_PLUGIN_DEFAULT_THEME,
|
16
24
|
},
|
17
25
|
SYNTAX_HIGHLIGHTER_PLUGIN,
|
18
26
|
};
|
@@ -21,13 +29,9 @@ mod utils;
|
|
21
29
|
|
22
30
|
pub const EMPTY_STR: &str = "";
|
23
31
|
|
24
|
-
fn commonmark_to_html
|
25
|
-
let args = scan_args::scan_args(args)?;
|
32
|
+
fn commonmark_to_html(args: &[Value]) -> Result<String, magnus::Error> {
|
33
|
+
let args = scan_args::scan_args::<_, (), (), (), _, ()>(args)?;
|
26
34
|
let (rb_commonmark,): (String,) = args.required;
|
27
|
-
let _: () = args.optional;
|
28
|
-
let _: () = args.splat;
|
29
|
-
let _: () = args.trailing;
|
30
|
-
let _: () = args.block;
|
31
35
|
|
32
36
|
let kwargs = scan_args::get_kwargs::<_, (), (Option<RHash>, Option<RHash>), ()>(
|
33
37
|
args.keywords,
|
@@ -52,13 +56,75 @@ fn commonmark_to_html<'a>(args: &[Value]) -> Result<String, magnus::Error> {
|
|
52
56
|
let adapter: SyntectAdapter;
|
53
57
|
|
54
58
|
let theme = match rb_plugins.get(Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN)) {
|
55
|
-
Some(
|
59
|
+
Some(syntax_highlighter_options) => {
|
60
|
+
fetch_syntax_highlighter_theme(syntax_highlighter_options)?
|
61
|
+
}
|
56
62
|
None => SYNTAX_HIGHLIGHTER_PLUGIN_DEFAULT_THEME.to_string(), // no `syntax_highlighter:` defined
|
57
63
|
};
|
58
64
|
|
59
|
-
|
65
|
+
let path = match rb_plugins.get(Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN)) {
|
66
|
+
Some(syntax_highlighter_options) => {
|
67
|
+
fetch_syntax_highlighter_path(syntax_highlighter_options)?
|
68
|
+
}
|
69
|
+
None => PathBuf::from("".to_string()), // no `syntax_highlighter:` defined
|
70
|
+
};
|
71
|
+
|
72
|
+
if !path.eq(&PathBuf::from("".to_string())) && !path.exists() {
|
73
|
+
return Err(Error::new(
|
74
|
+
exception::arg_error(),
|
75
|
+
"path does not exist".to_string(),
|
76
|
+
));
|
77
|
+
}
|
78
|
+
|
79
|
+
if theme.is_empty() && path.exists() {
|
80
|
+
return Err(Error::new(
|
81
|
+
exception::arg_error(),
|
82
|
+
"`path` also needs `theme` passed into the `syntax_highlighter`",
|
83
|
+
));
|
84
|
+
}
|
85
|
+
if path.exists() && !path.is_dir() {
|
86
|
+
return Err(Error::new(
|
87
|
+
exception::arg_error(),
|
88
|
+
"`path` needs to be a directory",
|
89
|
+
));
|
90
|
+
}
|
91
|
+
|
92
|
+
if path.exists() {
|
93
|
+
let builder = SyntectAdapterBuilder::new();
|
94
|
+
let mut ts = ThemeSet::load_defaults();
|
95
|
+
|
96
|
+
match ts.add_from_folder(&path) {
|
97
|
+
Ok(_) => {}
|
98
|
+
Err(e) => {
|
99
|
+
return Err(Error::new(
|
100
|
+
exception::arg_error(),
|
101
|
+
format!("failed to load theme set from path: {e}"),
|
102
|
+
));
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
ts.themes.get(&theme).ok_or_else(|| {
|
107
|
+
Error::new(
|
108
|
+
exception::arg_error(),
|
109
|
+
format!("theme `{}` does not exist", theme),
|
110
|
+
)
|
111
|
+
})?;
|
112
|
+
|
113
|
+
adapter = builder.theme_set(ts).theme(&theme).build();
|
114
|
+
|
115
|
+
syntax_highlighter = Some(&adapter);
|
116
|
+
} else if theme.is_empty() || theme == "none" {
|
60
117
|
syntax_highlighter = None;
|
61
118
|
} else {
|
119
|
+
ThemeSet::load_defaults()
|
120
|
+
.themes
|
121
|
+
.get(&theme)
|
122
|
+
.ok_or_else(|| {
|
123
|
+
Error::new(
|
124
|
+
exception::arg_error(),
|
125
|
+
format!("theme `{}` does not exist", theme),
|
126
|
+
)
|
127
|
+
})?;
|
62
128
|
adapter = SyntectAdapter::new(&theme);
|
63
129
|
syntax_highlighter = Some(&adapter);
|
64
130
|
}
|
@@ -2,6 +2,8 @@ use std::borrow::Cow;
|
|
2
2
|
|
3
3
|
use comrak::ComrakOptions;
|
4
4
|
|
5
|
+
use magnus::value::ReprValue;
|
6
|
+
use magnus::TryConvert;
|
5
7
|
use magnus::{class, r_hash::ForEach, Error, RHash, Symbol, Value};
|
6
8
|
|
7
9
|
use crate::utils::try_convert_string;
|
@@ -14,7 +16,7 @@ fn iterate_parse_options(comrak_options: &mut ComrakOptions, options_hash: RHash
|
|
14
16
|
.foreach(|key: Symbol, value: Value| {
|
15
17
|
match key.name() {
|
16
18
|
Ok(Cow::Borrowed(PARSE_SMART)) => {
|
17
|
-
comrak_options.parse.smart =
|
19
|
+
comrak_options.parse.smart = TryConvert::try_convert(value)?;
|
18
20
|
}
|
19
21
|
Ok(Cow::Borrowed(PARSE_DEFAULT_INFO_STRING)) => {
|
20
22
|
comrak_options.parse.default_info_string = try_convert_string(value);
|
@@ -37,19 +39,19 @@ fn iterate_render_options(comrak_options: &mut ComrakOptions, options_hash: RHas
|
|
37
39
|
.foreach(|key: Symbol, value: Value| {
|
38
40
|
match key.name() {
|
39
41
|
Ok(Cow::Borrowed(RENDER_HARDBREAKS)) => {
|
40
|
-
comrak_options.render.hardbreaks =
|
42
|
+
comrak_options.render.hardbreaks = TryConvert::try_convert(value)?;
|
41
43
|
}
|
42
44
|
Ok(Cow::Borrowed(RENDER_GITHUB_PRE_LANG)) => {
|
43
|
-
comrak_options.render.github_pre_lang =
|
45
|
+
comrak_options.render.github_pre_lang = TryConvert::try_convert(value)?;
|
44
46
|
}
|
45
47
|
Ok(Cow::Borrowed(RENDER_WIDTH)) => {
|
46
|
-
comrak_options.render.width =
|
48
|
+
comrak_options.render.width = TryConvert::try_convert(value)?;
|
47
49
|
}
|
48
50
|
Ok(Cow::Borrowed(RENDER_UNSAFE)) => {
|
49
|
-
comrak_options.render.unsafe_ =
|
51
|
+
comrak_options.render.unsafe_ = TryConvert::try_convert(value)?;
|
50
52
|
}
|
51
53
|
Ok(Cow::Borrowed(RENDER_ESCAPE)) => {
|
52
|
-
comrak_options.render.escape =
|
54
|
+
comrak_options.render.escape = TryConvert::try_convert(value)?;
|
53
55
|
}
|
54
56
|
_ => {}
|
55
57
|
}
|
@@ -75,37 +77,41 @@ fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: R
|
|
75
77
|
.foreach(|key: Symbol, value: Value| {
|
76
78
|
match key.name() {
|
77
79
|
Ok(Cow::Borrowed(EXTENSION_STRIKETHROUGH)) => {
|
78
|
-
comrak_options.extension.strikethrough =
|
80
|
+
comrak_options.extension.strikethrough = TryConvert::try_convert(value)?;
|
79
81
|
}
|
80
82
|
Ok(Cow::Borrowed(EXTENSION_TAGFILTER)) => {
|
81
|
-
comrak_options.extension.tagfilter =
|
83
|
+
comrak_options.extension.tagfilter = TryConvert::try_convert(value)?;
|
82
84
|
}
|
83
85
|
Ok(Cow::Borrowed(EXTENSION_TABLE)) => {
|
84
|
-
comrak_options.extension.table =
|
86
|
+
comrak_options.extension.table = TryConvert::try_convert(value)?;
|
85
87
|
}
|
86
88
|
Ok(Cow::Borrowed(EXTENSION_AUTOLINK)) => {
|
87
|
-
comrak_options.extension.autolink =
|
89
|
+
comrak_options.extension.autolink = TryConvert::try_convert(value)?;
|
88
90
|
}
|
89
91
|
Ok(Cow::Borrowed(EXTENSION_TASKLIST)) => {
|
90
|
-
comrak_options.extension.tasklist =
|
92
|
+
comrak_options.extension.tasklist = TryConvert::try_convert(value)?;
|
91
93
|
}
|
92
94
|
Ok(Cow::Borrowed(EXTENSION_SUPERSCRIPT)) => {
|
93
|
-
comrak_options.extension.superscript =
|
95
|
+
comrak_options.extension.superscript = TryConvert::try_convert(value)?;
|
94
96
|
}
|
95
97
|
Ok(Cow::Borrowed(EXTENSION_HEADER_IDS)) => {
|
96
98
|
comrak_options.extension.header_ids = try_convert_string(value);
|
97
99
|
}
|
98
100
|
Ok(Cow::Borrowed(EXTENSION_FOOTNOTES)) => {
|
99
|
-
comrak_options.extension.footnotes =
|
101
|
+
comrak_options.extension.footnotes = TryConvert::try_convert(value)?;
|
100
102
|
}
|
101
103
|
Ok(Cow::Borrowed(EXTENSION_DESCRIPTION_LISTS)) => {
|
102
|
-
comrak_options.extension.description_lists =
|
104
|
+
comrak_options.extension.description_lists = TryConvert::try_convert(value)?;
|
103
105
|
}
|
104
106
|
Ok(Cow::Borrowed(EXTENSION_FRONT_MATTER_DELIMITER)) => {
|
105
|
-
|
107
|
+
if let Some(option) = try_convert_string(value) {
|
108
|
+
if !option.is_empty() {
|
109
|
+
comrak_options.extension.front_matter_delimiter = Some(option);
|
110
|
+
}
|
111
|
+
}
|
106
112
|
}
|
107
113
|
Ok(Cow::Borrowed(EXTENSION_SHORTCODES)) => {
|
108
|
-
comrak_options.extension.shortcodes =
|
114
|
+
comrak_options.extension.shortcodes = TryConvert::try_convert(value)?;
|
109
115
|
}
|
110
116
|
_ => {}
|
111
117
|
}
|
@@ -1,8 +1,12 @@
|
|
1
|
-
use
|
1
|
+
use std::path::PathBuf;
|
2
|
+
|
3
|
+
use magnus::value::ReprValue;
|
4
|
+
use magnus::{RHash, Symbol, TryConvert, Value};
|
2
5
|
|
3
6
|
use crate::EMPTY_STR;
|
4
7
|
|
5
8
|
pub const SYNTAX_HIGHLIGHTER_PLUGIN_THEME_KEY: &str = "theme";
|
9
|
+
pub const SYNTAX_HIGHLIGHTER_PLUGIN_PATH_KEY: &str = "path";
|
6
10
|
pub const SYNTAX_HIGHLIGHTER_PLUGIN_DEFAULT_THEME: &str = "base16-ocean.dark";
|
7
11
|
|
8
12
|
pub fn fetch_syntax_highlighter_theme(value: Value) -> Result<String, magnus::Error> {
|
@@ -11,7 +15,7 @@ pub fn fetch_syntax_highlighter_theme(value: Value) -> Result<String, magnus::Er
|
|
11
15
|
return Ok(EMPTY_STR.to_string());
|
12
16
|
}
|
13
17
|
|
14
|
-
let syntax_highlighter_plugin =
|
18
|
+
let syntax_highlighter_plugin: RHash = TryConvert::try_convert(value)?;
|
15
19
|
let theme_key = Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN_THEME_KEY);
|
16
20
|
|
17
21
|
match syntax_highlighter_plugin.get(theme_key) {
|
@@ -28,3 +32,28 @@ pub fn fetch_syntax_highlighter_theme(value: Value) -> Result<String, magnus::Er
|
|
28
32
|
}
|
29
33
|
}
|
30
34
|
}
|
35
|
+
|
36
|
+
pub fn fetch_syntax_highlighter_path(value: Value) -> Result<PathBuf, magnus::Error> {
|
37
|
+
if value.is_nil() {
|
38
|
+
// `syntax_highlighter: nil`
|
39
|
+
return Ok(PathBuf::from(EMPTY_STR));
|
40
|
+
}
|
41
|
+
|
42
|
+
let syntax_highlighter_plugin: RHash = TryConvert::try_convert(value)?;
|
43
|
+
let path_key = Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN_PATH_KEY);
|
44
|
+
|
45
|
+
match syntax_highlighter_plugin.get(path_key) {
|
46
|
+
Some(path) => {
|
47
|
+
if path.is_nil() {
|
48
|
+
// `syntax_highlighter: { path: nil }`
|
49
|
+
return Ok(PathBuf::from(EMPTY_STR));
|
50
|
+
}
|
51
|
+
let val: String = TryConvert::try_convert(path)?;
|
52
|
+
Ok(PathBuf::from(val))
|
53
|
+
}
|
54
|
+
None => {
|
55
|
+
// `syntax_highlighter: { }`
|
56
|
+
Ok(PathBuf::from(EMPTY_STR))
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
@@ -1,21 +1,3 @@
|
|
1
|
-
// use comrak::ComrakPlugins;
|
2
|
-
// use magnus::{class, r_hash::ForEach, RHash, Symbol, Value};
|
3
|
-
|
4
|
-
// use crate::plugins::syntax_highlighting::fetch_syntax_highlighter_theme;
|
5
|
-
|
6
1
|
pub mod syntax_highlighting;
|
7
2
|
|
8
3
|
pub const SYNTAX_HIGHLIGHTER_PLUGIN: &str = "syntax_highlighter";
|
9
|
-
|
10
|
-
// pub fn iterate_plugins_hash(
|
11
|
-
// comrak_plugins: &mut ComrakPlugins,
|
12
|
-
// mut theme: String,
|
13
|
-
// key: Symbol,
|
14
|
-
// value: Value,
|
15
|
-
// ) -> Result<ForEach, magnus::Error> {
|
16
|
-
// if key.name().unwrap() == SYNTAX_HIGHLIGHTER_PLUGIN {
|
17
|
-
// theme = fetch_syntax_highlighter_theme(value)?;
|
18
|
-
// }
|
19
|
-
|
20
|
-
// Ok(ForEach::Continue)
|
21
|
-
// }
|
data/lib/commonmarker/config.rb
CHANGED
@@ -26,7 +26,7 @@ module Commonmarker
|
|
26
26
|
header_ids: "",
|
27
27
|
footnotes: false,
|
28
28
|
description_lists: false,
|
29
|
-
front_matter_delimiter:
|
29
|
+
front_matter_delimiter: "",
|
30
30
|
shortcodes: true,
|
31
31
|
},
|
32
32
|
format: [:html].freeze,
|
@@ -35,6 +35,7 @@ module Commonmarker
|
|
35
35
|
PLUGINS = {
|
36
36
|
syntax_highlighter: {
|
37
37
|
theme: "base16-ocean.dark",
|
38
|
+
path: "",
|
38
39
|
},
|
39
40
|
}
|
40
41
|
|
@@ -78,7 +79,7 @@ module Commonmarker
|
|
78
79
|
|
79
80
|
[:syntax_highlighter].each do |type|
|
80
81
|
define_singleton_method :"process_#{type}_plugin" do |plugin|
|
81
|
-
return
|
82
|
+
return if plugin.nil? # plugin explicitly nil, remove it
|
82
83
|
|
83
84
|
Commonmarker::Config::PLUGINS[type].each_with_object({}) do |(key, value), hash|
|
84
85
|
if plugin.nil? # option not provided, go for the default
|
data/lib/commonmarker/version.rb
CHANGED
data/lib/commonmarker.rb
CHANGED
@@ -7,11 +7,6 @@ require "commonmarker/config"
|
|
7
7
|
require "commonmarker/renderer"
|
8
8
|
require "commonmarker/version"
|
9
9
|
|
10
|
-
if ENV.fetch("DEBUG", false)
|
11
|
-
require "awesome_print"
|
12
|
-
require "debug"
|
13
|
-
end
|
14
|
-
|
15
10
|
module Commonmarker
|
16
11
|
class << self
|
17
12
|
# Public: Parses a CommonMark string into an HTML string.
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.pre11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
- Ashe Connor
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb_sys
|
@@ -54,33 +54,19 @@ dependencies:
|
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '1.2'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: rake-compiler-dock
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - "~>"
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '1.2'
|
64
|
-
type: :development
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - "~>"
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '1.2'
|
71
57
|
description: A fast, safe, extensible parser for CommonMark. This wraps the comrak
|
72
58
|
Rust crate.
|
73
|
-
email:
|
59
|
+
email:
|
74
60
|
executables: []
|
75
61
|
extensions:
|
76
62
|
- ext/commonmarker/extconf.rb
|
77
63
|
extra_rdoc_files: []
|
78
64
|
files:
|
79
65
|
- Cargo.lock
|
66
|
+
- Cargo.toml
|
80
67
|
- LICENSE.txt
|
81
68
|
- README.md
|
82
69
|
- ext/commonmarker/Cargo.toml
|
83
|
-
- ext/commonmarker/_util.rb
|
84
70
|
- ext/commonmarker/extconf.rb
|
85
71
|
- ext/commonmarker/src/lib.rs
|
86
72
|
- ext/commonmarker/src/options.rs
|
@@ -102,7 +88,7 @@ metadata:
|
|
102
88
|
funding_uri: https://github.com/sponsors/gjtorikian/
|
103
89
|
source_code_uri: https://github.com/gjtorikian/commonmarker
|
104
90
|
rubygems_mfa_required: 'true'
|
105
|
-
post_install_message:
|
91
|
+
post_install_message:
|
106
92
|
rdoc_options: []
|
107
93
|
require_paths:
|
108
94
|
- lib
|
@@ -117,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
103
|
- !ruby/object:Gem::Version
|
118
104
|
version: 3.3.22
|
119
105
|
requirements: []
|
120
|
-
rubygems_version: 3.4.
|
121
|
-
signing_key:
|
106
|
+
rubygems_version: 3.4.21
|
107
|
+
signing_key:
|
122
108
|
specification_version: 4
|
123
109
|
summary: CommonMark parser and renderer. Written in Rust, wrapped in Ruby.
|
124
110
|
test_files: []
|
data/ext/commonmarker/_util.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RUBY_MAJOR, RUBY_MINOR = RUBY_VERSION.split(".").collect(&:to_i)
|
4
|
-
|
5
|
-
PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
6
|
-
PACKAGE_EXT_DIR = File.join(PACKAGE_ROOT_DIR, "ext", "commonmarker")
|
7
|
-
|
8
|
-
OS = case os = RbConfig::CONFIG["host_os"].downcase
|
9
|
-
when /linux/
|
10
|
-
# The official ruby-alpine Docker containers pre-build Ruby. As a result,
|
11
|
-
# Ruby doesn't know that it's on a musl-based platform. `ldd` is the
|
12
|
-
# a more reliable way to detect musl.
|
13
|
-
# See https://github.com/skylightio/skylight-ruby/issues/92
|
14
|
-
if ENV["SKYLIGHT_MUSL"] || %x(ldd --version 2>&1).include?("musl")
|
15
|
-
"linux-musl"
|
16
|
-
else
|
17
|
-
"linux"
|
18
|
-
end
|
19
|
-
when /darwin/
|
20
|
-
"darwin"
|
21
|
-
when /freebsd/
|
22
|
-
"freebsd"
|
23
|
-
when /netbsd/
|
24
|
-
"netbsd"
|
25
|
-
when /openbsd/
|
26
|
-
"openbsd"
|
27
|
-
when /sunos|solaris/
|
28
|
-
"solaris"
|
29
|
-
when /mingw|mswin/
|
30
|
-
"windows"
|
31
|
-
else
|
32
|
-
os
|
33
|
-
end
|
34
|
-
|
35
|
-
# Normalize the platform CPU
|
36
|
-
ARCH = case cpu = RbConfig::CONFIG["host_cpu"].downcase
|
37
|
-
when /amd64|x86_64|x64/
|
38
|
-
"x86_64"
|
39
|
-
when /i?86|x86|i86pc/
|
40
|
-
"x86"
|
41
|
-
when /ppc|powerpc/
|
42
|
-
"powerpc"
|
43
|
-
when /^aarch/
|
44
|
-
"aarch"
|
45
|
-
when /^arm/
|
46
|
-
"arm"
|
47
|
-
else
|
48
|
-
cpu
|
49
|
-
end
|
50
|
-
|
51
|
-
def windows?
|
52
|
-
OS == "windows"
|
53
|
-
end
|
54
|
-
|
55
|
-
def solaris?
|
56
|
-
OS == solaries
|
57
|
-
end
|
58
|
-
|
59
|
-
def darwin?
|
60
|
-
OS == "darwin"
|
61
|
-
end
|
62
|
-
|
63
|
-
def macos?
|
64
|
-
darwin? || OS == "macos"
|
65
|
-
end
|
66
|
-
|
67
|
-
def openbsd?
|
68
|
-
OS == "openbsd"
|
69
|
-
end
|
70
|
-
|
71
|
-
def aix?
|
72
|
-
OS == "aix"
|
73
|
-
end
|
74
|
-
|
75
|
-
def nix?
|
76
|
-
!(windows? || solaris? || darwin?)
|
77
|
-
end
|
78
|
-
|
79
|
-
def x86_64?
|
80
|
-
ARCH == "x86_64"
|
81
|
-
end
|
82
|
-
|
83
|
-
def x86?
|
84
|
-
ARCH == "x86"
|
85
|
-
end
|
86
|
-
|
87
|
-
def abs_path(path)
|
88
|
-
File.join(PACKAGE_EXT_DIR, path)
|
89
|
-
end
|
90
|
-
|
91
|
-
def find_header_or_abort(header, *paths)
|
92
|
-
find_header(header, *paths) || abort("#{header} was expected in `#{paths.join(", ")}`, but it is missing.")
|
93
|
-
end
|
94
|
-
|
95
|
-
def find_library_or_abort(lib, func, *paths)
|
96
|
-
find_library(lib, func, *paths) || abort("#{lib} was expected in `#{paths.join(", ")}`, but it is missing.")
|
97
|
-
end
|
98
|
-
|
99
|
-
def concat_flags(*args)
|
100
|
-
args.compact.join(" ")
|
101
|
-
end
|
102
|
-
|