commonmarker 0.8.0 → 0.9.0

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.

Potentially problematic release.


This version of commonmarker might be problematic. Click here for more details.

Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -1
  3. data/Rakefile +3 -3
  4. data/ext/commonmarker/cmark/build/CMakeCache.txt +8 -8
  5. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeCCompiler.cmake +0 -0
  6. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeCXXCompiler.cmake +0 -0
  7. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeDetermineCompilerABI_C.bin +0 -0
  8. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeDetermineCompilerABI_CXX.bin +0 -0
  9. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeSystem.cmake +0 -0
  10. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CompilerIdC/CMakeCCompilerId.c +0 -0
  11. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CompilerIdC/a.out +0 -0
  12. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -0
  13. data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CompilerIdCXX/a.out +0 -0
  14. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +6 -6
  15. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +143 -143
  16. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +106 -106
  17. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile2 +2 -2
  18. data/ext/commonmarker/cmark/build/Makefile +9 -9
  19. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +2 -2
  20. data/ext/commonmarker/cmark/build/api_test/Makefile +9 -9
  21. data/ext/commonmarker/cmark/build/man/Makefile +9 -9
  22. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make +2 -2
  23. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +2 -2
  24. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make +2 -2
  25. data/ext/commonmarker/cmark/build/src/Makefile +9 -9
  26. data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
  27. data/ext/commonmarker/cmark/build/testdir/Makefile +9 -9
  28. data/ext/commonmarker/commonmarker.c +579 -662
  29. data/ext/commonmarker/commonmarker.c.orig +1041 -0
  30. data/ext/commonmarker/commonmarker.h +1 -1
  31. data/lib/commonmarker.rb +1 -32
  32. data/lib/commonmarker/node.rb +45 -0
  33. data/lib/commonmarker/renderer.rb +2 -2
  34. data/lib/commonmarker/version.rb +1 -1
  35. data/test/test_basics.rb +1 -40
  36. data/test/test_node.rb +78 -0
  37. data/test/test_renderer.rb +13 -0
  38. metadata +17 -11
@@ -1,8 +1,8 @@
1
1
  #ifndef COMMONMARKER_H
2
2
  #define COMMONMARKER_H
3
3
 
4
- #include "ruby.h"
5
4
  #include "cmark.h"
5
+ #include "ruby.h"
6
6
 
7
7
  #define CSTR2SYM(s) (ID2SYM(rb_intern((s))))
8
8
 
data/lib/commonmarker.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'commonmarker/commonmarker'
3
3
  require 'commonmarker/config'
4
+ require 'commonmarker/node'
4
5
  require 'commonmarker/renderer'
5
6
  require 'commonmarker/renderer/html_renderer'
6
7
  require 'commonmarker/version'
@@ -36,36 +37,4 @@ module CommonMarker
36
37
  text = text.encode('UTF-8')
37
38
  Node.parse_document(text, text.bytesize, opts)
38
39
  end
39
-
40
- class Node
41
- # Public: An iterator that "walks the tree," descending into children recursively.
42
- #
43
- # blk - A {Proc} representing the action to take for each child
44
- def walk(&blk)
45
- yield self
46
- each_child do |child|
47
- child.walk(&blk)
48
- end
49
- end
50
-
51
- # Public: Convert the node to an HTML string.
52
- #
53
- # options - A {Symbol} or {Array of Symbol}s indicating the render options
54
- #
55
- # Returns a {String}.
56
- def to_html(options = :default)
57
- opts = Config.process_options(options, :render)
58
- _render_html(opts).force_encoding('utf-8')
59
- end
60
-
61
- # Internal: Iterate over the children (if any) of the current pointer.
62
- def each_child
63
- child = first_child
64
- while child
65
- nextchild = child.next
66
- yield child
67
- child = nextchild
68
- end
69
- end
70
- end
71
40
  end
@@ -0,0 +1,45 @@
1
+ module CommonMarker
2
+ class Node
3
+ include Enumerable
4
+
5
+ # Public: An iterator that "walks the tree," descending into children recursively.
6
+ #
7
+ # blk - A {Proc} representing the action to take for each child
8
+ def walk(&block)
9
+ return enum_for(:walk) unless block_given?
10
+
11
+ yield self
12
+ each do |child|
13
+ child.walk(&block)
14
+ end
15
+ end
16
+
17
+ # Public: Convert the node to an HTML string.
18
+ #
19
+ # options - A {Symbol} or {Array of Symbol}s indicating the render options
20
+ #
21
+ # Returns a {String}.
22
+ def to_html(options = :default)
23
+ opts = Config.process_options(options, :render)
24
+ _render_html(opts).force_encoding('utf-8')
25
+ end
26
+
27
+ # Public: Iterate over the children (if any) of the current pointer.
28
+ def each(&block)
29
+ return enum_for(:each) unless block_given?
30
+
31
+ child = first_child
32
+ while child
33
+ nextchild = child.next
34
+ yield child
35
+ child = nextchild
36
+ end
37
+ end
38
+
39
+ # Deprecated: Please use `each` instead
40
+ def each_child(&block)
41
+ warn '[DEPRECATION] `each_child` is deprecated. Please use `each` instead.'
42
+ each(&block)
43
+ end
44
+ end
45
+ end
@@ -16,7 +16,7 @@ module CommonMarker
16
16
  def out(*args)
17
17
  args.each do |arg|
18
18
  if arg == :children
19
- @node.each_child { |child| out(child) }
19
+ @node.each { |child| out(child) }
20
20
  elsif arg.is_a?(Array)
21
21
  arg.each { |x| render(x) }
22
22
  elsif arg.is_a?(Node)
@@ -34,7 +34,7 @@ module CommonMarker
34
34
  document(node)
35
35
  return @stream.string
36
36
  elsif @in_plain && node.type != :text && node.type != :softbreak
37
- node.each_child { |child| render(child) }
37
+ node.each { |child| render(child) }
38
38
  else
39
39
  begin
40
40
  send(node.type, node)
@@ -1,3 +1,3 @@
1
1
  module CommonMarker
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
data/test/test_basics.rb CHANGED
@@ -1,53 +1,14 @@
1
1
  require 'test_helper'
2
2
 
3
- class TestNode < Minitest::Test
3
+ class TestBasics < Minitest::Test
4
4
  def setup
5
5
  @doc = CommonMarker.render_doc('Hi *there*')
6
6
  end
7
7
 
8
- def test_walk
9
- nodes = []
10
- @doc.walk do |node|
11
- nodes << node.type
12
- end
13
- assert_equal [:document, :paragraph, :text, :emph, :text], nodes
14
- end
15
-
16
- def test_insert_illegal
17
- assert_raises NodeError do
18
- @doc.insert_before(@doc)
19
- end
20
- end
21
-
22
8
  def test_to_html
23
9
  assert_equal "<p>Hi <em>there</em></p>\n", @doc.to_html
24
10
  end
25
11
 
26
- def test_html_renderer
27
- renderer = HtmlRenderer.new
28
- result = renderer.render(@doc)
29
- assert_equal "<p>Hi <em>there</em></p>\n", result
30
- end
31
-
32
- def test_walk_and_set_string_content
33
- @doc.walk do |node|
34
- if node.type == :text && node.string_content == 'there'
35
- node.string_content = 'world'
36
- assert_equal 'world', node.string_content
37
- end
38
- end
39
- end
40
-
41
- def test_walk_and_delete_node
42
- @doc.walk do |node|
43
- if node.type == :emph
44
- node.insert_before(node.first_child)
45
- node.delete
46
- end
47
- end
48
- assert_equal "<p>Hi there</p>\n", @doc.to_html
49
- end
50
-
51
12
  def test_markdown_to_html
52
13
  html = CommonMarker.render_html('Hi *there*')
53
14
  assert_equal "<p>Hi <em>there</em></p>\n", html
data/test/test_node.rb ADDED
@@ -0,0 +1,78 @@
1
+ require 'test_helper'
2
+
3
+ class TestNode < Minitest::Test
4
+ def setup
5
+ @doc = CommonMarker.render_doc('Hi *there*, I am mostly text!')
6
+ end
7
+
8
+ def test_walk
9
+ nodes = []
10
+ @doc.walk do |node|
11
+ nodes << node.type
12
+ end
13
+ assert_equal [:document, :paragraph, :text, :emph, :text, :text, :text], nodes
14
+ end
15
+
16
+ def test_each
17
+ nodes = []
18
+ @doc.first_child.each do |node|
19
+ nodes << node.type
20
+ end
21
+ assert_equal [:text, :emph, :text, :text], nodes
22
+ end
23
+
24
+ def test_deprecated_each_child
25
+ nodes = []
26
+ @doc.first_child.each_child do |node|
27
+ nodes << node.type
28
+ end
29
+ assert_equal [:text, :emph, :text, :text], nodes
30
+ end
31
+
32
+ def test_select
33
+ nodes = @doc.first_child.select { |node| node.type == :text }
34
+ assert_equal CommonMarker::Node, nodes.first.class
35
+ assert_equal [:text, :text, :text], nodes.map(&:type)
36
+ end
37
+
38
+ def test_map
39
+ nodes = @doc.first_child.map(&:type)
40
+ assert_equal [:text, :emph, :text, :text], nodes
41
+ end
42
+
43
+ def test_insert_illegal
44
+ assert_raises NodeError do
45
+ @doc.insert_before(@doc)
46
+ end
47
+ end
48
+
49
+ def test_to_html
50
+ assert_equal "<p>Hi <em>there</em>, I am mostly text!</p>\n", @doc.to_html
51
+ end
52
+
53
+ def test_html_renderer
54
+ renderer = HtmlRenderer.new
55
+ result = renderer.render(@doc)
56
+ assert_equal "<p>Hi <em>there</em>, I am mostly text!</p>\n", result
57
+ end
58
+
59
+ def test_walk_and_set_string_content
60
+ @doc.walk do |node|
61
+ if node.type == :text && node.string_content == 'there'
62
+ node.string_content = 'world'
63
+ end
64
+ end
65
+ result = HtmlRenderer.new.render(@doc)
66
+ assert_equal "<p>Hi <em>world</em>, I am mostly text!</p>\n", result
67
+ end
68
+
69
+ def test_walk_and_delete_node
70
+ @doc.walk do |node|
71
+ if node.type == :emph
72
+ node.insert_before(node.first_child)
73
+ node.delete
74
+ end
75
+ end
76
+ assert_equal "<p>Hi there, I am mostly text!</p>\n", @doc.to_html
77
+ end
78
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ class TestRenderer < Minitest::Test
4
+ def setup
5
+ @doc = CommonMarker.render_doc('Hi *there*')
6
+ end
7
+
8
+ def test_html_renderer
9
+ renderer = HtmlRenderer.new
10
+ result = renderer.render(@doc)
11
+ assert_equal "<p>Hi <em>there</em></p>\n", result
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commonmarker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-enum
@@ -140,15 +140,15 @@ files:
140
140
  - ext/commonmarker/cmark/bench/stats.py
141
141
  - ext/commonmarker/cmark/benchmarks.md
142
142
  - ext/commonmarker/cmark/build/CMakeCache.txt
143
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CMakeCCompiler.cmake
144
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CMakeCXXCompiler.cmake
145
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin
146
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin
147
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CMakeSystem.cmake
148
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CompilerIdC/CMakeCCompilerId.c
149
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CompilerIdC/a.out
150
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CompilerIdCXX/CMakeCXXCompilerId.cpp
151
- - ext/commonmarker/cmark/build/CMakeFiles/3.5.1/CompilerIdCXX/a.out
143
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeCCompiler.cmake
144
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeCXXCompiler.cmake
145
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeDetermineCompilerABI_C.bin
146
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeDetermineCompilerABI_CXX.bin
147
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CMakeSystem.cmake
148
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdC/CMakeCCompilerId.c
149
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdC/a.out
150
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdCXX/CMakeCXXCompilerId.cpp
151
+ - ext/commonmarker/cmark/build/CMakeFiles/3.5.2/CompilerIdCXX/a.out
152
152
  - ext/commonmarker/cmark/build/CMakeFiles/CMakeDirectoryInformation.cmake
153
153
  - ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log
154
154
  - ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log
@@ -353,10 +353,12 @@ files:
353
353
  - ext/commonmarker/cmark/wrappers/wrapper.rb
354
354
  - ext/commonmarker/cmark/wrappers/wrapper.rkt
355
355
  - ext/commonmarker/commonmarker.c
356
+ - ext/commonmarker/commonmarker.c.orig
356
357
  - ext/commonmarker/commonmarker.h
357
358
  - ext/commonmarker/extconf.rb
358
359
  - lib/commonmarker.rb
359
360
  - lib/commonmarker/config.rb
361
+ - lib/commonmarker/node.rb
360
362
  - lib/commonmarker/renderer.rb
361
363
  - lib/commonmarker/renderer/html_renderer.rb
362
364
  - lib/commonmarker/version.rb
@@ -371,7 +373,9 @@ files:
371
373
  - test/test_helper.rb
372
374
  - test/test_linebreaks.rb
373
375
  - test/test_maliciousness.rb
376
+ - test/test_node.rb
374
377
  - test/test_pathological_inputs.rb
378
+ - test/test_renderer.rb
375
379
  - test/test_smartpunct.rb
376
380
  - test/test_spec.rb
377
381
  homepage: http://github.com/gjtorikian/commonmarker
@@ -411,6 +415,8 @@ test_files:
411
415
  - test/test_helper.rb
412
416
  - test/test_linebreaks.rb
413
417
  - test/test_maliciousness.rb
418
+ - test/test_node.rb
414
419
  - test/test_pathological_inputs.rb
420
+ - test/test_renderer.rb
415
421
  - test/test_smartpunct.rb
416
422
  - test/test_spec.rb