commonmarker 1.0.0.pre7-arm64-darwin → 1.0.0.pre9-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/lib/commonmarker/3.1/commonmarker.bundle +0 -0
- data/lib/commonmarker/3.2/commonmarker.bundle +0 -0
- data/lib/commonmarker/config.rb +1 -0
- data/lib/commonmarker/version.rb +1 -1
- metadata +2 -40
- data/Cargo.lock +0 -1108
- data/ext/commonmarker/Cargo.toml +0 -12
- data/ext/commonmarker/_util.rb +0 -102
- data/ext/commonmarker/extconf.rb +0 -6
- data/ext/commonmarker/src/lib.rs +0 -85
- data/ext/commonmarker/src/options.rs +0 -134
- data/ext/commonmarker/src/plugins/syntax_highlighting.rs +0 -30
- data/ext/commonmarker/src/plugins.rs +0 -21
- data/ext/commonmarker/src/utils.rs +0 -8
data/ext/commonmarker/Cargo.toml
DELETED
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
|
-
|
data/ext/commonmarker/extconf.rb
DELETED
data/ext/commonmarker/src/lib.rs
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
extern crate core;
|
2
|
-
|
3
|
-
use comrak::{
|
4
|
-
adapters::SyntaxHighlighterAdapter, markdown_to_html, markdown_to_html_with_plugins,
|
5
|
-
plugins::syntect::SyntectAdapter, ComrakOptions, ComrakPlugins,
|
6
|
-
};
|
7
|
-
use magnus::{define_module, function, r_hash::ForEach, scan_args, Error, RHash, Symbol, Value};
|
8
|
-
|
9
|
-
mod options;
|
10
|
-
use options::iterate_options_hash;
|
11
|
-
|
12
|
-
mod plugins;
|
13
|
-
use plugins::{
|
14
|
-
syntax_highlighting::{
|
15
|
-
fetch_syntax_highlighter_theme, SYNTAX_HIGHLIGHTER_PLUGIN_DEFAULT_THEME,
|
16
|
-
},
|
17
|
-
SYNTAX_HIGHLIGHTER_PLUGIN,
|
18
|
-
};
|
19
|
-
|
20
|
-
mod utils;
|
21
|
-
|
22
|
-
pub const EMPTY_STR: &str = "";
|
23
|
-
|
24
|
-
fn commonmark_to_html<'a>(args: &[Value]) -> Result<String, magnus::Error> {
|
25
|
-
let args = scan_args::scan_args(args)?;
|
26
|
-
let (rb_commonmark,): (String,) = args.required;
|
27
|
-
let _: () = args.optional;
|
28
|
-
let _: () = args.splat;
|
29
|
-
let _: () = args.trailing;
|
30
|
-
let _: () = args.block;
|
31
|
-
|
32
|
-
let kwargs = scan_args::get_kwargs::<_, (), (Option<RHash>, Option<RHash>), ()>(
|
33
|
-
args.keywords,
|
34
|
-
&[],
|
35
|
-
&["options", "plugins"],
|
36
|
-
)?;
|
37
|
-
let (rb_options, rb_plugins) = kwargs.optional;
|
38
|
-
|
39
|
-
let mut comrak_options = ComrakOptions::default();
|
40
|
-
|
41
|
-
if let Some(rb_options) = rb_options {
|
42
|
-
rb_options.foreach(|key: Symbol, value: RHash| {
|
43
|
-
iterate_options_hash(&mut comrak_options, key, value)?;
|
44
|
-
Ok(ForEach::Continue)
|
45
|
-
})?;
|
46
|
-
}
|
47
|
-
|
48
|
-
if let Some(rb_plugins) = rb_plugins {
|
49
|
-
let mut comrak_plugins = ComrakPlugins::default();
|
50
|
-
|
51
|
-
let syntax_highlighter: Option<&dyn SyntaxHighlighterAdapter>;
|
52
|
-
let adapter: SyntectAdapter;
|
53
|
-
|
54
|
-
let theme = match rb_plugins.get(Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN)) {
|
55
|
-
Some(theme_val) => fetch_syntax_highlighter_theme(theme_val)?,
|
56
|
-
None => SYNTAX_HIGHLIGHTER_PLUGIN_DEFAULT_THEME.to_string(), // no `syntax_highlighter:` defined
|
57
|
-
};
|
58
|
-
|
59
|
-
if theme.is_empty() || theme == "none" {
|
60
|
-
syntax_highlighter = None;
|
61
|
-
} else {
|
62
|
-
adapter = SyntectAdapter::new(&theme);
|
63
|
-
syntax_highlighter = Some(&adapter);
|
64
|
-
}
|
65
|
-
|
66
|
-
comrak_plugins.render.codefence_syntax_highlighter = syntax_highlighter;
|
67
|
-
|
68
|
-
Ok(markdown_to_html_with_plugins(
|
69
|
-
&rb_commonmark,
|
70
|
-
&comrak_options,
|
71
|
-
&comrak_plugins,
|
72
|
-
))
|
73
|
-
} else {
|
74
|
-
Ok(markdown_to_html(&rb_commonmark, &comrak_options))
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
#[magnus::init]
|
79
|
-
fn init() -> Result<(), Error> {
|
80
|
-
let module = define_module("Commonmarker")?;
|
81
|
-
|
82
|
-
module.define_module_function("commonmark_to_html", function!(commonmark_to_html, -1))?;
|
83
|
-
|
84
|
-
Ok(())
|
85
|
-
}
|
@@ -1,134 +0,0 @@
|
|
1
|
-
use std::borrow::Cow;
|
2
|
-
|
3
|
-
use comrak::ComrakOptions;
|
4
|
-
|
5
|
-
use magnus::{class, r_hash::ForEach, Error, RHash, Symbol, Value};
|
6
|
-
|
7
|
-
use crate::utils::try_convert_string;
|
8
|
-
|
9
|
-
const PARSE_SMART: &str = "smart";
|
10
|
-
const PARSE_DEFAULT_INFO_STRING: &str = "default_info_string";
|
11
|
-
|
12
|
-
fn iterate_parse_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
|
13
|
-
options_hash
|
14
|
-
.foreach(|key: Symbol, value: Value| {
|
15
|
-
match key.name() {
|
16
|
-
Ok(Cow::Borrowed(PARSE_SMART)) => {
|
17
|
-
comrak_options.parse.smart = value.try_convert::<bool>()?;
|
18
|
-
}
|
19
|
-
Ok(Cow::Borrowed(PARSE_DEFAULT_INFO_STRING)) => {
|
20
|
-
comrak_options.parse.default_info_string = try_convert_string(value);
|
21
|
-
}
|
22
|
-
_ => {}
|
23
|
-
}
|
24
|
-
Ok(ForEach::Continue)
|
25
|
-
})
|
26
|
-
.unwrap();
|
27
|
-
}
|
28
|
-
|
29
|
-
const RENDER_HARDBREAKS: &str = "hardbreaks";
|
30
|
-
const RENDER_GITHUB_PRE_LANG: &str = "github_pre_lang";
|
31
|
-
const RENDER_WIDTH: &str = "width";
|
32
|
-
const RENDER_UNSAFE: &str = "unsafe";
|
33
|
-
const RENDER_ESCAPE: &str = "escape";
|
34
|
-
|
35
|
-
fn iterate_render_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
|
36
|
-
options_hash
|
37
|
-
.foreach(|key: Symbol, value: Value| {
|
38
|
-
match key.name() {
|
39
|
-
Ok(Cow::Borrowed(RENDER_HARDBREAKS)) => {
|
40
|
-
comrak_options.render.hardbreaks = value.try_convert::<bool>()?;
|
41
|
-
}
|
42
|
-
Ok(Cow::Borrowed(RENDER_GITHUB_PRE_LANG)) => {
|
43
|
-
comrak_options.render.github_pre_lang = value.try_convert::<bool>()?;
|
44
|
-
}
|
45
|
-
Ok(Cow::Borrowed(RENDER_WIDTH)) => {
|
46
|
-
comrak_options.render.width = value.try_convert::<usize>()?;
|
47
|
-
}
|
48
|
-
Ok(Cow::Borrowed(RENDER_UNSAFE)) => {
|
49
|
-
comrak_options.render.unsafe_ = value.try_convert::<bool>()?;
|
50
|
-
}
|
51
|
-
Ok(Cow::Borrowed(RENDER_ESCAPE)) => {
|
52
|
-
comrak_options.render.escape = value.try_convert::<bool>()?;
|
53
|
-
}
|
54
|
-
_ => {}
|
55
|
-
}
|
56
|
-
Ok(ForEach::Continue)
|
57
|
-
})
|
58
|
-
.unwrap();
|
59
|
-
}
|
60
|
-
|
61
|
-
const EXTENSION_STRIKETHROUGH: &str = "strikethrough";
|
62
|
-
const EXTENSION_TAGFILTER: &str = "tagfilter";
|
63
|
-
const EXTENSION_TABLE: &str = "table";
|
64
|
-
const EXTENSION_AUTOLINK: &str = "autolink";
|
65
|
-
const EXTENSION_TASKLIST: &str = "tasklist";
|
66
|
-
const EXTENSION_SUPERSCRIPT: &str = "superscript";
|
67
|
-
const EXTENSION_HEADER_IDS: &str = "header_ids";
|
68
|
-
const EXTENSION_FOOTNOTES: &str = "footnotes";
|
69
|
-
const EXTENSION_DESCRIPTION_LISTS: &str = "description_lists";
|
70
|
-
const EXTENSION_FRONT_MATTER_DELIMITER: &str = "front_matter_delimiter";
|
71
|
-
const EXTENSION_SHORTCODES: &str = "shortcodes";
|
72
|
-
|
73
|
-
fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
|
74
|
-
options_hash
|
75
|
-
.foreach(|key: Symbol, value: Value| {
|
76
|
-
match key.name() {
|
77
|
-
Ok(Cow::Borrowed(EXTENSION_STRIKETHROUGH)) => {
|
78
|
-
comrak_options.extension.strikethrough = value.try_convert::<bool>()?;
|
79
|
-
}
|
80
|
-
Ok(Cow::Borrowed(EXTENSION_TAGFILTER)) => {
|
81
|
-
comrak_options.extension.tagfilter = value.try_convert::<bool>()?;
|
82
|
-
}
|
83
|
-
Ok(Cow::Borrowed(EXTENSION_TABLE)) => {
|
84
|
-
comrak_options.extension.table = value.try_convert::<bool>()?;
|
85
|
-
}
|
86
|
-
Ok(Cow::Borrowed(EXTENSION_AUTOLINK)) => {
|
87
|
-
comrak_options.extension.autolink = value.try_convert::<bool>()?;
|
88
|
-
}
|
89
|
-
Ok(Cow::Borrowed(EXTENSION_TASKLIST)) => {
|
90
|
-
comrak_options.extension.tasklist = value.try_convert::<bool>()?;
|
91
|
-
}
|
92
|
-
Ok(Cow::Borrowed(EXTENSION_SUPERSCRIPT)) => {
|
93
|
-
comrak_options.extension.superscript = value.try_convert::<bool>()?;
|
94
|
-
}
|
95
|
-
Ok(Cow::Borrowed(EXTENSION_HEADER_IDS)) => {
|
96
|
-
comrak_options.extension.header_ids = try_convert_string(value);
|
97
|
-
}
|
98
|
-
Ok(Cow::Borrowed(EXTENSION_FOOTNOTES)) => {
|
99
|
-
comrak_options.extension.footnotes = value.try_convert::<bool>()?;
|
100
|
-
}
|
101
|
-
Ok(Cow::Borrowed(EXTENSION_DESCRIPTION_LISTS)) => {
|
102
|
-
comrak_options.extension.description_lists = value.try_convert::<bool>()?;
|
103
|
-
}
|
104
|
-
Ok(Cow::Borrowed(EXTENSION_FRONT_MATTER_DELIMITER)) => {
|
105
|
-
comrak_options.extension.front_matter_delimiter = try_convert_string(value);
|
106
|
-
}
|
107
|
-
Ok(Cow::Borrowed(EXTENSION_SHORTCODES)) => {
|
108
|
-
comrak_options.extension.shortcodes = value.try_convert::<bool>()?;
|
109
|
-
}
|
110
|
-
_ => {}
|
111
|
-
}
|
112
|
-
Ok(ForEach::Continue)
|
113
|
-
})
|
114
|
-
.unwrap();
|
115
|
-
}
|
116
|
-
|
117
|
-
pub fn iterate_options_hash(
|
118
|
-
comrak_options: &mut ComrakOptions,
|
119
|
-
key: Symbol,
|
120
|
-
value: RHash,
|
121
|
-
) -> Result<ForEach, Error> {
|
122
|
-
assert!(value.is_kind_of(class::hash()));
|
123
|
-
|
124
|
-
if key.name().unwrap() == "parse" {
|
125
|
-
iterate_parse_options(comrak_options, value);
|
126
|
-
}
|
127
|
-
if key.name().unwrap() == "render" {
|
128
|
-
iterate_render_options(comrak_options, value);
|
129
|
-
}
|
130
|
-
if key.name().unwrap() == "extension" {
|
131
|
-
iterate_extension_options(comrak_options, value);
|
132
|
-
}
|
133
|
-
Ok(ForEach::Continue)
|
134
|
-
}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
use magnus::{RHash, Symbol, Value};
|
2
|
-
|
3
|
-
use crate::EMPTY_STR;
|
4
|
-
|
5
|
-
pub const SYNTAX_HIGHLIGHTER_PLUGIN_THEME_KEY: &str = "theme";
|
6
|
-
pub const SYNTAX_HIGHLIGHTER_PLUGIN_DEFAULT_THEME: &str = "base16-ocean.dark";
|
7
|
-
|
8
|
-
pub fn fetch_syntax_highlighter_theme(value: Value) -> Result<String, magnus::Error> {
|
9
|
-
if value.is_nil() {
|
10
|
-
// `syntax_highlighter: nil`
|
11
|
-
return Ok(EMPTY_STR.to_string());
|
12
|
-
}
|
13
|
-
|
14
|
-
let syntax_highlighter_plugin = value.try_convert::<RHash>()?;
|
15
|
-
let theme_key = Symbol::new(SYNTAX_HIGHLIGHTER_PLUGIN_THEME_KEY);
|
16
|
-
|
17
|
-
match syntax_highlighter_plugin.get(theme_key) {
|
18
|
-
Some(theme) => {
|
19
|
-
if theme.is_nil() {
|
20
|
-
// `syntax_highlighter: { theme: nil }`
|
21
|
-
return Ok(EMPTY_STR.to_string());
|
22
|
-
}
|
23
|
-
Ok(theme.try_convert::<String>()?)
|
24
|
-
}
|
25
|
-
None => {
|
26
|
-
// `syntax_highlighter: { }`
|
27
|
-
Ok(EMPTY_STR.to_string())
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
@@ -1,21 +0,0 @@
|
|
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
|
-
pub mod syntax_highlighting;
|
7
|
-
|
8
|
-
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
|
-
// }
|