commonmarker 0.23.0 → 0.23.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c52b70b0c680aae2d46b089b673745cbe586f1e27589bd81b1f3f0f091a7659d
4
- data.tar.gz: 400efb13ab3ba9c72d451be4cd4cac8ee17688f70733d6d57771a093e412b63f
3
+ metadata.gz: 1f620ec82d102c4726e551911d21a5d87e7185010ba711f6ddc35495184c90ba
4
+ data.tar.gz: cf14b3a68481564facd7fbb46c90c822757d168db7eb41786b3a2d0ee3173e66
5
5
  SHA512:
6
- metadata.gz: 99309c1ab3c30c524adac6be1f75b3e63fe166b9248f8a8e74bd228a2428b10c794a56a3d5390786e4b33a869531f5879461c73d1ae7aaea66be491000779761
7
- data.tar.gz: 2c4ac9a297cfb0204eb4355f0aa3e8471ddd2f6bf9162e7db2a71f16e32f3470779f86082e8aa9473ddf0f45ee3df41d133a7f073209c3d1441da4468266297d
6
+ metadata.gz: 6a4d50388ad098dd9ccfd7e733e9a1274841e4b5d929d76e4f2e75ec10c55889ee85ef55afdb5ef5665214e6abde73e75bcd647fd2a53c6aa985a9396922992b
7
+ data.tar.gz: a1e587570999fbc0c5f6423f7dcf375a8b2ffee2339939e2ca80807b5950c042656a498ea4acfaf3b60ba45d14fdc8f4655a0a936a06d966a89d3f9133a32188
data/README.md CHANGED
@@ -130,26 +130,31 @@ CommonMarker accepts the same options that CMark does, as symbols. Note that the
130
130
  | Name | Description
131
131
  | ----------------------------- | -----------
132
132
  | `:DEFAULT` | The default parsing system.
133
+ | `:SOURCEPOS` | Include source position in nodes
133
134
  | `:UNSAFE` | Allow raw/custom HTML and unsafe links.
134
- | `:FOOTNOTES` | Parse footnotes.
135
- | `:LIBERAL_HTML_TAG` | Support liberal parsing of inline HTML tags.
135
+ | `:VALIDATE_UTF8` | Replace illegal sequences with the replacement character `U+FFFD`.
136
136
  | `:SMART` | Use smart punctuation (curly quotes, etc.).
137
+ | `:LIBERAL_HTML_TAG` | Support liberal parsing of inline HTML tags.
138
+ | `:FOOTNOTES` | Parse footnotes.
137
139
  | `:STRIKETHROUGH_DOUBLE_TILDE` | Parse strikethroughs by double tildes (compatibility with [redcarpet](https://github.com/vmg/redcarpet))
138
- | `:VALIDATE_UTF8` | Replace illegal sequences with the replacement character `U+FFFD`.
139
140
 
140
141
  ### Render options
141
142
 
142
143
  | Name | Description |
143
144
  | ------------------ | ----------- |
144
145
  | `:DEFAULT` | The default rendering system. |
145
- | `:UNSAFE` | Allow raw/custom HTML and unsafe links. |
146
- | `:GITHUB_PRE_LANG` | Use GitHub-style `<pre lang>` for fenced code blocks. |
146
+ | `:SOURCEPOS` | Include source position in rendered HTML. |
147
147
  | `:HARDBREAKS` | Treat `\n` as hardbreaks (by adding `<br/>`). |
148
+ | `:UNSAFE` | Allow raw/custom HTML and unsafe links. |
148
149
  | `:NOBREAKS` | Translate `\n` in the source to a single whitespace. |
149
- | `:SOURCEPOS` | Include source position in rendered HTML. |
150
+ | `:VALIDATE_UTF8` | Replace illegal sequences with the replacement character `U+FFFD`. |
151
+ | `:SMART` | Use smart punctuation (curly quotes, etc.). |
152
+ | `:GITHUB_PRE_LANG` | Use GitHub-style `<pre lang>` for fenced code blocks. |
153
+ | `:LIBERAL_HTML_TAG` | Support liberal parsing of inline HTML tags. |
154
+ | `:FOOTNOTES` | Render footnotes. |
155
+ | `:STRIKETHROUGH_DOUBLE_TILDE` | Parse strikethroughs by double tildes (compatibility with [redcarpet](https://github.com/vmg/redcarpet)) |
150
156
  | `:TABLE_PREFER_STYLE_ATTRIBUTES` | Use `style` insted of `align` for table cells. |
151
157
  | `:FULL_INFO_STRING` | Include full info strings of code blocks in separate attribute. |
152
- | `:FOOTNOTES` | Render footnotes. |
153
158
 
154
159
  ### Passing options
155
160
 
@@ -7,23 +7,28 @@ module CommonMarker
7
7
  OPTS = {
8
8
  parse: {
9
9
  DEFAULT: 0,
10
+ SOURCEPOS: (1 << 1),
11
+ UNSAFE: (1 << 17),
10
12
  VALIDATE_UTF8: (1 << 9),
11
13
  SMART: (1 << 10),
12
14
  LIBERAL_HTML_TAG: (1 << 12),
13
15
  FOOTNOTES: (1 << 13),
14
16
  STRIKETHROUGH_DOUBLE_TILDE: (1 << 14),
15
- UNSAFE: (1 << 17)
16
17
  }.freeze,
17
18
  render: {
18
19
  DEFAULT: 0,
19
20
  SOURCEPOS: (1 << 1),
20
21
  HARDBREAKS: (1 << 2),
22
+ UNSAFE: (1 << 17),
21
23
  NOBREAKS: (1 << 4),
24
+ VALIDATE_UTF8: (1 << 9),
25
+ SMART: (1 << 10),
22
26
  GITHUB_PRE_LANG: (1 << 11),
27
+ LIBERAL_HTML_TAG: (1 << 12),
28
+ FOOTNOTES: (1 << 13),
29
+ STRIKETHROUGH_DOUBLE_TILDE: (1 << 14),
23
30
  TABLE_PREFER_STYLE_ATTRIBUTES: (1 << 15),
24
31
  FULL_INFO_STRING: (1 << 16),
25
- UNSAFE: (1 << 17),
26
- FOOTNOTES: (1 << 13)
27
32
  }.freeze,
28
33
  format: %i[html xml commonmark plaintext].freeze
29
34
  }.freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommonMarker
4
- VERSION = '0.23.0'
4
+ VERSION = '0.23.1'
5
5
  end
data/test/test_basics.rb CHANGED
@@ -15,4 +15,21 @@ class TestBasics < Minitest::Test
15
15
  html = CommonMarker.render_html('Hi *there*')
16
16
  assert_equal "<p>Hi <em>there</em></p>\n", html
17
17
  end
18
+
19
+ # basic test that just checks if every option is accepted & no errors are thrown
20
+ def test_accept_every_option
21
+ text = "Hello **world** -- how are _you_ today? I'm ~~fine~~, ~yourself~?"
22
+ parse_opt = [:SOURCEPOS, :UNSAFE, :VALIDATE_UTF8, :SMART, :LIBERAL_HTML_TAG, :FOOTNOTES, :STRIKETHROUGH_DOUBLE_TILDE]
23
+ render_opt = parse_opt + [:HARDBREAKS, :NOBREAKS, :GITHUB_PRE_LANG, :TABLE_PREFER_STYLE_ATTRIBUTES, :FULL_INFO_STRING]
24
+
25
+ extensions = %i[table tasklist strikethrough autolink tagfilter]
26
+
27
+ assert_equal "<p>Hello <strong>world</strong> – how are <em>you</em> today? I’m <del>fine</del>, ~yourself~?</p>\n", CommonMarker.render_doc(text, parse_opt, extensions).to_html
28
+
29
+ # note how tho the doc returned has sourcepos info, by default the renderer
30
+ # won't emit it. for that we need to pass in the render opt
31
+ assert_equal "<p data-sourcepos=\"1:1-1:65\">Hello <strong>world</strong> – how are <em>you</em> today? I’m <del>fine</del>, ~yourself~?</p>\n", CommonMarker.render_doc(text, parse_opt, extensions).to_html(render_opt, extensions)
32
+
33
+ assert_equal "<p data-sourcepos=\"1:1-1:65\">Hello <strong>world</strong> – how are <em>you</em> today? I’m <del>fine</del>, ~yourself~?</p>\n", CommonMarker.render_html(text, parse_opt, extensions)
34
+ end
18
35
  end
@@ -29,6 +29,9 @@ class TestExtensions < Minitest::Test
29
29
  doc = CommonMarker.render_doc('~a~ ~~b~~ ~~~c~~~', :STRIKETHROUGH_DOUBLE_TILDE, [:strikethrough])
30
30
  assert_equal("<p>~a~ <del>b</del> ~~~c~~~</p>\n", doc.to_html)
31
31
 
32
+ html = CommonMarker.render_html('~a~ ~~b~~ ~~~c~~~', :STRIKETHROUGH_DOUBLE_TILDE, [:strikethrough])
33
+ assert_equal("<p>~a~ <del>b</del> ~~~c~~~</p>\n", html)
34
+
32
35
  CommonMarker.render_html(@markdown, :DEFAULT, %i[table strikethrough]).tap do |out|
33
36
  refute_includes out, '| a'
34
37
  refute_includes out, '| <strong>x</strong>'
@@ -67,11 +67,6 @@ module CommonMarker
67
67
  CommonMarker.render_html(nil)
68
68
  end
69
69
 
70
- err = assert_raises TypeError do
71
- CommonMarker.render_html("foo \n baz", [:SMART])
72
- end
73
- assert_equal('option \':SMART\' does not exist for CommonMarker::Config::OPTS[:render]', err.message)
74
-
75
70
  assert_raises TypeError do
76
71
  CommonMarker.render_doc("foo \n baz", 123)
77
72
  end
@@ -7,11 +7,14 @@ class SmartPunctTest < Minitest::Test
7
7
 
8
8
  smart_punct.each do |testcase|
9
9
  doc = CommonMarker.render_doc(testcase[:markdown], :SMART)
10
+ html = CommonMarker.render_html(testcase[:markdown], :SMART)
10
11
 
11
12
  define_method("test_smart_punct_example_#{testcase[:example]}") do
12
- actual = doc.to_html.strip
13
+ doc_rendered = doc.to_html.strip
14
+ html_rendered = html.strip
13
15
 
14
- assert_equal testcase[:html], actual, testcase[:markdown]
16
+ assert_equal testcase[:html], doc_rendered, testcase[:markdown]
17
+ assert_equal testcase[:html], html_rendered, testcase[:markdown]
15
18
  end
16
19
  end
17
20
 
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.23.0
4
+ version: 0.23.1
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: 2021-08-30 00:00:00.000000000 Z
12
+ date: 2021-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: awesome_print