commonmarker 0.14.3 → 0.14.4

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.

Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/commonmarker.gemspec +1 -1
  3. data/ext/commonmarker/cmark/Makefile +2 -2
  4. data/ext/commonmarker/cmark/extensions/CMakeLists.txt +38 -12
  5. data/ext/commonmarker/cmark/extensions/autolink.c +151 -102
  6. data/ext/commonmarker/cmark/extensions/core-extensions.h +2 -0
  7. data/ext/commonmarker/cmark/extensions/strikethrough.c +15 -10
  8. data/ext/commonmarker/cmark/extensions/table.c +31 -26
  9. data/ext/commonmarker/cmark/src/CMakeLists.txt +4 -1
  10. data/ext/commonmarker/cmark/src/blocks.c +11 -7
  11. data/ext/commonmarker/cmark/src/cmark_extension_api.h +14 -0
  12. data/ext/commonmarker/cmark/src/commonmark.c +7 -5
  13. data/ext/commonmarker/cmark/src/inlines.c +1 -6
  14. data/ext/commonmarker/cmark/src/latex.c +4 -3
  15. data/ext/commonmarker/cmark/src/man.c +4 -3
  16. data/ext/commonmarker/cmark/src/render.c +5 -3
  17. data/ext/commonmarker/cmark/src/render.h +4 -3
  18. data/ext/commonmarker/cmark/src/syntax_extension.c +5 -0
  19. data/ext/commonmarker/cmark/src/syntax_extension.h +1 -0
  20. data/ext/commonmarker/cmark/test/CMakeLists.txt +3 -2
  21. data/ext/commonmarker/cmark/test/cmark.py +69 -23
  22. data/ext/commonmarker/cmark/test/extensions.txt +6 -6
  23. data/ext/commonmarker/cmark/test/roundtrip_tests.py +6 -4
  24. data/ext/commonmarker/cmark/test/spec.txt +420 -4
  25. data/ext/commonmarker/cmark/test/spec_tests.py +12 -6
  26. data/ext/commonmarker/extconf.rb +1 -1
  27. data/lib/commonmarker/renderer/html_renderer.rb +4 -0
  28. data/lib/commonmarker/version.rb +1 -1
  29. data/test/test_helper.rb +5 -2
  30. data/test/test_spec.rb +9 -7
  31. metadata +6 -6
@@ -19,6 +19,8 @@ if __name__ == "__main__":
19
19
  default=None, help='limit to sections matching regex pattern')
20
20
  parser.add_argument('--library-dir', dest='library_dir', nargs='?',
21
21
  default=None, help='directory containing dynamic library')
22
+ parser.add_argument('--extensions', dest='extensions', nargs='?',
23
+ default=None, help='space separated list of extensions to enable')
22
24
  parser.add_argument('--no-normalize', dest='normalize',
23
25
  action='store_const', const=False, default=True,
24
26
  help='do not normalize HTML')
@@ -39,9 +41,10 @@ def print_test_header(headertext, example_number, start_line, end_line):
39
41
  out("Example %d (lines %d-%d) %s\n" % (example_number,start_line,end_line,headertext))
40
42
 
41
43
  def do_test(converter, test, normalize, result_counts):
42
- [retcode, actual_html, err] = converter(test['markdown'])
44
+ [retcode, actual_html, err] = converter(test['markdown'], test['extensions'])
45
+ actual_html = re.sub(r'\r\n', '\n', actual_html)
43
46
  if retcode == 0:
44
- expected_html = test['html']
47
+ expected_html = re.sub(r'\r\n', '\n', test['html'])
45
48
  unicode_error = None
46
49
  if expected_html.strip() == '<IGNORE>':
47
50
  passed = True
@@ -84,6 +87,7 @@ def get_tests(specfile):
84
87
  markdown_lines = []
85
88
  html_lines = []
86
89
  state = 0 # 0 regular text, 1 markdown example, 2 html output
90
+ extensions = []
87
91
  headertext = ''
88
92
  tests = []
89
93
 
@@ -93,8 +97,9 @@ def get_tests(specfile):
93
97
  for line in specf:
94
98
  line_number = line_number + 1
95
99
  l = line.strip()
96
- if l == "`" * 32 + " example":
100
+ if l.startswith("`" * 32 + " example"):
97
101
  state = 1
102
+ extensions = l[32 + len(" example"):].split()
98
103
  elif l == "`" * 32:
99
104
  state = 0
100
105
  example_number = example_number + 1
@@ -105,7 +110,8 @@ def get_tests(specfile):
105
110
  "example": example_number,
106
111
  "start_line": start_line,
107
112
  "end_line": end_line,
108
- "section": headertext})
113
+ "section": headertext,
114
+ "extensions": extensions})
109
115
  start_line = 0
110
116
  markdown_lines = []
111
117
  html_lines = []
@@ -133,11 +139,11 @@ if __name__ == "__main__":
133
139
  pattern_re = re.compile('.')
134
140
  tests = [ test for test in all_tests if re.search(pattern_re, test['section']) and (not args.number or test['example'] == args.number) ]
135
141
  if args.dump_tests:
136
- out(json.dumps(tests, ensure_ascii=False, indent=2))
142
+ out(json.dumps(tests, indent=2))
137
143
  exit(0)
138
144
  else:
139
145
  skipped = len(all_tests) - len(tests)
140
- converter = CMark(prog=args.program, library_dir=args.library_dir).to_html
146
+ converter = CMark(prog=args.program, library_dir=args.library_dir, extensions=args.extensions).to_html
141
147
  result_counts = {'pass': 0, 'fail': 0, 'error': 0, 'skip': skipped}
142
148
  for test in tests:
143
149
  do_test(converter, test, args.normalize, result_counts)
@@ -46,7 +46,7 @@ unless sitearch =~ /^universal-darwin/
46
46
  end
47
47
 
48
48
  $LDFLAGS << " -L#{CMARK_BUILD_DIR}/src -L#{CMARK_BUILD_DIR}/extensions -lcmark -lcmarkextensions"
49
- $CFLAGS << " -O2 -I#{CMARK_DIR}/src -I#{CMARK_DIR}/extensions -I#{CMARK_BUILD_DIR}/src"
49
+ $CFLAGS << " -O2 -I#{CMARK_DIR}/src -I#{CMARK_DIR}/extensions -I#{CMARK_BUILD_DIR}/src -I#{CMARK_BUILD_DIR}/extensions"
50
50
  $CFLAGS << " -DCMARK_STATIC_DEFINE"
51
51
 
52
52
  create_makefile('commonmarker/commonmarker')
@@ -155,5 +155,9 @@ module CommonMarker
155
155
  def table_cell(_)
156
156
  out(@in_header ? '<th>' : '<td>', :children, @in_header ? '</th>' : '</td>')
157
157
  end
158
+
159
+ def strikethrough(_)
160
+ out('<strike>', :children, '</strike>')
161
+ end
158
162
  end
159
163
  end
@@ -1,3 +1,3 @@
1
1
  module CommonMarker
2
- VERSION = '0.14.3'.freeze
2
+ VERSION = '0.14.4'.freeze
3
3
  end
data/test/test_helper.rb CHANGED
@@ -17,6 +17,7 @@ def open_spec_file(filename)
17
17
  state = 0 # 0 regular text, 1 markdown example, 2 html output
18
18
  headertext = ''
19
19
  tests = []
20
+ extensions = []
20
21
 
21
22
  header_re = Regexp.new('#+ ')
22
23
  filepath = File.join('ext', 'commonmarker', 'cmark', 'test', filename)
@@ -25,8 +26,9 @@ def open_spec_file(filename)
25
26
  line_number += 1
26
27
 
27
28
  l = line.strip
28
- if l == '`' * 32 + ' example'
29
+ if l =~ /^`{32} example(.*)$/
29
30
  state = 1
31
+ extensions = $1.split
30
32
  elsif l == '`' * 32
31
33
  state = 0
32
34
  example_number += 1
@@ -37,7 +39,8 @@ def open_spec_file(filename)
37
39
  :example => example_number,
38
40
  :start_line => start_line,
39
41
  :end_line => end_line,
40
- :section => headertext
42
+ :section => headertext,
43
+ :extensions => extensions.map(&:to_sym),
41
44
  }
42
45
  start_line = 0
43
46
  markdown_lines = []
data/test/test_spec.rb CHANGED
@@ -6,18 +6,20 @@ 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])
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.rstrip
12
+ actual = doc.to_html(:default, testcase[:extensions]).rstrip
13
13
  assert_equal testcase[:html], actual, testcase[:markdown]
14
14
  end
15
15
 
16
- define_method("test_html_renderer_example_#{testcase[:example]}") do
17
- actual = HtmlRenderer.new.render(doc).rstrip
18
- File.write('test.txt', testcase[:html])
19
- File.write('actual.txt', actual)
20
- assert_equal testcase[:html], actual, testcase[:markdown]
16
+ unless testcase[:extensions].any?
17
+ define_method("test_html_renderer_example_#{testcase[:example]}") do
18
+ actual = HtmlRenderer.new.render(doc).rstrip
19
+ File.write('test.txt', testcase[:html])
20
+ File.write('actual.txt', actual)
21
+ assert_equal testcase[:html], actual, testcase[:markdown]
22
+ end
21
23
  end
22
24
  end
23
25
  end
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.3
4
+ version: 0.14.4
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-06 00:00:00.000000000 Z
11
+ date: 2017-02-23 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.4'
19
+ version: 0.5.0
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.4'
26
+ version: 0.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement