commonmarkercomrak 0.23.5

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1f803207ba4d7185dd0548bfe26becbd845dd817baef02db60e6e043b2f23ab6
4
+ data.tar.gz: 306fcd7ab108a5abecd91957c4526082174bf726e39057747cd50a54272c8d9b
5
+ SHA512:
6
+ metadata.gz: 1fe651892de86863ef7952eddb142502556614b178e355d6e3fec15f83cb6cae4fee344fee613dcdc9363377d6ff181b12104df6625c38e1cb314b4e90a2cf99
7
+ data.tar.gz: 5565bb76fa680f53de593b9c3a2f493a36cddf5a9305046243040a71452609ef0d29bd849b1d4abac8a3d045d7a075da4d4c6d2f93bd3fe75758acfefcebee7a
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Garen J. Torikian
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # CommonMarker
2
+
3
+ ![Build Status](https://github.com/gjtorikian/commonmarkercomrak/workflows/CI/badge.svg) [![Gem Version](https://badge.fury.io/rb/commonmarkercomrak.svg)](http://badge.fury.io/rb/commonmarkercomrak)
4
+
5
+ Ruby wrapper for [libcmark-gfm](https://github.com/github/cmark),
6
+ GitHub's fork of the reference parser for CommonMark. It passes all of the C tests, and is therefore spec-complete. It also includes extensions to the CommonMark spec as documented in the [GitHub Flavored Markdown spec](http://github.github.com/gfm/), such as support for tables, strikethroughs, and autolinking.
7
+
8
+ For more information on available extensions, see [the documentation below](#extensions).
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'commonmarkercomrak'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install commonmarkercomrak
23
+
24
+ ## Usage
25
+
26
+ ### Converting to HTML
27
+
28
+ Call `render_html` on a string to convert it to HTML:
29
+
30
+ ``` ruby
31
+ require 'commonmarkercomrak'
32
+ CommonMarker.to_html('Hi *there*', :DEFAULT)
33
+ # <p>Hi <em>there</em></p>\n
34
+ ```
35
+
36
+ The second argument is optional--[see below](#options) for more information.
37
+
38
+ ## Options
39
+
40
+ CommonMarker accepts the same options that CMark does, as symbols. Note that there is a distinction in CMark for "parse" options and "render" options, which are represented in the tables below.
41
+
42
+ ### Parse options
43
+
44
+ | Name | Description
45
+ | ----------------------------- | -----------
46
+ | `:DEFAULT` | The default parsing system.
47
+ | `:SOURCEPOS` | Include source position in nodes
48
+ | `:UNSAFE` | Allow raw/custom HTML and unsafe links.
49
+ | `:VALIDATE_UTF8` | Replace illegal sequences with the replacement character `U+FFFD`.
50
+ | `:SMART` | Use smart punctuation (curly quotes, etc.).
51
+ | `:LIBERAL_HTML_TAG` | Support liberal parsing of inline HTML tags.
52
+ | `:FOOTNOTES` | Parse footnotes.
53
+ | `:STRIKETHROUGH_DOUBLE_TILDE` | Parse strikethroughs by double tildes (compatibility with [redcarpet](https://github.com/vmg/redcarpet))
54
+
55
+ ### Render options
56
+
57
+ | Name | Description |
58
+ | ------------------ | ----------- |
59
+ | `:DEFAULT` | The default rendering system. |
60
+ | `:SOURCEPOS` | Include source position in rendered HTML. |
61
+ | `:HARDBREAKS` | Treat `\n` as hardbreaks (by adding `<br/>`). |
62
+ | `:UNSAFE` | Allow raw/custom HTML and unsafe links. |
63
+ | `:NOBREAKS` | Translate `\n` in the source to a single whitespace. |
64
+ | `:VALIDATE_UTF8` | Replace illegal sequences with the replacement character `U+FFFD`. |
65
+ | `:SMART` | Use smart punctuation (curly quotes, etc.). |
66
+ | `:GITHUB_PRE_LANG` | Use GitHub-style `<pre lang>` for fenced code blocks. |
67
+ | `:LIBERAL_HTML_TAG` | Support liberal parsing of inline HTML tags. |
68
+ | `:FOOTNOTES` | Render footnotes. |
69
+ | `:STRIKETHROUGH_DOUBLE_TILDE` | Parse strikethroughs by double tildes (compatibility with [redcarpet](https://github.com/vmg/redcarpet)) |
70
+ | `:TABLE_PREFER_STYLE_ATTRIBUTES` | Use `style` insted of `align` for table cells. |
71
+ | `:FULL_INFO_STRING` | Include full info strings of code blocks in separate attribute. |
72
+
73
+ ### Passing options
74
+
75
+ To apply an option, pass it as part of the hash:
76
+
77
+ ``` ruby
78
+ CommonMarker.to_html("\"Hello,\" said the spider.", :SMART)
79
+ # <p>“Hello,” said the spider.</p>\n
80
+
81
+ CommonMarker.to_html("\"'Shelob' is my name.\"", [:HARDBREAKS, :SOURCEPOS])
82
+ ```
83
+
84
+ For more information on these options, see [the comrak documentation](https://github.com/kivikakk/comrak#usage).
85
+
86
+ ## Output formats
87
+
88
+ CommonmarkerComrak can only generate output in one format: HTML.
89
+
90
+ ### HTML
91
+
92
+ ```ruby
93
+ html = CommonMarker.to_html('*Hello* world!', :DEFAULT)
94
+ puts(html)
95
+
96
+ # <p><em>Hello</em> world!</p>
97
+ ```
98
+
99
+ ## Developing locally
100
+
101
+ After cloning the repo:
102
+
103
+ ```
104
+ script/bootstrap
105
+ bundle exec rake compile
106
+ ```
107
+
108
+ If there were no errors, you're done! Otherwise, make sure to follow the comrak dependency instructions.
109
+
110
+ ## Benchmarks
111
+
112
+ Some rough benchmarks:
113
+
114
+ ```
115
+ $ bundle exec rake benchmark
116
+
117
+ input size = 11064832 bytes
118
+
119
+ Warming up --------------------------------------
120
+ redcarpet 2.000 i/100ms
121
+ commonmarkercomrak with to_html
122
+ 1.000 i/100ms
123
+ kramdown 1.000 i/100ms
124
+ Calculating -------------------------------------
125
+ redcarpet 22.634 (± 4.4%) i/s - 114.000 in 5.054490s
126
+ commonmarkercomrak with to_html
127
+ 7.340 (± 0.0%) i/s - 37.000 in 5.058352s
128
+ kramdown 0.343 (± 0.0%) i/s - 2.000 in 5.834208s
129
+
130
+ Comparison:
131
+ redcarpet: 22.6 i/s
132
+ commonmarkercomrak with to_html: 7.3 i/s - 3.08x (± 0.00) slower
133
+ kramdown: 0.3 i/s - 66.02x (± 0.00) slower
134
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Gem Spec
4
+ require "bundler"
5
+ COMMONMARKERCOMRAK_SPEC = Bundler.load_gemspec("commonmarkercomrak.gemspec")
6
+
7
+ # Packaging
8
+ require "bundler/gem_tasks"
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "commonmarkercomrak/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "commonmarkercomrak"
9
+ spec.version = CommonmarkerComrak::VERSION
10
+ spec.summary = "CommonMark parser and renderer. Written in Rust, wrapped in Ruby."
11
+ spec.description = "A fast, safe, extensible parser for CommonMark. This wraps the comrak Rust crate."
12
+ spec.authors = ["Garen Torikian", "Ashe Connor"]
13
+ spec.homepage = "https://github.com/gjtorikian/commonmarkercomrak"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = ["LICENSE.txt", "README.md", "Rakefile", "commonmarkercomrak.gemspec"]
17
+ spec.files += Dir.glob("lib/**/*.rb")
18
+ spec.files += Dir.glob("ext/commonmarkercomrak/*.*")
19
+ spec.extensions = ["ext/commonmarkercomrak/extconf.rb"]
20
+
21
+ spec.require_paths = ["lib", "ext"]
22
+ spec.required_ruby_version = [">= 3.0", "< 4.0"]
23
+
24
+ spec.metadata = {
25
+ "funding_uri" => "https://github.com/sponsors/gjtorikian/",
26
+ "rubygems_mfa_required" => "true",
27
+ }
28
+
29
+ spec.add_development_dependency("awesome_print")
30
+ spec.add_development_dependency("debug") if "#{RbConfig::CONFIG["MAJOR"]}.#{RbConfig::CONFIG["MINOR"]}".to_f >= 3.1
31
+ spec.add_development_dependency("json", "~> 2.3")
32
+ spec.add_development_dependency("minitest", "~> 5.6")
33
+ spec.add_development_dependency("minitest-focus", "~> 1.1")
34
+ spec.add_development_dependency("nokogiri", "~> 1.13")
35
+ spec.add_development_dependency("rake")
36
+ spec.add_development_dependency("rake-compiler", "~> 0.9")
37
+ spec.add_development_dependency("rdoc", "~> 6.2")
38
+ spec.add_development_dependency("rubocop-standard")
39
+
40
+ spec.add_runtime_dependency("mini_portile2", "~> 2.8") # keep version in sync with extconf.rb
41
+ end
@@ -0,0 +1,149 @@
1
+ #include "ruby.h"
2
+
3
+ #include "commonmarkercomrak.h"
4
+
5
+ #include "comrak_ffi.h"
6
+
7
+ int iterate_extension_options(VALUE key, VALUE val, VALUE arg) {
8
+ comrak_options_t *config = (comrak_options_t *)arg;
9
+
10
+ if (key == ID2SYM(rb_intern("strikethrough"))) {
11
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
12
+ comrak_set_extension_option_strikethrough(config, val);
13
+ }
14
+ } else if (key == ID2SYM(rb_intern("tagfilter"))) {
15
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
16
+ comrak_set_extension_option_tagfilter(config, val);
17
+ }
18
+ } else if (key == ID2SYM(rb_intern("table"))) {
19
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
20
+ comrak_set_extension_option_table(config, val);
21
+ }
22
+ } else if (key == ID2SYM(rb_intern("autolink"))) {
23
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
24
+ comrak_set_extension_option_autolink(config, val);
25
+ }
26
+ } else if (key == ID2SYM(rb_intern("tasklist"))) {
27
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
28
+ comrak_set_extension_option_tasklist(config, val);
29
+ }
30
+ } else if (key == ID2SYM(rb_intern("superscript"))) {
31
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
32
+ comrak_set_extension_option_superscript(config, val);
33
+ }
34
+ } else if (key == ID2SYM(rb_intern("header_ids"))) {
35
+ Check_Type(val, T_STRING);
36
+ comrak_set_extension_option_header_ids(config, StringValuePtr(val),
37
+ RSTRING_LEN(val));
38
+ } else if (key == ID2SYM(rb_intern("footnotes"))) {
39
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
40
+ comrak_set_extension_option_footnotes(config, val);
41
+ }
42
+ } else if (key == ID2SYM(rb_intern("description_lists"))) {
43
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
44
+ comrak_set_extension_option_description_lists(config, val);
45
+ }
46
+ } else if (key == ID2SYM(rb_intern("front_matter_delimiter"))) {
47
+ Check_Type(val, T_STRING);
48
+ comrak_set_extension_option_front_matter_delimiter(
49
+ config, StringValuePtr(val), RSTRING_LEN(val));
50
+ }
51
+
52
+ return ST_CONTINUE;
53
+ }
54
+
55
+ int iterate_render_options(VALUE key, VALUE val, VALUE arg) {
56
+ comrak_options_t *config = (comrak_options_t *)arg;
57
+
58
+ if (key == ID2SYM(rb_intern("hardbreaks"))) {
59
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
60
+ comrak_set_render_option_hardbreaks(config, val);
61
+ }
62
+ } else if (key == ID2SYM(rb_intern("github_pre_lang"))) {
63
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
64
+ comrak_set_render_option_github_pre_lang(config, val);
65
+ }
66
+ } else if (key == ID2SYM(rb_intern("width"))) {
67
+ Check_Type(val, T_FIXNUM);
68
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
69
+ comrak_set_render_option_github_pre_lang(config, val);
70
+ }
71
+ } else if (key == ID2SYM(rb_intern("unsafe_"))) {
72
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
73
+ comrak_set_render_option_unsafe_(config, val);
74
+ }
75
+ } else if (key == ID2SYM(rb_intern("escape"))) {
76
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
77
+ comrak_set_render_option_escape(config, val);
78
+ }
79
+ }
80
+
81
+ return ST_CONTINUE;
82
+ }
83
+
84
+ int iterate_parse_options(VALUE key, VALUE val, VALUE arg) {
85
+ comrak_options_t *config = (comrak_options_t *)arg;
86
+
87
+ if (key == ID2SYM(rb_intern("smart"))) {
88
+ if (TYPE(val) == T_TRUE || TYPE(val) == T_FALSE) {
89
+ comrak_set_parse_option_smart(config, val);
90
+ }
91
+ } else if (key == ID2SYM(rb_intern("default_info_string"))) {
92
+ Check_Type(val, T_STRING);
93
+
94
+ comrak_set_parse_option_default_info_string(config, StringValuePtr(val),
95
+ RSTRING_LEN(val));
96
+ }
97
+
98
+ return ST_CONTINUE;
99
+ }
100
+
101
+ int iterate_options_hash(VALUE rb_option_key, VALUE rb_option_val, VALUE arg) {
102
+ comrak_options_t *config = (comrak_options_t *)arg;
103
+
104
+ Check_Type(rb_option_key, T_SYMBOL);
105
+
106
+ // which options are we dealing with?
107
+ if (rb_option_key == ID2SYM(rb_intern("parse"))) {
108
+ Check_Type(rb_option_val, T_HASH);
109
+ rb_hash_foreach(rb_option_val, iterate_parse_options, (VALUE)config);
110
+ } else if (rb_option_key == ID2SYM(rb_intern("render"))) {
111
+ Check_Type(rb_option_val, T_HASH);
112
+ rb_hash_foreach(rb_option_val, iterate_render_options, (VALUE)config);
113
+ } else if (rb_option_key == ID2SYM(rb_intern("extension"))) {
114
+ Check_Type(rb_option_val, T_HASH);
115
+ if (rb_hash_aref(rb_option_val, ID2SYM(rb_intern("header_ids"))) == Qnil) {
116
+ comrak_set_extension_option_header_ids(config, NULL, 0);
117
+ }
118
+ rb_hash_foreach(rb_option_val, iterate_extension_options, (VALUE)config);
119
+ }
120
+
121
+ return ST_CONTINUE;
122
+ }
123
+
124
+ VALUE commonmark_to_html(VALUE self, VALUE rb_commonmark, VALUE rb_options) {
125
+ Check_Type(rb_commonmark, T_STRING);
126
+ Check_Type(rb_options, T_HASH);
127
+
128
+ char *commonmark = StringValueCStr(rb_commonmark);
129
+
130
+ comrak_options_t *options = comrak_options_new();
131
+ rb_hash_foreach(rb_options, iterate_options_hash, (VALUE)options);
132
+
133
+ comrak_str_t html = comrak_commonmark_to_html(commonmark, options);
134
+
135
+ VALUE rb_html = rb_utf8_str_new(html.data, html.len);
136
+
137
+ comrak_options_free(options);
138
+ comrak_str_free(html);
139
+
140
+ return rb_html;
141
+ }
142
+
143
+ __attribute__((visibility("default"))) void Init_commonmarkercomrak() {
144
+ VALUE module;
145
+
146
+ module = rb_define_module("CommonmarkerComrak");
147
+ rb_define_singleton_method(module, "commonmark_to_html", commonmark_to_html,
148
+ 2);
149
+ }
@@ -0,0 +1,18 @@
1
+ #ifndef COMMONMARKER_H
2
+ #define COMMONMARKER_H
3
+
4
+ #ifndef __MSXML_LIBRARY_DEFINED__
5
+ #define __MSXML_LIBRARY_DEFINED__
6
+ #endif
7
+
8
+ #include "ruby.h"
9
+ #include "ruby/encoding.h"
10
+
11
+ #include "comrak_ffi.h"
12
+
13
+ #define CSTR2SYM(s) (ID2SYM(rb_intern((s))))
14
+
15
+ void Init_commonmarker();
16
+ VALUE commonmark_to_html(VALUE self, VALUE rb_commonmark, VALUE rb_options);
17
+
18
+ #endif
@@ -0,0 +1,73 @@
1
+ require "mkmf"
2
+ require "mini_portile2"
3
+
4
+ windows = RUBY_PLATFORM =~ /mingw|mswin/
5
+ windows_ucrt = RUBY_PLATFORM =~ /(mingw|mswin).*ucrt/
6
+ bsd = RUBY_PLATFORM =~ /bsd/
7
+ darwin = RUBY_PLATFORM =~ /darwin/
8
+ linux = RUBY_PLATFORM =~ /linux/
9
+ cross_compiling = ENV['RCD_HOST_RUBY_VERSION'] # set by rake-compiler-dock in build containers
10
+ # TruffleRuby uses the Sulong LLVM runtime, which is different from Apple's.
11
+ apple_toolchain = darwin && RUBY_ENGINE != 'truffleruby'
12
+
13
+ GEM_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
14
+ EXT_DIR = File.join(GEM_ROOT_DIR, "ext", "commonmarkercomrak")
15
+ CROSS_BUILD_P = enable_config("cross-build")
16
+
17
+ RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
18
+ ENV["CC"] = RbConfig::CONFIG["CC"]
19
+
20
+ # what follows is pretty much an abuse of miniportile2, but it works for now
21
+ # i just need something to download files and run a cargo build; one day this should
22
+ # be replaced with actual prepacked binaries.
23
+ USER = "kivikakk"
24
+ # COMRAK_VERSION = "0.14.0"
25
+ COMRAK_VERSION = "main"
26
+ # TARBALL_URL = "https://github.com/#{USER}/comrak/archive/refs/tags/#{COMRAK_VERSION}.tar.gz"
27
+ TARBALL_URL = "https://github.com/#{USER}/comrak/archive/refs/heads/#{COMRAK_VERSION}.tar.gz"
28
+
29
+ MiniPortile.new("comrak", COMRAK_VERSION).tap do |recipe|
30
+ recipe.target = File.join(GEM_ROOT_DIR, "ports")
31
+ recipe.files = [{
32
+ url: TARBALL_URL,
33
+ # sha256: "055fa44ef002a1a07853d3a4dd2a8c553a1dc58ff3809b4fa530ed35694d8571",
34
+ }]
35
+
36
+ # configure the environment that MiniPortile will use for subshells
37
+ if CROSS_BUILD_P
38
+ ENV.to_h.tap do |env|
39
+ # -fPIC is necessary for linking into a shared library
40
+ env["CFLAGS"] = [env["CFLAGS"], "-fPIC"].join(" ")
41
+
42
+ recipe.configure_options += env.map { |key, value| "#{key}=#{value.strip}" }
43
+ end
44
+ end
45
+
46
+ unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
47
+ recipe.download unless recipe.downloaded?
48
+ recipe.extract
49
+
50
+ tarball_extract_path = File.join("tmp", recipe.host, "ports", recipe.name, recipe.version, "#{recipe.name}-#{recipe.version}")
51
+ Dir.chdir(tarball_extract_path) do
52
+ system "cargo build --manifest-path=./c-api/Cargo.toml --release"
53
+ end
54
+ lib_header_path = File.join(tarball_extract_path, "c-api", "include")
55
+ lib_build_path = File.join(tarball_extract_path, "c-api", "target", "release")
56
+
57
+ HEADER_DIRS = [lib_header_path]
58
+ LIB_DIRS = [lib_build_path]
59
+
60
+ dir_config('commonmarkercomrak', HEADER_DIRS, LIB_DIRS)
61
+ end
62
+
63
+ recipe.activate
64
+
65
+ $LIBS << ' -lcomrak_ffi'
66
+ $LIBS << ' -lbcrypt' if windows
67
+ end
68
+
69
+ unless find_header("comrak_ffi.h")
70
+ abort("\nERROR: *** could not find comrak_ffi.h ***\n\n")
71
+ end
72
+
73
+ create_makefile("commonmarkercomrak/commonmarkercomrak")
@@ -0,0 +1,68 @@
1
+ DYLD_FALLBACK_LIBRARY_PATH=.:/Users/gjtorikian/.rbenv/versions/3.1.1/lib pkg-config --exists /Users/gjtorikian/Development/commonmarker/ports/arm64-apple-darwin21.5.0/comrak/0.13.2/lib/pkgconfig/yaml-0.1.pc
2
+ package configuration for /Users/gjtorikian/Development/commonmarker/ports/arm64-apple-darwin21.5.0/comrak/0.13.2/lib/pkgconfig/yaml-0.1.pc is not found
3
+ have_library: checking for yaml_get_version() in -lyaml... -------------------- no
4
+
5
+ DYLD_FALLBACK_LIBRARY_PATH=.:/Users/gjtorikian/.rbenv/versions/3.1.1/lib "clang -o conftest -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0/arm64-darwin21 -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0/ruby/backward -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0 -I. -I/Users/gjtorikian/.rbenv/versions/3.1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -fno-common -pipe conftest.c -L. -L/Users/gjtorikian/.rbenv/versions/3.1.1/lib -L. -L/Users/gjtorikian/.rbenv/versions/3.1.1/lib -fstack-protector-strong -L/usr/local/lib -lruby.3.1 "
6
+ checked program was:
7
+ /* begin */
8
+ 1: #include "ruby.h"
9
+ 2:
10
+ 3: int main(int argc, char **argv)
11
+ 4: {
12
+ 5: return !!argv[argc];
13
+ 6: }
14
+ /* end */
15
+
16
+ DYLD_FALLBACK_LIBRARY_PATH=.:/Users/gjtorikian/.rbenv/versions/3.1.1/lib "clang -o conftest -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0/arm64-darwin21 -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0/ruby/backward -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0 -I. -I/Users/gjtorikian/.rbenv/versions/3.1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -fno-common -pipe conftest.c -L. -L/Users/gjtorikian/.rbenv/versions/3.1.1/lib -L. -L/Users/gjtorikian/.rbenv/versions/3.1.1/lib -fstack-protector-strong -L/usr/local/lib -lruby.3.1 -lyaml "
17
+ conftest.c:3:10: fatal error: 'comrak.h' file not found
18
+ #include <comrak.h>
19
+ ^~~~~~~~~~
20
+ 1 error generated.
21
+ checked program was:
22
+ /* begin */
23
+ 1: #include "ruby.h"
24
+ 2:
25
+ 3: #include <comrak.h>
26
+ 4:
27
+ 5: /*top*/
28
+ 6: extern int t(void);
29
+ 7: int main(int argc, char **argv)
30
+ 8: {
31
+ 9: if (argc > 1000000) {
32
+ 10: int (* volatile tp)(void)=(int (*)(void))&t;
33
+ 11: printf("%d", (*tp)());
34
+ 12: }
35
+ 13:
36
+ 14: return !!argv[argc];
37
+ 15: }
38
+ 16: int t(void) { void ((*volatile p)()); p = (void ((*)()))yaml_get_version; return !p; }
39
+ /* end */
40
+
41
+ DYLD_FALLBACK_LIBRARY_PATH=.:/Users/gjtorikian/.rbenv/versions/3.1.1/lib "clang -o conftest -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0/arm64-darwin21 -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0/ruby/backward -I/Users/gjtorikian/.rbenv/versions/3.1.1/include/ruby-3.1.0 -I. -I/Users/gjtorikian/.rbenv/versions/3.1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -fno-common -pipe conftest.c -L. -L/Users/gjtorikian/.rbenv/versions/3.1.1/lib -L. -L/Users/gjtorikian/.rbenv/versions/3.1.1/lib -fstack-protector-strong -L/usr/local/lib -lruby.3.1 -lyaml "
42
+ conftest.c:3:10: fatal error: 'comrak.h' file not found
43
+ #include <comrak.h>
44
+ ^~~~~~~~~~
45
+ 1 error generated.
46
+ checked program was:
47
+ /* begin */
48
+ 1: #include "ruby.h"
49
+ 2:
50
+ 3: #include <comrak.h>
51
+ 4:
52
+ 5: /*top*/
53
+ 6: extern int t(void);
54
+ 7: int main(int argc, char **argv)
55
+ 8: {
56
+ 9: if (argc > 1000000) {
57
+ 10: int (* volatile tp)(void)=(int (*)(void))&t;
58
+ 11: printf("%d", (*tp)());
59
+ 12: }
60
+ 13:
61
+ 14: return !!argv[argc];
62
+ 15: }
63
+ 16: extern void yaml_get_version();
64
+ 17: int t(void) { yaml_get_version(); return 0; }
65
+ /* end */
66
+
67
+ --------------------
68
+
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CommonmarkerComrak
4
+ module Config
5
+ # For details, see
6
+ # https://github.com/kivikakk/comrak/blob/162ef9354deb2c9b4a4e05be495aa372ba5bb696/src/main.rs#L201
7
+ OPTS = {
8
+ parse: {
9
+ smart: false,
10
+ default_info_string: "",
11
+ }.freeze,
12
+ render: {
13
+ hardbreaks: true,
14
+ github_pre_lang: true,
15
+ width: 80,
16
+ unsafe_: false,
17
+ escape: false,
18
+ }.freeze,
19
+ extension: {
20
+ strikethrough: true,
21
+ tagfilter: true,
22
+ table: true,
23
+ autolink: true,
24
+ tasklist: true,
25
+ superscript: false,
26
+ header_ids: "",
27
+ footnotes: false,
28
+ description_lists: false,
29
+ front_matter_delimiter: "",
30
+ },
31
+ format: [:html].freeze,
32
+ }.freeze
33
+
34
+ def self.merged_with_defaults(options)
35
+ CommonmarkerComrak::Config::OPTS.merge(process_options(options))
36
+ end
37
+
38
+ def self.process_options(options)
39
+ {
40
+ parse: process_parse_options(options[:parse]),
41
+ render: process_render_options(options[:render]),
42
+ extension: process_extension_options(options[:extension]),
43
+ }
44
+ end
45
+
46
+ BOOLS = [true, false]
47
+ ["parse", "render", "extension"].each do |type|
48
+ define_singleton_method :"process_#{type}_options" do |options|
49
+ CommonmarkerComrak::Config::OPTS[type.to_sym].each_with_object({}) do |(key, value), hash|
50
+ if options.nil? # option not provided, go for the default
51
+ hash[key] = value
52
+ next
53
+ end
54
+
55
+ # option explicitly not included, remove it
56
+ next if options[key].nil?
57
+
58
+ value_klass = value.class
59
+ if BOOLS.include?(value) && BOOLS.include?(options[key])
60
+ hash[key] = options[key]
61
+ elsif options[key].is_a?(value_klass)
62
+ hash[key] = options[key]
63
+ else
64
+ expected_type = BOOLS.include?(value) ? "Boolean" : value_klass.to_s
65
+ raise TypeError, "#{type}_options[:#{key}] must be a #{expected_type}; got #{options[key].class}"
66
+ end
67
+ end
68
+ end
69
+ # private :"process_#{type}_options"
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "set"
4
+ require "stringio"
5
+
6
+ module CommonmarkerComrak
7
+ class Renderer
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CommonmarkerComrak
4
+ VERSION = "0.23.5"
5
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ # load the precompiled extension file
5
+ ruby_version = /(\d+\.\d+)/.match(::RUBY_VERSION)
6
+ require_relative "commonmarkercomrak/#{ruby_version}/commonmarkercomrak"
7
+ rescue LoadError
8
+ # fall back to the extension compiled upon installation.
9
+ require "commonmarkercomrak/commonmarkercomrak"
10
+ end
11
+
12
+ require "commonmarkercomrak/config"
13
+ require "commonmarkercomrak/renderer"
14
+ require "commonmarkercomrak/version"
15
+
16
+ if ENV.fetch("DEBUG", false)
17
+ require "awesome_print"
18
+ require "debug"
19
+ end
20
+
21
+ module CommonmarkerComrak
22
+ # Public: Parses a CommonMark string into an HTML string.
23
+ #
24
+ # text - A {String} of text
25
+ # option - A {Hash} of render, parse, and extension options to transform the text.
26
+ #
27
+ # Returns a {String} of converted HTML.
28
+ def self.to_html(text, options: CommonmarkerComrak::Config::OPTS)
29
+ raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
30
+ raise TypeError, "options must be a Hash; got a #{options.class}!" unless options.is_a?(Hash)
31
+
32
+ opts = Config.process_options(options)
33
+ commonmark_to_html(text.encode("UTF-8"), opts)
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commonmarkercomrak
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.23.5
5
+ platform: ruby
6
+ authors:
7
+ - Garen Torikian
8
+ - Ashe Connor
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2022-09-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: awesome_print
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: debug
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: json
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.3'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '5.6'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '5.6'
70
+ - !ruby/object:Gem::Dependency
71
+ name: minitest-focus
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.1'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: nokogiri
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1.13'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.13'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rake
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rake-compiler
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '0.9'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '0.9'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rdoc
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '6.2'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '6.2'
140
+ - !ruby/object:Gem::Dependency
141
+ name: rubocop-standard
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: mini_portile2
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '2.8'
161
+ type: :runtime
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '2.8'
168
+ description: A fast, safe, extensible parser for CommonMark. This wraps the comrak
169
+ Rust crate.
170
+ email:
171
+ executables: []
172
+ extensions:
173
+ - ext/commonmarkercomrak/extconf.rb
174
+ extra_rdoc_files: []
175
+ files:
176
+ - LICENSE.txt
177
+ - README.md
178
+ - Rakefile
179
+ - commonmarkercomrak.gemspec
180
+ - ext/commonmarkercomrak/commonmarkercomrak.c
181
+ - ext/commonmarkercomrak/commonmarkercomrak.h
182
+ - ext/commonmarkercomrak/extconf.rb
183
+ - ext/commonmarkercomrak/mkmf.log
184
+ - lib/commonmarkercomrak.rb
185
+ - lib/commonmarkercomrak/config.rb
186
+ - lib/commonmarkercomrak/renderer.rb
187
+ - lib/commonmarkercomrak/version.rb
188
+ homepage: https://github.com/gjtorikian/commonmarkercomrak
189
+ licenses:
190
+ - MIT
191
+ metadata:
192
+ funding_uri: https://github.com/sponsors/gjtorikian/
193
+ rubygems_mfa_required: 'true'
194
+ post_install_message:
195
+ rdoc_options: []
196
+ require_paths:
197
+ - lib
198
+ - ext
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '3.0'
204
+ - - "<"
205
+ - !ruby/object:Gem::Version
206
+ version: '4.0'
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ requirements: []
213
+ rubygems_version: 3.3.7
214
+ signing_key:
215
+ specification_version: 4
216
+ summary: CommonMark parser and renderer. Written in Rust, wrapped in Ruby.
217
+ test_files: []