kramdown 1.17.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTERS +4 -2
  3. data/VERSION +1 -1
  4. data/bin/kramdown +13 -14
  5. data/lib/kramdown.rb +2 -2
  6. data/lib/kramdown/converter.rb +6 -7
  7. data/lib/kramdown/converter/base.rb +18 -29
  8. data/lib/kramdown/converter/hash_ast.rb +4 -4
  9. data/lib/kramdown/converter/html.rb +82 -67
  10. data/lib/kramdown/converter/kramdown.rb +83 -78
  11. data/lib/kramdown/converter/latex.rb +53 -47
  12. data/lib/kramdown/converter/man.rb +22 -25
  13. data/lib/kramdown/converter/math_engine/mathjax.rb +10 -10
  14. data/lib/kramdown/converter/remove_html_tags.rb +2 -2
  15. data/lib/kramdown/converter/syntax_highlighter.rb +2 -2
  16. data/lib/kramdown/converter/syntax_highlighter/minted.rb +2 -2
  17. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +5 -5
  18. data/lib/kramdown/converter/toc.rb +5 -5
  19. data/lib/kramdown/document.rb +9 -11
  20. data/lib/kramdown/element.rb +11 -9
  21. data/lib/kramdown/error.rb +2 -2
  22. data/lib/kramdown/options.rb +258 -384
  23. data/lib/kramdown/parser.rb +2 -3
  24. data/lib/kramdown/parser/base.rb +7 -6
  25. data/lib/kramdown/parser/html.rb +103 -95
  26. data/lib/kramdown/parser/kramdown.rb +32 -36
  27. data/lib/kramdown/parser/kramdown/abbreviation.rb +13 -10
  28. data/lib/kramdown/parser/kramdown/autolink.rb +3 -3
  29. data/lib/kramdown/parser/kramdown/blank_line.rb +2 -2
  30. data/lib/kramdown/parser/kramdown/block_boundary.rb +2 -2
  31. data/lib/kramdown/parser/kramdown/blockquote.rb +4 -5
  32. data/lib/kramdown/parser/kramdown/codeblock.rb +4 -5
  33. data/lib/kramdown/parser/kramdown/codespan.rb +5 -5
  34. data/lib/kramdown/parser/kramdown/emphasis.rb +6 -6
  35. data/lib/kramdown/parser/kramdown/eob.rb +2 -2
  36. data/lib/kramdown/parser/kramdown/escaped_chars.rb +2 -2
  37. data/lib/kramdown/parser/kramdown/extensions.rb +31 -26
  38. data/lib/kramdown/parser/kramdown/footnote.rb +7 -6
  39. data/lib/kramdown/parser/kramdown/header.rb +6 -6
  40. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +3 -3
  41. data/lib/kramdown/parser/kramdown/html.rb +31 -26
  42. data/lib/kramdown/parser/kramdown/html_entity.rb +6 -5
  43. data/lib/kramdown/parser/kramdown/line_break.rb +3 -3
  44. data/lib/kramdown/parser/kramdown/link.rb +13 -11
  45. data/lib/kramdown/parser/kramdown/list.rb +38 -40
  46. data/lib/kramdown/parser/kramdown/math.rb +4 -5
  47. data/lib/kramdown/parser/kramdown/paragraph.rb +5 -5
  48. data/lib/kramdown/parser/kramdown/smart_quotes.rb +23 -23
  49. data/lib/kramdown/parser/kramdown/table.rb +18 -17
  50. data/lib/kramdown/parser/kramdown/typographic_symbol.rb +8 -8
  51. data/lib/kramdown/parser/markdown.rb +9 -8
  52. data/lib/kramdown/utils.rb +5 -6
  53. data/lib/kramdown/utils/configurable.rb +7 -6
  54. data/lib/kramdown/utils/entities.rb +286 -289
  55. data/lib/kramdown/utils/html.rb +10 -12
  56. data/lib/kramdown/utils/lru_cache.rb +3 -2
  57. data/lib/kramdown/utils/string_scanner.rb +2 -3
  58. data/lib/kramdown/utils/unidecoder.rb +8 -6
  59. data/lib/kramdown/version.rb +3 -3
  60. data/man/man1/kramdown.1 +3 -107
  61. data/test/run_tests.rb +6 -6
  62. data/test/test_files.rb +122 -298
  63. data/test/test_location.rb +8 -30
  64. data/test/test_string_scanner_kramdown.rb +6 -9
  65. data/test/testcases/block/06_codeblock/highlighting-opts.html +6 -6
  66. data/test/testcases/block/06_codeblock/highlighting.html +5 -6
  67. data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options +1 -1
  68. data/test/testcases/block/07_horizontal_rule/error.html +2 -2
  69. data/test/testcases/block/09_html/html5_attributes.html +2 -0
  70. data/test/testcases/block/09_html/html5_attributes.text +2 -0
  71. data/test/testcases/block/09_html/html_to_native/typography.html +1 -1
  72. data/test/testcases/block/09_html/simple.html +1 -1
  73. data/test/testcases/block/12_extension/options3.html +7 -6
  74. data/test/testcases/block/12_extension/options3.text +2 -2
  75. data/test/testcases/span/01_link/inline.html +1 -1
  76. data/test/testcases/span/01_link/reference.html +3 -3
  77. data/test/testcases/span/03_codespan/highlighting.html +1 -1
  78. data/test/testcases/span/text_substitutions/entities_as_char.html +1 -1
  79. metadata +5 -234
  80. data/Rakefile +0 -341
  81. data/benchmark/benchmark.rb +0 -43
  82. data/benchmark/benchmark.sh +0 -74
  83. data/benchmark/generate_data.rb +0 -119
  84. data/benchmark/mdbasics.text +0 -306
  85. data/benchmark/mdsyntax.text +0 -888
  86. data/benchmark/testing.sh +0 -12
  87. data/benchmark/timing.sh +0 -10
  88. data/doc/_design.scss +0 -441
  89. data/doc/bg.png +0 -0
  90. data/doc/default.scss +0 -217
  91. data/doc/default.template +0 -62
  92. data/doc/documentation.page +0 -84
  93. data/doc/documentation.template +0 -36
  94. data/doc/index.page +0 -113
  95. data/doc/installation.page +0 -88
  96. data/doc/links.markdown +0 -6
  97. data/doc/metainfo +0 -13
  98. data/doc/news.feed +0 -9
  99. data/doc/news.page +0 -29
  100. data/doc/options.page +0 -49
  101. data/doc/quickref.page +0 -603
  102. data/doc/sidebar.template +0 -22
  103. data/doc/sitemap.sitemap +0 -5
  104. data/doc/syntax.page +0 -1799
  105. data/doc/tests.page +0 -104
  106. data/doc/virtual +0 -14
  107. data/lib/kramdown/converter/math_engine/itex2mml.rb +0 -39
  108. data/lib/kramdown/converter/math_engine/katex.rb +0 -35
  109. data/lib/kramdown/converter/math_engine/mathjaxnode.rb +0 -56
  110. data/lib/kramdown/converter/math_engine/ritex.rb +0 -38
  111. data/lib/kramdown/converter/math_engine/sskatex.rb +0 -97
  112. data/lib/kramdown/converter/pdf.rb +0 -625
  113. data/lib/kramdown/converter/syntax_highlighter/coderay.rb +0 -81
  114. data/lib/kramdown/parser/gfm.rb +0 -188
  115. data/lib/kramdown/utils/ordered_hash.rb +0 -18
  116. data/setup.rb +0 -1585
  117. data/test/testcases/block/07_horizontal_rule/error.html.19 +0 -7
  118. data/test/testcases/block/09_html/html_to_native/typography.html.19 +0 -1
  119. data/test/testcases/block/09_html/simple.html.19 +0 -60
  120. data/test/testcases/block/15_math/itex2mml.html +0 -1
  121. data/test/testcases/block/15_math/itex2mml.options +0 -1
  122. data/test/testcases/block/15_math/itex2mml.text +0 -1
  123. data/test/testcases/block/15_math/katex.html.19 +0 -2
  124. data/test/testcases/block/15_math/katex.options +0 -1
  125. data/test/testcases/block/15_math/katex.text +0 -2
  126. data/test/testcases/block/15_math/mathjaxnode.html.19 +0 -27
  127. data/test/testcases/block/15_math/mathjaxnode.options +0 -1
  128. data/test/testcases/block/15_math/mathjaxnode.text +0 -1
  129. data/test/testcases/block/15_math/mathjaxnode_notexhints.html.19 +0 -23
  130. data/test/testcases/block/15_math/mathjaxnode_notexhints.options +0 -3
  131. data/test/testcases/block/15_math/mathjaxnode_notexhints.text +0 -1
  132. data/test/testcases/block/15_math/mathjaxnode_semantics.html.19 +0 -32
  133. data/test/testcases/block/15_math/mathjaxnode_semantics.options +0 -3
  134. data/test/testcases/block/15_math/mathjaxnode_semantics.text +0 -1
  135. data/test/testcases/block/15_math/ritex.html +0 -1
  136. data/test/testcases/block/15_math/ritex.options +0 -1
  137. data/test/testcases/block/15_math/ritex.text +0 -1
  138. data/test/testcases/block/15_math/sskatex.html.19 +0 -2
  139. data/test/testcases/block/15_math/sskatex.options +0 -1
  140. data/test/testcases/block/15_math/sskatex.text +0 -2
  141. data/test/testcases/span/01_link/inline.html.19 +0 -46
  142. data/test/testcases/span/01_link/reference.html.19 +0 -37
  143. data/test/testcases/span/math/itex2mml.html +0 -1
  144. data/test/testcases/span/math/itex2mml.options +0 -1
  145. data/test/testcases/span/math/itex2mml.text +0 -1
  146. data/test/testcases/span/math/katex.html.19 +0 -1
  147. data/test/testcases/span/math/katex.options +0 -1
  148. data/test/testcases/span/math/katex.text +0 -1
  149. data/test/testcases/span/math/mathjaxnode.html.19 +0 -27
  150. data/test/testcases/span/math/mathjaxnode.options +0 -1
  151. data/test/testcases/span/math/mathjaxnode.text +0 -1
  152. data/test/testcases/span/math/ritex.html +0 -1
  153. data/test/testcases/span/math/ritex.options +0 -1
  154. data/test/testcases/span/math/ritex.text +0 -1
  155. data/test/testcases/span/math/sskatex.html.19 +0 -1
  156. data/test/testcases/span/math/sskatex.options +0 -1
  157. data/test/testcases/span/math/sskatex.text +0 -1
  158. data/test/testcases/span/text_substitutions/entities_as_char.html.19 +0 -1
  159. data/test/testcases_gfm/atx_header.html +0 -3
  160. data/test/testcases_gfm/atx_header.text +0 -3
  161. data/test/testcases_gfm/backticks_disable_highlighting.html +0 -2
  162. data/test/testcases_gfm/backticks_disable_highlighting.options +0 -1
  163. data/test/testcases_gfm/backticks_disable_highlighting.text +0 -3
  164. data/test/testcases_gfm/backticks_syntax.html +0 -20
  165. data/test/testcases_gfm/backticks_syntax.text +0 -19
  166. data/test/testcases_gfm/codeblock_fenced.html +0 -20
  167. data/test/testcases_gfm/codeblock_fenced.options +0 -1
  168. data/test/testcases_gfm/codeblock_fenced.text +0 -21
  169. data/test/testcases_gfm/hard_line_breaks.html +0 -3
  170. data/test/testcases_gfm/hard_line_breaks.text +0 -3
  171. data/test/testcases_gfm/hard_line_breaks_off.html +0 -2
  172. data/test/testcases_gfm/hard_line_breaks_off.options +0 -1
  173. data/test/testcases_gfm/hard_line_breaks_off.text +0 -2
  174. data/test/testcases_gfm/header_ids.html +0 -27
  175. data/test/testcases_gfm/header_ids.html.19 +0 -27
  176. data/test/testcases_gfm/header_ids.options +0 -1
  177. data/test/testcases_gfm/header_ids.text +0 -27
  178. data/test/testcases_gfm/header_ids_with_prefix.html +0 -3
  179. data/test/testcases_gfm/header_ids_with_prefix.options +0 -2
  180. data/test/testcases_gfm/header_ids_with_prefix.text +0 -3
  181. data/test/testcases_gfm/no_typographic.html +0 -3
  182. data/test/testcases_gfm/no_typographic.html.19 +0 -3
  183. data/test/testcases_gfm/no_typographic.options +0 -1
  184. data/test/testcases_gfm/no_typographic.text +0 -3
  185. data/test/testcases_gfm/paragraph_end-disabled.html +0 -31
  186. data/test/testcases_gfm/paragraph_end-disabled.options +0 -1
  187. data/test/testcases_gfm/paragraph_end-disabled.text +0 -27
  188. data/test/testcases_gfm/paragraph_end.html +0 -38
  189. data/test/testcases_gfm/paragraph_end.text +0 -27
  190. data/test/testcases_gfm/strikethrough.html +0 -27
  191. data/test/testcases_gfm/strikethrough.html.19 +0 -27
  192. data/test/testcases_gfm/strikethrough.text +0 -27
  193. data/test/testcases_gfm/task_list.html +0 -40
  194. data/test/testcases_gfm/task_list.text +0 -26
  195. data/test/testcases_gfm/two_para_hard_line_breaks.html +0 -4
  196. data/test/testcases_gfm/two_para_hard_line_breaks.text +0 -4
data/Rakefile DELETED
@@ -1,341 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- # load all optional developer libraries
4
- begin
5
- require 'rubygems'
6
- require 'rubygems/package_task'
7
- rescue LoadError
8
- end
9
-
10
- begin
11
- require 'webgen/page'
12
- rescue LoadError
13
- end
14
-
15
- begin
16
- gem 'rdoc' if RUBY_VERSION >= '1.9'
17
- require 'rdoc/task'
18
- require 'rdoc/rdoc'
19
-
20
- class RDoc::RDoc
21
-
22
- alias :old_parse_files :parse_files
23
-
24
- def parse_files(options)
25
- file_info = old_parse_files(options)
26
- require 'kramdown/options'
27
-
28
- # Add options documentation to Kramdown::Options module
29
- opt_module = @store.all_classes_and_modules.find {|m| m.full_name == 'Kramdown::Options'}
30
- opt_defs = Kramdown::Options.definitions.sort.collect do |n, definition|
31
- desc = definition.desc.split(/\n/).map {|l| " #{l}"}
32
- desc[-2] = []
33
- desc = desc.join("\n")
34
- "[<tt>#{n}</tt> (type: #{definition.type}, default: #{definition.default.inspect})]\n#{desc}\n\n"
35
- end
36
- opt_module.comment.text += "\n== Available Options\n\n" << opt_defs.join("\n\n")
37
-
38
- file_info
39
- end
40
-
41
- end
42
-
43
- rescue LoadError
44
- end
45
-
46
- begin
47
- require 'rcov/rcovtask'
48
- rescue LoadError
49
- end
50
-
51
- require 'fileutils'
52
- require 'rake/clean'
53
- require 'rake/testtask'
54
- require 'rake/packagetask'
55
- require 'erb'
56
-
57
- $:.unshift('lib')
58
- require 'kramdown'
59
-
60
- # End user tasks ################################################################
61
-
62
- task :default => :test
63
-
64
- desc "Install using setup.rb"
65
- task :install do
66
- ruby "setup.rb config"
67
- ruby "setup.rb setup"
68
- ruby "setup.rb install"
69
- end
70
-
71
- task :clobber do
72
- ruby "setup.rb clean"
73
- end
74
-
75
- if defined?(Webgen)
76
- desc "Generate the HTML documentation"
77
- task :htmldoc do
78
- ruby "-Ilib -S webgen"
79
- end
80
- CLOBBER << "htmldoc/"
81
- CLOBBER << "webgen-tmp"
82
- end
83
-
84
- if defined? RDoc::Task
85
- rd = RDoc::Task.new do |rdoc|
86
- rdoc.rdoc_dir = 'htmldoc/rdoc'
87
- rdoc.title = 'kramdown'
88
- rdoc.main = 'lib/kramdown/document.rb'
89
- rdoc.rdoc_files.include('lib')
90
- end
91
- end
92
-
93
- if defined?(Webgen) && defined?(RDoc::Task)
94
- desc "Build the whole user documentation"
95
- task :doc => [:rdoc, 'htmldoc']
96
- end
97
-
98
- tt = Rake::TestTask.new do |test|
99
- test.warning = false
100
- test.libs << 'test'
101
- test.test_files = FileList['test/test_*.rb']
102
- end
103
-
104
- # Release tasks and development tasks ############################################
105
-
106
- namespace :dev do
107
-
108
- SUMMARY = 'kramdown is a fast, pure-Ruby Markdown-superset converter.'
109
- DESCRIPTION = <<EOF
110
- kramdown is yet-another-markdown-parser but fast, pure Ruby,
111
- using a strict syntax definition and supporting several common extensions.
112
- EOF
113
-
114
- begin
115
- REL_PAGE = Webgen::Page.from_data(File.read('doc/news/release_' + Kramdown::VERSION.split('.').join('_') + '.page'))
116
- rescue
117
- puts 'NO RELEASE NOTES/CHANGES FILE'
118
- end
119
-
120
- PKG_FILES = FileList.new([
121
- 'Rakefile',
122
- 'setup.rb',
123
- 'COPYING', 'README.md', 'AUTHORS',
124
- 'VERSION', 'CONTRIBUTERS',
125
- 'bin/*',
126
- 'benchmark/*',
127
- 'lib/**/*.rb',
128
- 'man/man1/kramdown.1',
129
- 'data/**/*',
130
- 'doc/**',
131
- 'test/**/*'
132
- ])
133
-
134
- CLOBBER << "VERSION"
135
- file 'VERSION' do
136
- puts "Generating VERSION file"
137
- File.open('VERSION', 'w+') {|file| file.write(Kramdown::VERSION + "\n")}
138
- end
139
-
140
- CLOBBER << 'CONTRIBUTERS'
141
- file 'CONTRIBUTERS' do
142
- puts "Generating CONTRIBUTERS file"
143
- `echo " Count Name" > CONTRIBUTERS`
144
- `echo "======= ====" >> CONTRIBUTERS`
145
- `git log | grep ^Author: | sed 's/^Author: //' | sort | uniq -c | sort -nr >> CONTRIBUTERS`
146
- end
147
-
148
- CLOBBER << "man/man1/kramdown.1"
149
- file 'man/man1/kramdown.1' => ['man/man1/kramdown.1.erb'] do
150
- puts "Generating kramdown man page"
151
- File.open('man/man1/kramdown.1', 'w+') do |file|
152
- data = ERB.new(File.read('man/man1/kramdown.1.erb')).result(binding)
153
- file.write(Kramdown::Document.new(data).to_man)
154
- end
155
- end
156
-
157
- Rake::PackageTask.new('kramdown', Kramdown::VERSION) do |pkg|
158
- pkg.need_tar = true
159
- pkg.need_zip = true
160
- pkg.package_files = PKG_FILES
161
- end
162
-
163
- if defined? Gem
164
- spec = Gem::Specification.new do |s|
165
-
166
- #### Basic information
167
- s.name = 'kramdown'
168
- s.version = Kramdown::VERSION
169
- s.summary = SUMMARY
170
- s.description = DESCRIPTION
171
- s.license = 'MIT'
172
-
173
- #### Dependencies, requirements and files
174
- s.files = PKG_FILES.to_a
175
-
176
- s.require_path = 'lib'
177
- s.executables = ['kramdown']
178
- s.default_executable = 'kramdown'
179
- s.required_ruby_version = '>= 2.0'
180
- s.add_development_dependency 'minitest', '~> 5.0'
181
- s.add_development_dependency 'coderay', '~> 1.0.0'
182
- s.add_development_dependency 'rouge'
183
- s.add_development_dependency 'stringex', '~> 1.5.1'
184
- s.add_development_dependency 'prawn', '~> 2.0'
185
- s.add_development_dependency 'prawn-table', '~> 0.2.2'
186
- s.add_development_dependency 'ritex', '~> 1.0'
187
- s.add_development_dependency 'itextomml', '~> 1.5'
188
- s.add_development_dependency 'execjs', '~> 2.7'
189
- s.add_development_dependency 'sskatex', '>= 0.9.37'
190
- s.add_development_dependency 'katex', '~> 0.4.3'
191
-
192
- #### Documentation
193
-
194
- s.has_rdoc = true
195
- s.rdoc_options = ['--main', 'lib/kramdown/document.rb']
196
-
197
- #### Author and project details
198
-
199
- s.author = 'Thomas Leitner'
200
- s.email = 't_leitner@gmx.at'
201
- s.homepage = "http://kramdown.gettalong.org"
202
- end
203
-
204
-
205
- task :gemspec => [ 'CONTRIBUTERS', 'VERSION', 'man/man1/kramdown.1'] do
206
- print "Generating Gemspec\n"
207
- contents = spec.to_ruby
208
- File.open("kramdown.gemspec", 'w+') {|f| f.puts(contents)}
209
- end
210
-
211
- Gem::PackageTask.new(spec) do |pkg|
212
- pkg.need_zip = true
213
- pkg.need_tar = true
214
- end
215
-
216
- end
217
-
218
- if defined?(Webgen) && defined?(Gem) && defined?(Rake::RDocTask)
219
- desc 'Release Kramdown version ' + Kramdown::VERSION
220
- task :release => [:clobber, :package, :publish_files, :publish_website]
221
- end
222
-
223
- if defined?(Gem)
224
- desc "Upload the release to Rubygems"
225
- task :publish_files => [:package] do
226
- sh "gem push pkg/kramdown-#{Kramdown::VERSION}.gem"
227
- puts 'done'
228
- end
229
- end
230
-
231
- desc "Upload the website"
232
- task :publish_website => ['doc'] do
233
- puts "Transfer manually!!!"
234
- # sh "rsync -avc --delete --exclude 'MathJax' --exclude 'robots.txt' htmldoc/ gettalong@rubyforge.org:/var/www/gforge-projects/kramdown/"
235
- end
236
-
237
-
238
- if defined? Rcov
239
- Rcov::RcovTask.new do |rcov|
240
- rcov.libs << 'test'
241
- end
242
- end
243
-
244
- CODING_LINE = "# -*- coding: utf-8 -*-\n"
245
- COPYRIGHT=<<EOF
246
- #
247
- #--
248
- # Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
249
- #
250
- # This file is part of kramdown which is licensed under the MIT.
251
- #++
252
- #
253
- EOF
254
-
255
- desc "Insert/Update copyright notice"
256
- task :update_copyright do
257
- inserted = false
258
- Dir["lib/**/*.rb", "test/**/*.rb"].each do |file|
259
- if !File.read(file).start_with?(CODING_LINE + COPYRIGHT)
260
- inserted = true
261
- puts "Updating file #{file}"
262
- old = File.read(file)
263
- if !old.gsub!(/\A#{Regexp.escape(CODING_LINE)}#\n#--.*?\n#\+\+\n#\n/m, CODING_LINE + COPYRIGHT)
264
- old.gsub!(/\A(#{Regexp.escape(CODING_LINE)})?/, CODING_LINE + COPYRIGHT + "\n")
265
- end
266
- File.open(file, 'w+') {|f| f.puts(old)}
267
- end
268
- end
269
- puts "Look through the above mentioned files and correct all problems" if inserted
270
- end
271
-
272
- desc "Check for MathjaxNode availability"
273
- task :test_mathjaxnode_deps do
274
- html = %x{echo '$$a$$' | \
275
- #{RbConfig.ruby} -Ilib bin/kramdown --no-config-file --math-engine mathjaxnode}
276
- raise (<<MJC) unless $?.success?
277
- Some requirement by the mathjax-node-cli package has not been satisfied.
278
- Cf. the above error messages.
279
- MJC
280
- raise (<<MJN) unless %r{\A<math xmlns="http://www.w3.org/\d+/Math/MathML".*</math>\Z}m === html
281
- The MathjaxNode engine is not available. Try "npm install mathjax-node-cli".
282
- MJN
283
- puts "MathjaxNode is available, and its default configuration works."
284
- end
285
-
286
- desc "Update kramdown MathjaxNode test reference outputs"
287
- task update_mathjaxnode_tests: [:test_mathjaxnode_deps] do
288
- # Not framed in terms of rake file tasks to prevent accidental overwrites.
289
- Dir['test/testcases/**/mathjaxnode*.text'].each do |f|
290
- stem = f[0..-6] # Remove .text
291
- ruby "-Ilib bin/kramdown --config-file #{stem}.options #{f} >#{stem}.html.19"
292
- end
293
- end
294
-
295
- desc "Check for SsKaTeX availability"
296
- task :test_sskatex_deps do
297
- katexjs = 'katex/katex.min.js'
298
- raise (<<TKJ) unless File.exists? katexjs
299
- Cannot find file '#{katexjs}'.
300
- You need to download KaTeX e.g. from https://github.com/Khan/KaTeX/releases/
301
- and extract at least '#{katexjs}'.
302
- Alternatively, if you have a copy of KaTeX unpacked somewhere else,
303
- you can create a symbolic link 'katex' pointing to that KaTeX directory.
304
- TKJ
305
- html = %x{echo '$$a$$' | \
306
- #{RbConfig.ruby} -Ilib bin/kramdown --no-config-file --math-engine sskatex}
307
- raise (<<KTC) unless $?.success?
308
- Some requirement by SsKaTeX or the employed JS engine has not been satisfied.
309
- Cf. the above error messages.
310
- KTC
311
- raise (<<XJS) unless / class="katex"/ === html
312
- Some static dependency of SsKaTeX, probably the 'sskatex' or the 'execjs' gem,
313
- is not available.
314
- If you 'gem install sskatex', also make sure that some JS engine is available,
315
- e.g. by installing one of the gems 'duktape', 'therubyracer', or 'therubyrhino'.
316
- XJS
317
- puts "SsKaTeX is available, and its default configuration works."
318
- end
319
-
320
- desc "Update kramdown SsKaTeX test reference outputs"
321
- task update_sskatex_tests: [:test_sskatex_deps] do
322
- # Not framed in terms of rake file tasks to prevent accidental overwrites.
323
- Dir['test/testcases/**/sskatex*.text'].each do |f|
324
- stem = f[0..-6] # Remove .text
325
- ruby "-Ilib bin/kramdown --config-file #{stem}.options #{f} >#{stem}.html.19"
326
- end
327
- end
328
-
329
- desc "Update kramdown KaTeX test reference outputs"
330
- task :update_katex_tests do
331
- # Not framed in terms of rake file tasks to prevent accidental overwrites.
332
- Dir['test/testcases/**/katex*.text'].each do |f|
333
- stem = f[0..-6] # Remove .text
334
- ruby "-Ilib bin/kramdown --config-file #{stem}.options #{f} >#{stem}.html.19"
335
- end
336
- end
337
- end
338
-
339
- task :gemspec => ['dev:gemspec']
340
-
341
- task :clobber => ['dev:clobber']
@@ -1,43 +0,0 @@
1
- require 'benchmark'
2
- require 'stringio'
3
-
4
- require 'kramdown'
5
- require 'bluecloth'
6
- require 'maruku'
7
- require 'maruku/version'
8
- require 'rdiscount'
9
- require 'bluefeather'
10
- require 'redcarpet'
11
-
12
- module MaRuKu::Errors
13
- def tell_user(s)
14
- end
15
- end
16
-
17
-
18
- RUNS=20
19
-
20
- FILES=['mdsyntax.text', 'mdbasics.text']
21
-
22
- puts "Running tests on #{Time.now.strftime("%Y-%m-%d")} under #{RUBY_DESCRIPTION}"
23
-
24
- FILES.each do |file|
25
- data = File.read(File.join(File.dirname(__FILE__), file))
26
- puts
27
- puts "Test using file #{file} and #{RUNS} runs"
28
- results = Benchmark.bmbm do |b|
29
- b.report("kramdown #{Kramdown::VERSION}") { RUNS.times { Kramdown::Document.new(data).to_html } }
30
- b.report("Maruku #{MaRuKu::Version}") { RUNS.times { Maruku.new(data, :on_error => :ignore).to_html } }
31
- b.report("BlueFeather #{BlueFeather::VERSION}") { RUNS.times { BlueFeather.parse(data) } }
32
- b.report("BlueCloth #{BlueCloth::VERSION}") { RUNS.times { BlueCloth.new(data).to_html } }
33
- b.report("RDiscount #{RDiscount::VERSION}") { RUNS.times { RDiscount.new(data).to_html } }
34
- b.report("redcarpet #{Redcarpet::VERSION}") { RUNS.times { Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(data) } }
35
- end
36
-
37
- puts
38
- puts "Real time of X divided by real time of kramdown"
39
- kd = results.shift.real
40
- %w[Maruku BlueFeather BlueCloth RDiscount redcarpet].each do |name|
41
- puts name.ljust(19) << (results.shift.real/kd).round(4).to_s
42
- end
43
- end
@@ -1,74 +0,0 @@
1
- #!/bin/bash
2
-
3
- source ~/.profile
4
-
5
- RUBY_VERSIONS=`rvm list strings | sort`
6
- KD_VERSIONS="`git tag | sort -V` master"
7
- OTHERS=false
8
- AVERAGE=1
9
- MASTER_AS=master
10
-
11
- while getopts "r:k:om:a:" optname; do
12
- case "$optname" in
13
- "r")
14
- RUBY_VERSIONS="$OPTARG"
15
- ;;
16
- "k")
17
- KD_VERSIONS="$OPTARG"
18
- ;;
19
- "o")
20
- OTHERS=true
21
- ;;
22
- "m")
23
- MASTER_AS="$OPTARG"
24
- ;;
25
- "a")
26
- AVERAGE="$OPTARG"
27
- ;;
28
- "?")
29
- echo "Unknown option $OPTARG"
30
- exit 1
31
- ;;
32
- ":")
33
- echo "No argument value for option $OPTARG"
34
- exit 1
35
- ;;
36
- *)
37
- echo "Unknown error while processing options"
38
- exit 1
39
- ;;
40
- esac
41
- done
42
-
43
- TMPDIR=/tmp/kramdown-benchmark
44
-
45
- rm -rf $TMPDIR
46
- mkdir -p $TMPDIR
47
- cp benchmark/md* $TMPDIR
48
- cp benchmark/generate_data.rb $TMPDIR
49
- git clone .git ${TMPDIR}/kramdown
50
- cd ${TMPDIR}/kramdown
51
-
52
- for RUBY_VERSION in $RUBY_VERSIONS; do
53
- rvm use $RUBY_VERSION
54
- echo "Creating benchmark data for $(ruby -v)"
55
-
56
- for KD_VERSION in $KD_VERSIONS; do
57
- echo "Using kramdown version $KD_VERSION"
58
- git co $KD_VERSION 2>/dev/null
59
- if [ -z $MASTER_AS -o $KD_VERSION != master ]; then
60
- VNUM=${KD_VERSION}
61
- else
62
- VNUM=$MASTER_AS
63
- fi
64
- ruby -I${TMPDIR}/kramdown/lib ../generate_data.rb -k ${VNUM} -a ${AVERAGE} >/dev/null
65
- done
66
-
67
- if [ $OTHERS = "true" ]; then
68
- ruby -rubygems -I${TMPDIR}/kramdown/lib ../generate_data.rb -o >/dev/null
69
- fi
70
- done
71
-
72
- cd ${TMPDIR}
73
- rvm default
74
- ruby generate_data.rb -g