commonmarker 0.20.1 → 0.20.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of commonmarker might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/README.md +1 -0
- data/bin/commonmarker +82 -44
- data/lib/commonmarker/version.rb +1 -1
- data/test/fixtures/strong.md +1 -0
- data/test/fixtures/table.md +10 -0
- data/test/test_attributes.rb +1 -1
- data/test/test_commands.rb +31 -0
- data/test/test_encoding.rb +1 -1
- data/test/test_extensions.rb +1 -12
- data/test/test_helper.rb +8 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0061cea8cfbad9898ad1fe7d9e9fd28b8add70a5e5bbe122b5e6ea86549f4f49
|
4
|
+
data.tar.gz: 1606082fb10db7dff360e5e96ec31ad71e98f2c4450ce94635350fc3695c4ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c3d9226cd6819f39fcdfb0e13dd7cd5610fc6a1531758ac578af447af798f8130c9c4f886f7f055a03a35b4dde4e903ca5a2ea35ad4466cb9606300f505ad5f
|
7
|
+
data.tar.gz: 5b4700f6d4024f0ea2a93a06afc46f90a65c694bc8f86f1148e1ac5a5f6ffdb50705c557035336183d8f14b27352a5d4e6037b160b34baf93c74aa5db1bc7144
|
data/README.md
CHANGED
@@ -176,6 +176,7 @@ Both `render_html` and `render_doc` take an optional third argument defining the
|
|
176
176
|
The available extensions are:
|
177
177
|
|
178
178
|
* `:table` - This provides support for tables.
|
179
|
+
* `:tasklist` - This provides support for task list items.
|
179
180
|
* `:strikethrough` - This provides support for strikethroughs.
|
180
181
|
* `:autolink` - This provides support for automatically converting URLs to anchor tags.
|
181
182
|
* `:tagfilter` - This escapes [several "unsafe" HTML tags](https://github.github.com/gfm/#disallowed-raw-html-extension-), causing them to not have any effect.
|
data/bin/commonmarker
CHANGED
@@ -1,60 +1,98 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
# If no FILE argument is provided, text will be read from STDIN.
|
7
|
-
# With --html-renderer, use the HtmlRenderer renderer rather than the native C
|
8
|
-
# renderer.
|
9
|
-
# With --extension=EXTENSION, EXTENSION will be used for parsing, and HTML
|
10
|
-
# output unless --html-renderer is specified.
|
11
|
-
if ARGV.include?('--help') or ARGV.include?('-h')
|
12
|
-
File.read(__FILE__).split("\n").grep(/^# /).each do |line|
|
13
|
-
puts line[2..-1]
|
14
|
-
end
|
15
|
-
exit 0
|
16
|
-
end
|
4
|
+
require 'optparse'
|
5
|
+
require 'ostruct'
|
17
6
|
|
18
7
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
19
8
|
require 'commonmarker'
|
20
9
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
10
|
+
root = File.expand_path('..', __dir__)
|
11
|
+
$LOAD_PATH.unshift File.expand_path('lib', root)
|
12
|
+
|
13
|
+
def parse_options
|
14
|
+
options = OpenStruct.new
|
15
|
+
extensions = CommonMarker.extensions
|
16
|
+
parse_options = CommonMarker::Config::Parse
|
17
|
+
render_options = CommonMarker::Config::Render
|
18
|
+
|
19
|
+
options.active_extensions = []
|
20
|
+
options.active_parse_options = [:DEFAULT]
|
21
|
+
options.active_render_options = [:DEFAULT]
|
22
|
+
|
23
|
+
option_parser = OptionParser.new do |opts|
|
24
|
+
opts.banner = 'Usage: commonmarker [--html-renderer] [--extension=EXTENSION]'
|
25
|
+
opts.separator ' [--parse-option=OPTION]'
|
26
|
+
opts.separator ' [--render-option=OPTION]'
|
27
|
+
opts.separator ' [FILE..]'
|
28
|
+
opts.separator ''
|
29
|
+
opts.separator 'Convert one or more CommonMark files to HTML and write to standard output.'
|
30
|
+
opts.separator 'If no FILE argument is provided, text will be read from STDIN.'
|
31
|
+
opts.separator ''
|
32
|
+
|
33
|
+
opts.on('--extension=EXTENSION', Array, 'Use EXTENSION for parsing and HTML output (unless --html-renderer is specified)') do |values|
|
34
|
+
values.each do |value|
|
35
|
+
if extensions.include?(value)
|
36
|
+
options.active_extensions << value.to_sym
|
37
|
+
else
|
38
|
+
abort("extension '#{value}' not found")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on('-h', '--help', 'Prints this help') do
|
44
|
+
puts opts
|
45
|
+
puts
|
46
|
+
puts "Available extentions: #{extensions.join(', ')}"
|
47
|
+
puts "Available parse options: #{parse_options.keys.join(', ')}"
|
48
|
+
puts "Available render options: #{render_options.keys.join(', ')}"
|
49
|
+
puts
|
50
|
+
puts 'See the README for more information on these.'
|
51
|
+
exit
|
52
|
+
end
|
25
53
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
54
|
+
opts.on('--html-renderer', 'Use the HtmlRenderer renderer rather than the native C renderer') do
|
55
|
+
options.renderer = true
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on('--parse-option=OPTION', Array, 'OPTION passed during parsing') do |values|
|
59
|
+
values.each do |value|
|
60
|
+
if parse_options.key?(value.to_sym)
|
61
|
+
options.active_parse_options << value.to_sym
|
62
|
+
else
|
63
|
+
abort("parse-option '#{value}' not found")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
opts.on('--render-option=OPTION', Array, 'OPTION passed during rendering') do |values|
|
69
|
+
values.each do |value|
|
70
|
+
if render_options.key?(value.to_sym)
|
71
|
+
options.active_render_options << value.to_sym
|
72
|
+
else
|
73
|
+
abort("render-option '#{value}' not found")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.on('-v', '--version', 'Version information') do
|
79
|
+
puts "commonmarker #{CommonMarker::VERSION}"
|
80
|
+
exit
|
46
81
|
end
|
47
|
-
true
|
48
|
-
else
|
49
|
-
false
|
50
82
|
end
|
83
|
+
|
84
|
+
option_parser.parse!
|
85
|
+
|
86
|
+
options
|
51
87
|
end
|
52
88
|
|
53
|
-
|
89
|
+
options = parse_options
|
90
|
+
|
91
|
+
doc = CommonMarker.render_doc(ARGF.read, options.active_parse_options, options.active_extensions)
|
54
92
|
|
55
|
-
if renderer
|
56
|
-
renderer = CommonMarker::HtmlRenderer.new(extensions: active_extensions)
|
93
|
+
if options.renderer
|
94
|
+
renderer = CommonMarker::HtmlRenderer.new(extensions: options.active_extensions)
|
57
95
|
STDOUT.write(renderer.render(doc))
|
58
96
|
else
|
59
|
-
STDOUT.write(doc.to_html(
|
97
|
+
STDOUT.write(doc.to_html(options.active_render_options, options.active_extensions))
|
60
98
|
end
|
data/lib/commonmarker/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
I am **strong**
|
data/test/test_attributes.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class TestCommands < Minitest::Test
|
6
|
+
def test_basic
|
7
|
+
out = make_bin('strong.md')
|
8
|
+
assert_equal out, '<p>I am <strong>strong</strong></p>'
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_does_not_have_extensions
|
12
|
+
out = make_bin('table.md')
|
13
|
+
assert out.include?('| a')
|
14
|
+
refute out.include?('<p><del>hi</del>')
|
15
|
+
refute out.include?('<table> <tr> <th> a </th> <td> c </td>')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_understands_extensions
|
19
|
+
out = make_bin('table.md', '--extension=table')
|
20
|
+
refute out.include?('| a')
|
21
|
+
refute out.include?('<p><del>hi</del>')
|
22
|
+
%w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert out.include?(html) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_understands_multiple_extensions
|
26
|
+
out = make_bin('table.md', '--extension=table,strikethrough')
|
27
|
+
refute out.include?('| a')
|
28
|
+
assert out.include?('<p><del>hi</del>')
|
29
|
+
%w[<table> <tr> <th> a </th> <td> c </td>].each { |html| assert out.include?(html) }
|
30
|
+
end
|
31
|
+
end
|
data/test/test_encoding.rb
CHANGED
@@ -6,7 +6,7 @@ require 'test_helper'
|
|
6
6
|
class TestEncoding < Minitest::Test
|
7
7
|
# see http://git.io/vq4FR
|
8
8
|
def test_encoding
|
9
|
-
contents =
|
9
|
+
contents = fixtures_file('curly.md')
|
10
10
|
doc = CommonMarker.render_doc(contents, :SMART)
|
11
11
|
render = doc.to_html
|
12
12
|
assert_equal render.rstrip, '<p>This curly quote “makes commonmarker throw an exception”.</p>'
|
data/test/test_extensions.rb
CHANGED
@@ -4,18 +4,7 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class TestExtensions < Minitest::Test
|
6
6
|
def setup
|
7
|
-
@markdown =
|
8
|
-
One extension:
|
9
|
-
|
10
|
-
| a | b |
|
11
|
-
| --- | --- |
|
12
|
-
| c | d |
|
13
|
-
| **x** | |
|
14
|
-
|
15
|
-
Another extension:
|
16
|
-
|
17
|
-
~~hi~~
|
18
|
-
MD
|
7
|
+
@markdown = fixtures_file('table.md')
|
19
8
|
end
|
20
9
|
|
21
10
|
def test_uses_specified_extensions
|
data/test/test_helper.rb
CHANGED
@@ -10,6 +10,14 @@ include CommonMarker
|
|
10
10
|
|
11
11
|
FIXTURES_DIR = File.join(File.dirname(__FILE__), 'fixtures')
|
12
12
|
|
13
|
+
def fixtures_file(file)
|
14
|
+
File.read(File.join(FIXTURES_DIR, file), encoding: 'utf-8')
|
15
|
+
end
|
16
|
+
|
17
|
+
def make_bin(file, args = '')
|
18
|
+
`ruby bin/commonmarker #{File.join(FIXTURES_DIR, file)} #{args}`.chomp
|
19
|
+
end
|
20
|
+
|
13
21
|
def open_spec_file(filename)
|
14
22
|
line_number = 0
|
15
23
|
start_line = 0
|
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: 0.20.
|
4
|
+
version: 0.20.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-enum
|
@@ -246,8 +246,11 @@ files:
|
|
246
246
|
- test/benchmark.rb
|
247
247
|
- test/fixtures/curly.md
|
248
248
|
- test/fixtures/dingus.md
|
249
|
+
- test/fixtures/strong.md
|
250
|
+
- test/fixtures/table.md
|
249
251
|
- test/test_attributes.rb
|
250
252
|
- test/test_basics.rb
|
253
|
+
- test/test_commands.rb
|
251
254
|
- test/test_commonmark.rb
|
252
255
|
- test/test_doc.rb
|
253
256
|
- test/test_encoding.rb
|
@@ -287,8 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
287
290
|
- !ruby/object:Gem::Version
|
288
291
|
version: '0'
|
289
292
|
requirements: []
|
290
|
-
|
291
|
-
rubygems_version: 2.5.1
|
293
|
+
rubygems_version: 3.0.6
|
292
294
|
signing_key:
|
293
295
|
specification_version: 4
|
294
296
|
summary: CommonMark parser and renderer. Written in C, wrapped in Ruby.
|
@@ -296,8 +298,11 @@ test_files:
|
|
296
298
|
- test/benchmark.rb
|
297
299
|
- test/fixtures/curly.md
|
298
300
|
- test/fixtures/dingus.md
|
301
|
+
- test/fixtures/strong.md
|
302
|
+
- test/fixtures/table.md
|
299
303
|
- test/test_attributes.rb
|
300
304
|
- test/test_basics.rb
|
305
|
+
- test/test_commands.rb
|
301
306
|
- test/test_commonmark.rb
|
302
307
|
- test/test_doc.rb
|
303
308
|
- test/test_encoding.rb
|