commonmarker 0.14.4 → 0.14.5

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
  SHA1:
3
- metadata.gz: 0e197672d34d9b8ce80830230f748a1a82dc41de
4
- data.tar.gz: e43f9b677a242a8c928f0d446df6be992ce9aede
3
+ metadata.gz: 2464d1ed429720b63b234bbd8a57114c18c0f80f
4
+ data.tar.gz: 9f58b78d8a6e2262da5a78948ef73da2d55722fb
5
5
  SHA512:
6
- metadata.gz: 3bf9e8dfac4bebdc8d4d15af724a93d15070730721bbba2637db42d0e12fbf0a5455cdb69c3e21043476ebe58ba7e615326af1e310c447626cc5d20bf3668684
7
- data.tar.gz: cdad436d0936f904787febab5367a7633d101e2108856d2507b707a5bc475adecdb482bb7e728d4795715bf706b47e0d133364aec94ad3e1485cbc9669b5e24c
6
+ metadata.gz: ebafa228760dfd38353a459726f4090638f1e007a7e80c29f45548a2fed122379a5ba6c7b3900e98885248725dd23a6daec2c5ef7e09c11f80335c9e81b69ce3
7
+ data.tar.gz: 862331cc8c3b5d90566e07dcf4b2fc572c60d36a8a5d4078517256fed201d2988d4c27df08f5662d509bbe3914c3f5ac6bf8c14f7fc46e013424f8539199a390
data/README.md CHANGED
@@ -27,7 +27,7 @@ Call `render_html` on a string to convert it to HTML:
27
27
 
28
28
  ``` ruby
29
29
  require 'commonmarker'
30
- CommonMarker.render_html('Hi *there*', :default)
30
+ CommonMarker.render_html('Hi *there*', :DEFAULT)
31
31
  # <p>Hi <em>there</em></p>\n
32
32
  ```
33
33
 
@@ -40,7 +40,7 @@ You can also parse a string to receive a `Document` node. You can than print tha
40
40
  ``` ruby
41
41
  require 'commonmarker'
42
42
 
43
- doc = CommonMarker.render_doc('*Hello* world', :default)
43
+ doc = CommonMarker.render_doc('*Hello* world', :DEFAULT)
44
44
  puts(doc.to_html) # <p>Hi <em>there</em></p>\n
45
45
 
46
46
  doc.walk do |node|
@@ -129,33 +129,33 @@ CommonMarker accepts the same options that CMark does, as symbols. Note that the
129
129
 
130
130
  | Name | Description |
131
131
  |-------|--------------|
132
- | `:default` | The default parsing system.
133
- | `:normalize` | Attempt to normalize the HTML.
134
- | `:smart` | Use smart punctuation (curly quotes, etc.).
135
- | `:validate_utf8` | Replace illegal sequences with the replacement character `U+FFFD`.
132
+ | `:DEFAULT` | The default parsing system.
133
+ | `:NORMALIZE` | Attempt to normalize the HTML.
134
+ | `:SMART` | Use smart punctuation (curly quotes, etc.).
135
+ | `:VALIDATE_UTF8` | Replace illegal sequences with the replacement character `U+FFFD`.
136
136
 
137
137
  ### Render options
138
138
 
139
139
  | Name | Description |
140
140
  |-------|--------------|
141
- | `:default` | The default rendering system.
142
- | `:sourcepos` | Include source position in rendered HTML.
143
- | `:hardbreaks` | Treat `\n` as hardbreaks (by adding `<br/>`).
144
- | `:safe` | Suppress raw HTML and unsafe links.
141
+ | `:DEFAULT` | The default rendering system.
142
+ | `:SOURCEPOS` | Include source position in rendered HTML.
143
+ | `:HARDBREAKS` | Treat `\n` as hardbreaks (by adding `<br/>`).
144
+ | `:SAFE` | Suppress raw HTML and unsafe links.
145
145
 
146
146
  ### Passing options
147
147
 
148
148
  To apply a single option, pass it in as a symbol argument:
149
149
 
150
150
  ``` ruby
151
- CommonMarker.render_doc("\"Hello,\" said the spider.", :smart)
151
+ CommonMarker.render_doc("\"Hello,\" said the spider.", :SMART)
152
152
  # <p>“Hello,” said the spider.</p>\n
153
153
  ```
154
154
 
155
155
  To have multiple options applied, pass in an array of symbols:
156
156
 
157
157
  ``` ruby
158
- CommonMarker.render_html("\"'Shelob' is my name.\"", [:hardbreaks, :sourcepos])
158
+ CommonMarker.render_html("\"'Shelob' is my name.\"", [:HARDBREAKS, :SOURCEPOS])
159
159
  ```
160
160
 
161
161
  For more information on these options, see [the CMark documentation](http://git.io/vlQii).
data/commonmarker.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.executables = ['commonmarker']
25
25
  s.require_paths = %w(lib ext)
26
26
 
27
- s.add_dependency 'ruby-enum', '= 0.5.0'
27
+ s.add_dependency 'ruby-enum', '~> 0.5'
28
28
 
29
29
  s.add_development_dependency 'minitest', '~> 5.6'
30
30
  s.add_development_dependency 'rake-compiler', '~> 0.9'
@@ -58,7 +58,7 @@ if (CMARK_STATIC)
58
58
  add_library(${STATICLIBRARY} STATIC ${LIBRARY_SOURCES})
59
59
 
60
60
  set_target_properties(${STATICLIBRARY} PROPERTIES
61
- COMPILE_FLAGS -DCMARKEXTENSIONS_STATIC_DEFINE
61
+ COMPILE_FLAGS "-DCMARK_STATIC_DEFINE -DCMARKEXTENSIONS_STATIC_DEFINE"
62
62
  POSITION_INDEPENDENT_CODE ON)
63
63
 
64
64
  if (MSVC)
@@ -70,7 +70,7 @@ include (GenerateExportHeader)
70
70
  add_executable(${PROGRAM} ${PROGRAM_SOURCES})
71
71
  add_compiler_export_flags()
72
72
 
73
- target_link_libraries(${PROGRAM} libcmark)
73
+ target_link_libraries(${PROGRAM} libcmark_static)
74
74
 
75
75
  add_dependencies(${PROGRAM} libcmarkextensions_static)
76
76
  target_link_libraries(${PROGRAM} libcmarkextensions_static)
@@ -47,6 +47,6 @@ end
47
47
 
48
48
  $LDFLAGS << " -L#{CMARK_BUILD_DIR}/src -L#{CMARK_BUILD_DIR}/extensions -lcmark -lcmarkextensions"
49
49
  $CFLAGS << " -O2 -I#{CMARK_DIR}/src -I#{CMARK_DIR}/extensions -I#{CMARK_BUILD_DIR}/src -I#{CMARK_BUILD_DIR}/extensions"
50
- $CFLAGS << " -DCMARK_STATIC_DEFINE"
50
+ $CFLAGS << " -DCMARK_STATIC_DEFINE -DCMARKEXTENSIONS_STATIC_DEFINE"
51
51
 
52
52
  create_makefile('commonmarker/commonmarker')
data/lib/commonmarker.rb CHANGED
@@ -18,7 +18,7 @@ module CommonMarker
18
18
  # extensions - An {Array of Symbol}s indicating the extensions to use
19
19
  #
20
20
  # Returns a {String} of converted HTML.
21
- def self.render_html(text, options = :default, extensions = [])
21
+ def self.render_html(text, options = :DEFAULT, extensions = [])
22
22
  fail TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
23
23
  opts = Config.process_options(options, :render)
24
24
  text = text.encode('UTF-8')
@@ -33,7 +33,7 @@ module CommonMarker
33
33
  # extensions - An {Array of Symbol}s indicating the extensions to use
34
34
  #
35
35
  # Returns the `document` node.
36
- def self.render_doc(text, options = :default, extensions = [])
36
+ def self.render_doc(text, options = :DEFAULT, extensions = [])
37
37
  fail TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
38
38
  opts = Config.process_options(options, :parse)
39
39
  text = text.encode('UTF-8')
@@ -5,19 +5,19 @@ module CommonMarker
5
5
  class Parse
6
6
  include Ruby::Enum
7
7
 
8
- define :default, 0
9
- define :normalize, (1 << 8)
10
- define :validate_utf8, (1 << 9)
11
- define :smart, (1 << 10)
8
+ define :DEFAULT, 0
9
+ define :NORMALIZE, (1 << 8)
10
+ define :VALIDATE_UTF8, (1 << 9)
11
+ define :SMART, (1 << 10)
12
12
  end
13
13
 
14
14
  class Render
15
15
  include Ruby::Enum
16
16
 
17
- define :default, 0
18
- define :sourcepos, (1 << 1)
19
- define :hardbreaks, (1 << 2)
20
- define :safe, (1 << 3)
17
+ define :DEFAULT, 0
18
+ define :SOURCEPOS, (1 << 1)
19
+ define :HARDBREAKS, (1 << 2)
20
+ define :SAFE, (1 << 3)
21
21
  end
22
22
 
23
23
  def self.process_options(option, type)
@@ -20,7 +20,7 @@ module CommonMarker
20
20
  # extensions - An {Array of Symbol}s indicating the extensions to use
21
21
  #
22
22
  # Returns a {String}.
23
- def to_html(options = :default, extensions = [])
23
+ def to_html(options = :DEFAULT, extensions = [])
24
24
  opts = Config.process_options(options, :render)
25
25
  _render_html(opts, extensions).force_encoding('utf-8')
26
26
  end
@@ -30,7 +30,7 @@ module CommonMarker
30
30
  # options - A {Symbol} or {Array of Symbol}s indicating the render options
31
31
  #
32
32
  # Returns a {String}.
33
- def to_commonmark(options = :default)
33
+ def to_commonmark(options = :DEFAULT)
34
34
  opts = Config.process_options(options, :render)
35
35
  _render_commonmark(opts).force_encoding('utf-8')
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module CommonMarker
2
- VERSION = '0.14.4'.freeze
2
+ VERSION = '0.14.5'.freeze
3
3
  end
@@ -21,7 +21,7 @@ Okay, _enough_.
21
21
  end
22
22
 
23
23
  def render_doc(doc)
24
- CommonMarker.render_doc(doc, :default, %i[table])
24
+ CommonMarker.render_doc(doc, :DEFAULT, %i[table])
25
25
  end
26
26
 
27
27
  def test_to_commonmark
@@ -5,7 +5,7 @@ class TestEncoding < Minitest::Test
5
5
  # see http://git.io/vq4FR
6
6
  def test_encoding
7
7
  contents = File.read(File.join(FIXTURES_DIR, 'curly.md'), encoding: 'utf-8')
8
- doc = CommonMarker.render_doc(contents, :smart)
8
+ doc = CommonMarker.render_doc(contents, :SMART)
9
9
  render = doc.to_html
10
10
  assert_equal render.rstrip, '<p>This curly quote “makes commonmarker throw an exception”.</p>'
11
11
  end
@@ -17,25 +17,25 @@ Another extension:
17
17
  end
18
18
 
19
19
  def test_uses_specified_extensions
20
- CommonMarker.render_html(@markdown, :default, %i[]).tap do |out|
20
+ CommonMarker.render_html(@markdown, :DEFAULT, %i[]).tap do |out|
21
21
  assert out.include?("| a")
22
22
  assert out.include?("| <strong>x</strong>")
23
23
  assert out.include?("~~hi~~")
24
24
  end
25
25
 
26
- CommonMarker.render_html(@markdown, :default, %i[table]).tap do |out|
26
+ CommonMarker.render_html(@markdown, :DEFAULT, %i[table]).tap do |out|
27
27
  refute out.include?("| a")
28
28
  %w(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each {|html| assert out.include?(html) }
29
29
  assert out.include?("~~hi~~")
30
30
  end
31
31
 
32
- CommonMarker.render_html(@markdown, :default, %i[strikethrough]).tap do |out|
32
+ CommonMarker.render_html(@markdown, :DEFAULT, %i[strikethrough]).tap do |out|
33
33
  assert out.include?("| a")
34
34
  refute out.include?("~~hi~~")
35
35
  assert out.include?("<del>hi</del>")
36
36
  end
37
37
 
38
- CommonMarker.render_html(@markdown, :default, %i[table strikethrough]).tap do |out|
38
+ CommonMarker.render_html(@markdown, :DEFAULT, %i[table strikethrough]).tap do |out|
39
39
  refute out.include?("| a")
40
40
  refute out.include?("| <strong>x</strong>")
41
41
  refute out.include?("~~hi~~")
@@ -44,7 +44,7 @@ Another extension:
44
44
  end
45
45
 
46
46
  def test_extensions_with_renderers
47
- doc = CommonMarker.render_doc(@markdown, :default, %i[table])
47
+ doc = CommonMarker.render_doc(@markdown, :DEFAULT, %i[table])
48
48
 
49
49
  doc.to_html.tap do |out|
50
50
  refute out.include?("| a")
@@ -60,13 +60,13 @@ Another extension:
60
60
  end
61
61
 
62
62
  def test_bad_extension_specifications
63
- assert_raises(TypeError) { CommonMarker.render_html(@markdown, :default, "nope") }
64
- assert_raises(TypeError) { CommonMarker.render_html(@markdown, :default, ["table"]) }
65
- assert_raises(ArgumentError) { CommonMarker.render_html(@markdown, :default, %i[table bad]) }
63
+ assert_raises(TypeError) { CommonMarker.render_html(@markdown, :DEFAULT, "nope") }
64
+ assert_raises(TypeError) { CommonMarker.render_html(@markdown, :DEFAULT, ["table"]) }
65
+ assert_raises(ArgumentError) { CommonMarker.render_html(@markdown, :DEFAULT, %i[table bad]) }
66
66
  end
67
67
 
68
68
  def test_comments_are_kept_as_expected
69
69
  assert_equal "<!--hello--> <blah> &lt;xmp>\n",
70
- CommonMarker.render_html("<!--hello--> <blah> <xmp>\n", :default, %i[tagfilter])
70
+ CommonMarker.render_html("<!--hello--> <blah> <xmp>\n", :DEFAULT, %i[tagfilter])
71
71
  end
72
72
  end
@@ -3,11 +3,11 @@ require 'test_helper'
3
3
  class TestLinebreaks < Minitest::Test
4
4
  def test_hardbreak_no_spaces
5
5
  doc = CommonMarker.render_doc("foo\nbaz")
6
- assert_equal "<p>foo<br />\nbaz</p>\n", doc.to_html(:hardbreaks)
6
+ assert_equal "<p>foo<br />\nbaz</p>\n", doc.to_html(:HARDBREAKS)
7
7
  end
8
8
 
9
9
  def test_hardbreak_with_spaces
10
10
  doc = CommonMarker.render_doc("foo \nbaz")
11
- assert_equal "<p>foo<br />\nbaz</p>\n", doc.to_html(:hardbreaks)
11
+ assert_equal "<p>foo<br />\nbaz</p>\n", doc.to_html(:HARDBREAKS)
12
12
  end
13
13
  end
@@ -4,7 +4,7 @@ class SmartPunctTest < Minitest::Test
4
4
  smart_punct = open_spec_file('smart_punct.txt')
5
5
 
6
6
  smart_punct.each do |testcase|
7
- doc = CommonMarker.render_doc(testcase[:markdown], :smart)
7
+ doc = CommonMarker.render_doc(testcase[:markdown], :SMART)
8
8
 
9
9
  define_method("test_smart_punct_example_#{testcase[:example]}") do
10
10
  actual = doc.to_html.strip
@@ -16,7 +16,7 @@ class SmartPunctTest < Minitest::Test
16
16
  def test_smart_hardbreak_no_spaces_render_doc
17
17
  markdown = "\"foo\"\nbaz"
18
18
  result = "<p>“foo”<br />\nbaz</p>\n"
19
- doc = CommonMarker.render_doc(markdown, :smart)
20
- assert_equal result, doc.to_html([:hardbreaks])
19
+ doc = CommonMarker.render_doc(markdown, :SMART)
20
+ assert_equal result, doc.to_html([:HARDBREAKS])
21
21
  end
22
22
  end
data/test/test_spec.rb CHANGED
@@ -6,10 +6,10 @@ class TestSpec < Minitest::Test
6
6
 
7
7
  spec.each do |testcase|
8
8
  # next unless testcase['example'] == 420
9
- doc = CommonMarker.render_doc(testcase[:markdown], :default, testcase[:extensions])
9
+ doc = CommonMarker.render_doc(testcase[:markdown], :DEFAULT, testcase[:extensions])
10
10
 
11
11
  define_method("test_to_html_example_#{testcase[:example]}") do
12
- actual = doc.to_html(:default, testcase[:extensions]).rstrip
12
+ actual = doc.to_html(:DEFAULT, testcase[:extensions]).rstrip
13
13
  assert_equal testcase[:html], actual, testcase[:markdown]
14
14
  end
15
15
 
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commonmarker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-23 00:00:00.000000000 Z
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-enum
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.0
19
+ version: '0.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.0
26
+ version: '0.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement