motion-kramdown 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -7
  3. data/lib/kramdown.rb +1 -1
  4. data/lib/kramdown/compatibility.rb +1 -1
  5. data/lib/kramdown/converter.rb +1 -1
  6. data/lib/kramdown/converter/base.rb +2 -1
  7. data/lib/kramdown/converter/html.rb +10 -5
  8. data/lib/kramdown/converter/kramdown.rb +13 -7
  9. data/lib/kramdown/converter/latex.rb +2 -1
  10. data/lib/kramdown/converter/math_engine/itex2mml.rb +1 -1
  11. data/lib/kramdown/converter/math_engine/mathjax.rb +18 -3
  12. data/lib/kramdown/converter/math_engine/ritex.rb +1 -1
  13. data/lib/kramdown/converter/pdf.rb +3 -2
  14. data/lib/kramdown/converter/remove_html_tags.rb +3 -1
  15. data/lib/kramdown/converter/syntax_highlighter.rb +53 -0
  16. data/lib/kramdown/converter/syntax_highlighter/coderay.rb +1 -1
  17. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +2 -2
  18. data/lib/kramdown/converter/toc.rb +2 -2
  19. data/lib/kramdown/document.rb +5 -5
  20. data/lib/kramdown/element.rb +4 -1
  21. data/lib/kramdown/error.rb +1 -1
  22. data/lib/kramdown/options.rb +4 -3
  23. data/lib/kramdown/parser.rb +1 -1
  24. data/lib/kramdown/parser/base.rb +8 -4
  25. data/lib/kramdown/parser/gfm.rb +9 -1
  26. data/lib/kramdown/parser/html.rb +18 -3
  27. data/lib/kramdown/parser/kramdown.rb +8 -5
  28. data/lib/kramdown/parser/kramdown/abbreviation.rb +10 -2
  29. data/lib/kramdown/parser/kramdown/autolink.rb +1 -1
  30. data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
  31. data/lib/kramdown/parser/kramdown/block_boundary.rb +1 -1
  32. data/lib/kramdown/parser/kramdown/blockquote.rb +1 -1
  33. data/lib/kramdown/parser/kramdown/codeblock.rb +1 -1
  34. data/lib/kramdown/parser/kramdown/codespan.rb +1 -1
  35. data/lib/kramdown/parser/kramdown/emphasis.rb +2 -2
  36. data/lib/kramdown/parser/kramdown/eob.rb +1 -1
  37. data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
  38. data/lib/kramdown/parser/kramdown/extensions.rb +8 -7
  39. data/lib/kramdown/parser/kramdown/footnote.rb +12 -4
  40. data/lib/kramdown/parser/kramdown/header.rb +1 -1
  41. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
  42. data/lib/kramdown/parser/kramdown/html.rb +7 -4
  43. data/lib/kramdown/parser/kramdown/html_entity.rb +1 -1
  44. data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
  45. data/lib/kramdown/parser/kramdown/link.rb +8 -5
  46. data/lib/kramdown/parser/kramdown/list.rb +17 -5
  47. data/lib/kramdown/parser/kramdown/math.rb +3 -3
  48. data/lib/kramdown/parser/kramdown/paragraph.rb +3 -3
  49. data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
  50. data/lib/kramdown/parser/kramdown/table.rb +1 -1
  51. data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
  52. data/lib/kramdown/parser/markdown.rb +2 -2
  53. data/lib/kramdown/utils.rb +1 -1
  54. data/lib/kramdown/utils/configurable.rb +1 -1
  55. data/lib/kramdown/utils/entities.rb +1 -1
  56. data/lib/kramdown/utils/html.rb +3 -1
  57. data/lib/kramdown/utils/ordered_hash.rb +1 -1
  58. data/lib/kramdown/utils/string_scanner.rb +8 -0
  59. data/lib/kramdown/utils/unidecoder.rb +1 -1
  60. data/lib/kramdown/version.rb +2 -2
  61. data/lib/rubymotion/version.rb +1 -1
  62. data/spec/bench_mark.rb +43 -30
  63. data/spec/document_tree.rb +12 -2
  64. data/spec/gfm_to_html.rb +4 -1
  65. data/spec/html_to_html.rb +27 -9
  66. data/spec/html_to_kramdown_to_html.rb +4 -1
  67. data/spec/kramdown_to_xxx.rb +3 -1
  68. data/spec/text_to_kramdown_to_html.rb +4 -0
  69. data/spec/text_to_latex.rb +1 -1
  70. metadata +5 -4
@@ -1,14 +1,24 @@
1
1
  describe "asserting that converters don't modify the document tree" do
2
2
 
3
+ EXCLUDE_PDF_MODIFY = ['test/testcases/span/text_substitutions/entities.text',
4
+ 'test/testcases/span/text_substitutions/entities_numeric.text',
5
+ 'test/testcases/span/text_substitutions/entities_as_char.text',
6
+ 'test/testcases/span/text_substitutions/entities_as_input.text',
7
+ 'test/testcases/span/text_substitutions/entities_symbolic.text',
8
+ 'test/testcases/block/04_header/with_auto_ids.text',
9
+ ].compact
10
+
3
11
  EXCLUDE_TREE_FILES = [
4
12
  'test/testcases/block/15_math/gh_128.text', # bc no math support yet
5
13
  'test/testcases/block/15_math/itex2mml.text', # bc no math support yet
6
14
  'test/testcases/block/15_math/normal.text', # bc no math support yet
7
15
  'test/testcases/block/15_math/ritex.text', # bc no math support yet
16
+ 'test/testcases/block/15_math/mathjax_preview.text', # bc no math support yet
17
+ 'test/testcases/block/15_math/mathjax_preview_simple.text', # bc no math support yet
8
18
  'test/testcases/span/math/normal.text', # bc no math support yet
9
19
  'test/testcases/span/math/ritex.text', # bc no math support yet
10
20
  'test/testcases/span/math/itex2mml.text', # bc no math support yet
11
- ]
21
+ ].compact
12
22
 
13
23
  Dir["#{focus_files(testcase_dir)}.text"].each do |text_file|
14
24
  next if EXCLUDE_TREE_FILES.any? {|f| text_file =~ /#{f}$/}
@@ -16,7 +26,7 @@ describe "asserting that converters don't modify the document tree" do
16
26
  options = load_options(opts_file)
17
27
 
18
28
  (Kramdown::Converter.constants(true).map {|c| c.to_sym} - [:Latex, :Base, :RemoveHtmlTags, :MathEngine, :SyntaxHighlighter]).each do |conv_class|
19
- next if conv_class == :Pdf && RUBY_VERSION < '1.9'
29
+ next if conv_class == :Pdf && (RUBY_VERSION < '2.0' || EXCLUDE_PDF_MODIFY.any? {|f| text_file =~ /#{f}$/})
20
30
 
21
31
  it "#{short_name(text_file)} --> #{conv_class} modifies tree with file?" do
22
32
  options = load_options(opts_file)
data/spec/gfm_to_html.rb CHANGED
@@ -67,13 +67,15 @@ describe "gfm-to-html conversion" do
67
67
  'test/testcases/block/15_math/itex2mml.text', # bc no math support yet
68
68
  'test/testcases/block/15_math/normal.text', # bc no math support yet
69
69
  'test/testcases/block/15_math/ritex.text', # bc no math support yet
70
+ 'test/testcases/block/15_math/mathjax_preview.text', # bc no math support yet
71
+ 'test/testcases/block/15_math/mathjax_preview_simple.text', # bc no math support yet
70
72
  'test/testcases/span/math/itex2mml.text', # bc no math support yet
71
73
  'test/testcases/span/math/normal.text', # bc no math support yet
72
74
  'test/testcases/span/math/ritex.text', # bc no math support yet
73
75
  'test/testcases/span/03_codespan/highlighting-rouge.text', # bc no highlight support yet
74
76
  'test/testcases/span/03_codespan/highlighting.text', # bc no highlight support yet
75
77
  'test/testcases_gfm/backticks_syntax.text', # bc no highlight support yet
76
- ]
78
+ ].compact
77
79
 
78
80
  ['testcases', 'testcases_gfm'].each do |item|
79
81
  Dir["#{focus_files(testcase_dir(item))}.text"].each do |text_file|
@@ -84,6 +86,7 @@ describe "gfm-to-html conversion" do
84
86
  html_file = [(".html.19" if RUBY_VERSION >= '1.9'), ".html"].compact.
85
87
  map {|ext| basename + ext }.
86
88
  detect {|file| File.exist?(file) }
89
+ next unless html_file
87
90
 
88
91
  it "gfm #{short_name(text_file)} --> html" do
89
92
  options = load_options(opts_file)
data/spec/html_to_html.rb CHANGED
@@ -1,8 +1,8 @@
1
- describe "html-to-html conversion" do
1
+ describe "html-to-{html,kramdown} conversion" do
2
2
 
3
3
  `tidy -v 2>&1`
4
4
  if $?.exitstatus != 0
5
- warn("Skipping html-to-html tests because tidy executable is missing")
5
+ warn("Skipping html-to-{html,kramdown} tests because tidy executable is missing")
6
6
  else
7
7
  EXCLUDE_HTML_FILES = [
8
8
  'test/testcases/block/06_codeblock/whitespace.html', # bc of span inside pre
@@ -16,23 +16,41 @@ describe "html-to-html conversion" do
16
16
  'test/testcases/span/math/ritex.html', # bc of tidy
17
17
  'test/testcases/block/15_math/itex2mml.html', # bc of tidy
18
18
  'test/testcases/span/math/itex2mml.html', # bc of tidy
19
-
19
+ 'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
20
+ 'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
21
+
20
22
  'test/testcases/block/15_math/gh_128.html', # bc no math support yet
21
23
  'test/testcases/block/15_math/normal.html', # bc no math support yet
22
24
  'test/testcases/span/math/normal.html', # bc no math support yet
23
- ]
25
+ ].compact
26
+
27
+ EXCLUDE_HTML_TEXT_FILES = ['test/testcases/block/09_html/parse_as_span.htmlinput',
28
+ 'test/testcases/block/09_html/parse_as_raw.htmlinput',
29
+ ].compact
24
30
 
25
31
  Dir["#{focus_files(testcase_dir)}.{html,html.19,htmlinput,htmlinput.19}"].each do |html_file|
26
32
  next if EXCLUDE_HTML_FILES.any? {|f| html_file =~ /#{f}(\.19)?$/}
27
33
  next if skip_file_ruby_19?(html_file)
28
34
 
29
- out_file = (html_file =~ /\.htmlinput(\.19)?$/ ? html_file.sub(/input(\.19)?$/, '') : html_file)
30
35
  opts_file = html_file.sub(/\.html(input)?(\.19)?$/, '.options')
36
+
37
+ out_files = []
38
+ out_files << [(html_file =~ /\.htmlinput(\.19)?$/ ? html_file.sub(/input(\.19)?$/, '') : html_file), :to_html]
39
+ if html_file =~ /\.htmlinput(\.19)?$/ && !EXCLUDE_HTML_TEXT_FILES.any? {|f| html_file =~ /#{f}/}
40
+ out_files << [html_file.sub(/htmlinput(\.19)?$/, 'text'), :to_kramdown]
41
+ end
42
+
43
+ out_files.select {|f, _| File.exist?(f)}.each do |out_file, out_method|
31
44
 
32
- it "#{short_name(html_file)} --> html" do
33
- options = load_options(opts_file)
34
- doc = Kramdown::Document.new(File.read(html_file), options.merge(:input => 'html'))
35
- expect(tidy_output(File.read(out_file))).to eq tidy_output(doc.to_html)
45
+ it "#{short_name(html_file)} --> #{File.extname(out_file)}" do
46
+ options = load_options(opts_file)
47
+ doc = Kramdown::Document.new(File.read(html_file), options.merge(:input => 'html'))
48
+ if out_method == :to_html
49
+ expect(tidy_output(File.read(out_file))).to eq tidy_output(doc.send(out_method))
50
+ else
51
+ expect(File.read(out_file)).to eq doc.send(out_method)
52
+ end
53
+ end
36
54
  end
37
55
  end
38
56
  end
@@ -24,11 +24,14 @@ describe "html-to-kramdown-to-html conversion" do
24
24
  'test/testcases/span/math/ritex.html', # bc of tidy
25
25
  'test/testcases/block/15_math/itex2mml.html', # bc of tidy
26
26
  'test/testcases/span/math/itex2mml.html', # bc of tidy
27
+ 'test/testcases/block/15_math/mathjax_preview.html', # bc of mathjax preview
28
+ 'test/testcases/block/15_math/mathjax_preview_simple.html', # bc of mathjax preview
29
+ 'test/testcases/span/01_link/link_defs_with_ial.html', # bc of attribute ordering
27
30
 
28
31
  'testcases/block/15_math/gh_128.html', # bc no math support yet
29
32
  'test/testcases/block/15_math/normal.html', # bc no math support yet
30
33
  'test/testcases/span/math/normal.html', # bc no math support yet
31
- ]
34
+ ].compact
32
35
 
33
36
  Dir["#{focus_files(testcase_dir)}.{html,html.19}"].each do |html_file|
34
37
  next if EXCLUDE_HTML_KD_FILES.any? {|f| html_file =~ /#{f}(\.19)?$/}
@@ -10,12 +10,14 @@ describe "kramdown-to-xxx conversion" do
10
10
  'test/testcases/block/15_math/itex2mml.text', # bc no math support yet
11
11
  'test/testcases/block/15_math/normal.text', # bc no math support yet
12
12
  'test/testcases/block/15_math/ritex.text', # bc no math support yet
13
+ 'test/testcases/block/15_math/mathjax_preview.text', # bc no math support yet
14
+ 'test/testcases/block/15_math/mathjax_preview_simple.text', # bc no math support yet
13
15
  'test/testcases/span/math/itex2mml.text', # bc no math support yet
14
16
  'test/testcases/span/math/normal.text', # bc no math support yet
15
17
  'test/testcases/span/math/ritex.text', # bc no math support yet
16
18
  'test/testcases/span/03_codespan/highlighting-rouge.text', # bc no highlight support yet
17
19
  'test/testcases/span/03_codespan/highlighting.text', # bc no highlight support yet
18
- ]
20
+ ].compact
19
21
 
20
22
  Dir["#{focus_files(testcase_dir)}.text"].each do |text_file|
21
23
  next if EXCLUDE_FILES.any? {|f| text_file =~ /#{f}$/}
@@ -24,12 +24,15 @@ describe "text-to-kramdown-to-html conversion" do
24
24
  'test/testcases/span/math/ritex.text', # bc of tidy
25
25
  'test/testcases/block/15_math/itex2mml.text', # bc of tidy
26
26
  'test/testcases/span/math/itex2mml.text', # bc of tidy
27
+ 'test/testcases/span/01_link/link_defs_with_ial.text', # bc of attribute ordering
27
28
 
28
29
  'test/testcases/block/04_header/with_auto_ids.text', # bc no transliteration support yet
29
30
  'test/testcases/block/06_codeblock/highlighting-opts.text', # bc no highlight support yet
30
31
  'test/testcases/block/06_codeblock/highlighting.text', # bc no highlight support yet
31
32
  'test/testcases/block/15_math/gh_128.text', # bc no math support yet
32
33
  'test/testcases/block/15_math/normal.text', # bc no math support yet
34
+ 'test/testcases/block/15_math/mathjax_preview.text', # bc no math support yet
35
+ 'test/testcases/block/15_math/mathjax_preview_simple.text', # bc no math support yet
33
36
  'test/testcases/span/03_codespan/highlighting.text', # bc no highlight support yet
34
37
  'test/testcases/span/math/normal.text', # bc no math support yet
35
38
 
@@ -39,6 +42,7 @@ describe "text-to-kramdown-to-html conversion" do
39
42
  next if EXCLUDE_TEXT_FILES.any? {|f| text_file =~ /#{f}$/}
40
43
  html_file = text_file.sub(/\.text$/, '.html')
41
44
  html_file += '.19' if RUBY_VERSION >= '1.9' && File.exist?(html_file + '.19')
45
+ next unless File.exist?(html_file)
42
46
  opts_file = text_file.sub(/\.text$/, '.options')
43
47
 
44
48
  it "#{short_name(text_file)} --> kramdown --> html" do
@@ -10,7 +10,7 @@
10
10
  # 'test/testcases/span/01_link/image_in_a.text', # bc of image link
11
11
  # 'test/testcases/span/01_link/imagelinks.text', # bc of image links
12
12
  # 'test/testcases/span/04_footnote/markers.text', # bc of footnote in header
13
- # ]
13
+ # ].compact
14
14
  #
15
15
  # Dir["#{focus_files(testcase_dir)}.text"].each do |text_file|
16
16
  # next if EXCLUDE_LATEX_FILES.any? {|f| text_file =~ /#{f}$/}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-kramdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Walker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-25 00:00:00.000000000 Z
12
+ date: 2015-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: motion-strscan
@@ -39,8 +39,8 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.4'
42
- description: A light modification of the kramdown Markdown gem, for use with RubyMotion
43
- on iOS and OS X.
42
+ description: The kramdown parser for Markdown, for use with RubyMotion on iOS and
43
+ OS X.
44
44
  email:
45
45
  - github@digitalmoksha.com
46
46
  - t_leitner@gmx.at
@@ -61,6 +61,7 @@ files:
61
61
  - lib/kramdown/converter/math_engine/ritex.rb
62
62
  - lib/kramdown/converter/pdf.rb
63
63
  - lib/kramdown/converter/remove_html_tags.rb
64
+ - lib/kramdown/converter/syntax_highlighter.rb
64
65
  - lib/kramdown/converter/syntax_highlighter/coderay.rb
65
66
  - lib/kramdown/converter/syntax_highlighter/rouge.rb
66
67
  - lib/kramdown/converter/toc.rb