commonmarker 1.0.0.pre-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e76b022bbca03d322deb88f2df8a0bcf0e50c7ea099ab02643ce4c4c1e58bfa0
4
+ data.tar.gz: c4a1cce51a78f6b9130c34b32712810eef9f546f4515865286889246ad5bc59d
5
+ SHA512:
6
+ metadata.gz: f403e7bda659d61fad338bfc61ecfe8108e638e4bdb2af35af707333101d30626161cc5e7f6a2cdbf9b59cf2ad796e2a420e3643b7245d01d0e0ec9ce9d89a31
7
+ data.tar.gz: 17c2ba52ce4a86cd44f2123489b11a4460c0b72ec1bea38b65cefb118893d59a674756f048c9a743e15532e85b1bea32d7841316fcea925f5ce5cf5cbf40459d
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,146 @@
1
+ # Commonmarker
2
+
3
+ > **Note**
4
+ > This README refers to the behavior in the new 1.0.0.pre gem.
5
+
6
+ Ruby wrapper for Rust's [comrak](https://github.com/kivikakk/comrak) crate.
7
+
8
+ It passes all of the CommonMark test suite, 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.
9
+
10
+ For more information on available extensions, see [the documentation below](#extensions).
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'commonmarker'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install commonmarker
25
+
26
+ ## Usage
27
+
28
+ ### Converting to HTML
29
+
30
+ Call `render_html` on a string to convert it to HTML:
31
+
32
+ ```ruby
33
+ require 'commonmarker'
34
+ Commonmarker.to_html('"Hi *there*"', options: {
35
+ parse: { smart: true }
36
+ })
37
+ # <p>“Hi <em>there</em>”</p>\n
38
+ ```
39
+
40
+ The second argument is optional--[see below](#options) for more information.
41
+
42
+ ## Parse and Render Options
43
+
44
+ Commonmarker accepts the same options that comrak does, as a hash dictionary with symbol keys:
45
+
46
+ ```ruby
47
+ Commonmarker.to_html('"Hi *there*"', options:{
48
+ parse: { smart: true },
49
+ render: { hardbreaks: false}
50
+ })
51
+ ```
52
+
53
+ Note that there is a distinction in comrak for "parse" options and "render" options, which are represented in the tables below.
54
+
55
+ ### Parse options
56
+
57
+ | Name | Description | Default |
58
+ | --------------------- | ------------------------------------------------------------------------------------ | ------- |
59
+ | `smart` | Punctuation (quotes, full-stops and hyphens) are converted into 'smart' punctuation. | `false` |
60
+ | `default_info_string` | The default info string for fenced code blocks. | `""` |
61
+
62
+ ### Render options
63
+
64
+ | Name | Description | Default |
65
+ | ----------------- | ------------------------------------------------------------------------------------------------------ | ------- |
66
+ | `hardbreaks` | [Soft line breaks](http://spec.commonmark.org/0.27/#soft-line-breaks) translate into hard line breaks. | `true` |
67
+ | `github_pre_lang` | GitHub-style `<pre lang="xyz">` is used for fenced code blocks with info tags. | `true` |
68
+ | `width` | The wrap column when outputting CommonMark. | `80` |
69
+ | `unsafe_` | Allow rendering of raw HTML and potentially dangerous links. | `false` |
70
+ | `escape` | Escape raw HTML instead of clobbering it. | `false` |
71
+
72
+ As well, there are several extensions which you can toggle in the same manner:
73
+
74
+ ```ruby
75
+ Commonmarker.to_html('"Hi *there*"', options: {
76
+ extensions: { footnotes: true, description_lists: true },
77
+ render: { hardbreaks: false}
78
+ })
79
+ ```
80
+
81
+ ### Extension options
82
+
83
+ | Name | Description | Default |
84
+ | ------------------------ | ------------------------------------------------------------------------------------------------------------------- | ------- |
85
+ | `strikethrough` | Enables the [strikethrough extension](https://github.github.com/gfm/#strikethrough-extension-) from the GFM spec. | `true` |
86
+ | `tagfilter` | Enables the [tagfilter extension](https://github.github.com/gfm/#disallowed-raw-html-extension-) from the GFM spec. | `true` |
87
+ | `table` | Enables the [table extension](https://github.github.com/gfm/#tables-extension-) from the GFM spec. | `true` |
88
+ | `autolink` | Enables the [autolink extension](https://github.github.com/gfm/#autolinks-extension-) from the GFM spec. | `true` |
89
+ | `tasklist` | Enables the [task list extension](https://github.github.com/gfm/#task-list-items-extension-) from the GFM spec. | `true` |
90
+ | `superscript` | Enables the superscript Comrak extension. | `false` |
91
+ | `header_ids` | Enables the header IDs Comrak extension. from the GFM spec. | `""` |
92
+ | `footnotes` | Enables the footnotes extension per `cmark-gfm`. | `false` |
93
+ | `description_lists` | Enables the description lists extension.. | `false` |
94
+ | `front_matter_delimiter` | Enables the front matter extension. | `""` |
95
+
96
+ For more information on these options, see [the comrak documentation](https://github.com/kivikakk/comrak#usage).
97
+
98
+ ## Output formats
99
+
100
+ Commonmarker can currently only generate output in one format: HTML.
101
+
102
+ ### HTML
103
+
104
+ ```ruby
105
+ html = CommonMarker.to_html('*Hello* world!', :DEFAULT)
106
+ puts(html)
107
+
108
+ # <p><em>Hello</em> world!</p>
109
+ ```
110
+
111
+ ## Developing locally
112
+
113
+ After cloning the repo:
114
+
115
+ ```
116
+ script/bootstrap
117
+ bundle exec rake compile
118
+ ```
119
+
120
+ If there were no errors, you're done! Otherwise, make sure to follow the comrak dependency instructions.
121
+
122
+ ## Benchmarks
123
+
124
+ Some rough benchmarks:
125
+
126
+ ```
127
+ $ bundle exec rake benchmark
128
+
129
+ input size = 11064832 bytes
130
+
131
+ Warming up --------------------------------------
132
+ redcarpet 2.000 i/100ms
133
+ commonmarker with to_html
134
+ 1.000 i/100ms
135
+ kramdown 1.000 i/100ms
136
+ Calculating -------------------------------------
137
+ redcarpet 22.317 (± 4.5%) i/s - 112.000 in 5.036374s
138
+ commonmarker with to_html
139
+ 5.815 (± 0.0%) i/s - 30.000 in 5.168869s
140
+ kramdown 0.327 (± 0.0%) i/s - 2.000 in 6.121486s
141
+
142
+ Comparison:
143
+ redcarpet: 22.3 i/s
144
+ commonmarker with to_html: 5.8 i/s - 3.84x (± 0.00) slower
145
+ kramdown: 0.3 i/s - 68.30x (± 0.00) slower
146
+ ```
@@ -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 "commonmarker/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "commonmarker"
9
+ spec.version = Commonmarker::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.license = "MIT"
14
+ spec.homepage = "https://github.com/gjtorikian/commonmarker"
15
+
16
+ spec.required_ruby_version = "~> 3.1"
17
+ # https://github.com/rubygems/rubygems/pull/5852#issuecomment-1231118509
18
+ spec.required_rubygems_version = ">= 3.3.22"
19
+
20
+ spec.files = ["LICENSE.txt", "README.md", "commonmarker.gemspec"]
21
+ spec.files += Dir.glob("lib/**/*.rb")
22
+ spec.files += Dir.glob("ext/**/*.{rs,toml,lock,rb}")
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
+
26
+ spec.require_paths = ["lib"]
27
+ spec.extensions = ["ext/commonmarker/Cargo.toml"]
28
+
29
+ spec.metadata = {
30
+ "allowed_push_host" => "https://rubygems.org",
31
+ "funding_uri" => "https://github.com/sponsors/gjtorikian/",
32
+ "source_code_uri" => "https://github.com/gjtorikian/commonmarker",
33
+ "rubygems_mfa_required" => "true",
34
+ }
35
+
36
+ spec.add_dependency("rb_sys", "~> 0.9")
37
+
38
+ spec.add_development_dependency("rake", "~> 13.0")
39
+ spec.add_development_dependency("rake-compiler", "~> 1.2")
40
+ spec.add_development_dependency("rake-compiler-dock", "~> 1.2")
41
+ end
@@ -0,0 +1,12 @@
1
+ [package]
2
+ name = "commonmarker"
3
+ version = "1.0.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
7
+ magnus = { git = "https://github.com/gjtorikian/magnus", branch = "main" } # waiting for release with full rb-sys backend
8
+ comrak = "0.14.0"
9
+
10
+ [lib]
11
+ name = "commonmarker"
12
+ crate-type = ["cdylib"]
@@ -0,0 +1,102 @@
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
+
@@ -0,0 +1,6 @@
1
+ require "mkmf"
2
+ require "rb_sys/mkmf"
3
+
4
+ require_relative "_util"
5
+
6
+ create_rust_makefile("commonmarker")
@@ -0,0 +1,107 @@
1
+ use comrak::ComrakOptions;
2
+
3
+ use magnus::{class, r_hash::ForEach, Error, RHash, Symbol, Value};
4
+
5
+ fn iterate_parse_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
6
+ options_hash.foreach(|key: Symbol, value: Value| {
7
+ if key.name().unwrap() == "smart" {
8
+ comrak_options.parse.smart = value.try_convert::<bool>()?;
9
+ }
10
+ if key.name().unwrap() == "default_info_string" {
11
+ comrak_options.parse.default_info_string = Some(value.try_convert::<String>().unwrap());
12
+ }
13
+ Ok(ForEach::Continue)
14
+ });
15
+ }
16
+
17
+ fn iterate_render_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
18
+ options_hash.foreach(|key: Symbol, value: Value| {
19
+ if key.name().unwrap() == "hardbreaks" {
20
+ comrak_options.render.hardbreaks = value.try_convert::<bool>()?;
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
+ }
34
+
35
+ if key.name().unwrap() == "escape" {
36
+ comrak_options.render.escape = value.try_convert::<bool>()?;
37
+ }
38
+
39
+ Ok(ForEach::Continue)
40
+ });
41
+ }
42
+
43
+ fn iterate_extension_options(comrak_options: &mut ComrakOptions, options_hash: RHash) {
44
+ options_hash.foreach(|key: Symbol, value: Value| {
45
+ if key.name().unwrap() == "strikethrough" {
46
+ comrak_options.extension.strikethrough = value.try_convert::<bool>()?;
47
+ }
48
+
49
+ if key.name().unwrap() == "tagfilter" {
50
+ comrak_options.extension.tagfilter = value.try_convert::<bool>()?;
51
+ }
52
+
53
+ if key.name().unwrap() == "table" {
54
+ comrak_options.extension.table = value.try_convert::<bool>()?;
55
+ }
56
+
57
+ if key.name().unwrap() == "autolink" {
58
+ comrak_options.extension.autolink = value.try_convert::<bool>()?;
59
+ }
60
+
61
+ if key.name().unwrap() == "tasklist" {
62
+ comrak_options.extension.tasklist = value.try_convert::<bool>()?;
63
+ }
64
+
65
+ if key.name().unwrap() == "superscript" {
66
+ comrak_options.extension.superscript = value.try_convert::<bool>()?;
67
+ }
68
+
69
+ if key.name().unwrap() == "header_ids" {
70
+ comrak_options.extension.header_ids = Some(value.try_convert::<String>().unwrap());
71
+ }
72
+
73
+ if key.name().unwrap() == "footnotes" {
74
+ comrak_options.extension.footnotes = value.try_convert::<bool>()?;
75
+ }
76
+
77
+ if key.name().unwrap() == "description_lists" {
78
+ comrak_options.extension.description_lists = value.try_convert::<bool>()?;
79
+ }
80
+
81
+ if key.name().unwrap() == "front_matter_delimiter" {
82
+ comrak_options.extension.front_matter_delimiter =
83
+ Some(value.try_convert::<String>().unwrap());
84
+ }
85
+
86
+ Ok(ForEach::Continue)
87
+ });
88
+ }
89
+
90
+ pub fn iterate_options_hash(
91
+ comrak_options: &mut ComrakOptions,
92
+ key: Symbol,
93
+ value: RHash,
94
+ ) -> Result<ForEach, Error> {
95
+ assert!(value.is_kind_of(class::hash()));
96
+
97
+ if key.name().unwrap() == "parse" {
98
+ iterate_parse_options(comrak_options, value);
99
+ }
100
+ if key.name().unwrap() == "render" {
101
+ iterate_render_options(comrak_options, value);
102
+ }
103
+ if key.name().unwrap() == "extension" {
104
+ iterate_extension_options(comrak_options, value);
105
+ }
106
+ Ok(ForEach::Continue)
107
+ }
@@ -0,0 +1,27 @@
1
+ extern crate core;
2
+
3
+ use comrak::{markdown_to_html, ComrakOptions};
4
+ use magnus::{define_module, function, r_hash::ForEach, Error, RHash, Symbol};
5
+
6
+ mod comrak_options;
7
+ use comrak_options::iterate_options_hash;
8
+
9
+ fn commonmark_to_html(rb_commonmark: String, rb_options: magnus::RHash) -> String {
10
+ let mut comrak_options = ComrakOptions::default();
11
+
12
+ rb_options.foreach(|key: Symbol, value: RHash| {
13
+ iterate_options_hash(&mut comrak_options, key, value);
14
+ Ok(ForEach::Continue)
15
+ });
16
+
17
+ markdown_to_html(&rb_commonmark, &comrak_options)
18
+ }
19
+
20
+ #[magnus::init]
21
+ fn init() -> Result<(), Error> {
22
+ let module = define_module("Commonmarker")?;
23
+
24
+ module.define_module_function("commonmark_to_html", function!(commonmark_to_html, 2))?;
25
+
26
+ Ok(())
27
+ }
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Commonmarker
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
+ class << self
35
+ def merged_with_defaults(options)
36
+ Commonmarker::Config::OPTS.merge(process_options(options))
37
+ end
38
+
39
+ def process_options(options)
40
+ {
41
+ parse: process_parse_options(options[:parse]),
42
+ render: process_render_options(options[:render]),
43
+ extension: process_extension_options(options[:extension]),
44
+ }
45
+ end
46
+ end
47
+
48
+ BOOLS = [true, false]
49
+ ["parse", "render", "extension"].each do |type|
50
+ define_singleton_method :"process_#{type}_options" do |options|
51
+ Commonmarker::Config::OPTS[type.to_sym].each_with_object({}) do |(key, value), hash|
52
+ if options.nil? # option not provided, go for the default
53
+ hash[key] = value
54
+ next
55
+ end
56
+
57
+ # option explicitly not included, remove it
58
+ next if options[key].nil?
59
+
60
+ value_klass = value.class
61
+ if BOOLS.include?(value) && BOOLS.include?(options[key])
62
+ hash[key] = options[key]
63
+ elsif options[key].is_a?(value_klass)
64
+ hash[key] = options[key]
65
+ else
66
+ expected_type = BOOLS.include?(value) ? "Boolean" : value_klass.to_s
67
+ raise TypeError, "#{type}_options[:#{key}] must be a #{expected_type}; got #{options[key].class}"
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ # native precompiled gems package shared libraries in <gem_dir>/lib/commonmarker/<ruby_version>
5
+ # load the precompiled extension file
6
+ ruby_version = /\d+\.\d+/.match(::RUBY_VERSION)
7
+ require_relative "#{ruby_version}/commonmarker"
8
+ rescue LoadError
9
+ # fall back to the extension compiled upon installation.
10
+ # use "require" instead of "require_relative" because non-native gems will place C extension files
11
+ # in Gem::BasicSpecification#extension_dir after compilation (during normal installation), which
12
+ # is in $LOAD_PATH but not necessarily relative to this file (see nokogiri#2300)
13
+ require "commonmarker/commonmarker"
14
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "set"
4
+ require "stringio"
5
+
6
+ module Commonmarker
7
+ class Renderer
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Commonmarker
4
+ VERSION = "1.0.0.pre"
5
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "commonmarker/extension"
4
+
5
+ require "commonmarker/config"
6
+ require "commonmarker/renderer"
7
+ require "commonmarker/version"
8
+
9
+ if ENV.fetch("DEBUG", false)
10
+ require "awesome_print"
11
+ require "debug"
12
+ end
13
+
14
+ module Commonmarker
15
+ class << self
16
+ # Public: Parses a CommonMark string into an HTML string.
17
+ #
18
+ # text - A {String} of text
19
+ # option - A {Hash} of render, parse, and extension options to transform the text.
20
+ #
21
+ # Returns a {String} of converted HTML.
22
+ def to_html(text, options: Commonmarker::Config::OPTS)
23
+ raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
24
+ raise TypeError, "options must be a Hash; got a #{options.class}!" unless options.is_a?(Hash)
25
+
26
+ opts = Config.process_options(options)
27
+ commonmark_to_html(text.encode("UTF-8"), opts)
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commonmarker
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre
5
+ platform: x86_64-darwin
6
+ authors:
7
+ - Garen Torikian
8
+ - Ashe Connor
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2022-11-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rb_sys
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.9'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0.9'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '13.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '13.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake-compiler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.2'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.2'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake-compiler-dock
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.2'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.2'
70
+ description: A fast, safe, extensible parser for CommonMark. This wraps the comrak
71
+ Rust crate.
72
+ email:
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - LICENSE.txt
78
+ - README.md
79
+ - commonmarker.gemspec
80
+ - ext/commonmarker/Cargo.toml
81
+ - ext/commonmarker/_util.rb
82
+ - ext/commonmarker/extconf.rb
83
+ - ext/commonmarker/src/comrak_options.rs
84
+ - ext/commonmarker/src/lib.rs
85
+ - lib/commonmarker.rb
86
+ - lib/commonmarker/3.1/commonmarker.bundle
87
+ - lib/commonmarker/config.rb
88
+ - lib/commonmarker/extension.rb
89
+ - lib/commonmarker/renderer.rb
90
+ - lib/commonmarker/version.rb
91
+ homepage: https://github.com/gjtorikian/commonmarker
92
+ licenses:
93
+ - MIT
94
+ metadata:
95
+ allowed_push_host: https://rubygems.org
96
+ funding_uri: https://github.com/sponsors/gjtorikian/
97
+ source_code_uri: https://github.com/gjtorikian/commonmarker
98
+ rubygems_mfa_required: 'true'
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '3.1'
108
+ - - "<"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.2.dev
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 3.3.22
116
+ requirements: []
117
+ rubygems_version: 3.3.22
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: CommonMark parser and renderer. Written in Rust, wrapped in Ruby.
121
+ test_files: []