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.
- checksums.yaml +4 -4
- data/CONTRIBUTERS +4 -2
- data/VERSION +1 -1
- data/bin/kramdown +13 -14
- data/lib/kramdown.rb +2 -2
- data/lib/kramdown/converter.rb +6 -7
- data/lib/kramdown/converter/base.rb +18 -29
- data/lib/kramdown/converter/hash_ast.rb +4 -4
- data/lib/kramdown/converter/html.rb +82 -67
- data/lib/kramdown/converter/kramdown.rb +83 -78
- data/lib/kramdown/converter/latex.rb +53 -47
- data/lib/kramdown/converter/man.rb +22 -25
- data/lib/kramdown/converter/math_engine/mathjax.rb +10 -10
- data/lib/kramdown/converter/remove_html_tags.rb +2 -2
- data/lib/kramdown/converter/syntax_highlighter.rb +2 -2
- data/lib/kramdown/converter/syntax_highlighter/minted.rb +2 -2
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +5 -5
- data/lib/kramdown/converter/toc.rb +5 -5
- data/lib/kramdown/document.rb +9 -11
- data/lib/kramdown/element.rb +11 -9
- data/lib/kramdown/error.rb +2 -2
- data/lib/kramdown/options.rb +258 -384
- data/lib/kramdown/parser.rb +2 -3
- data/lib/kramdown/parser/base.rb +7 -6
- data/lib/kramdown/parser/html.rb +103 -95
- data/lib/kramdown/parser/kramdown.rb +32 -36
- data/lib/kramdown/parser/kramdown/abbreviation.rb +13 -10
- data/lib/kramdown/parser/kramdown/autolink.rb +3 -3
- data/lib/kramdown/parser/kramdown/blank_line.rb +2 -2
- data/lib/kramdown/parser/kramdown/block_boundary.rb +2 -2
- data/lib/kramdown/parser/kramdown/blockquote.rb +4 -5
- data/lib/kramdown/parser/kramdown/codeblock.rb +4 -5
- data/lib/kramdown/parser/kramdown/codespan.rb +5 -5
- data/lib/kramdown/parser/kramdown/emphasis.rb +6 -6
- data/lib/kramdown/parser/kramdown/eob.rb +2 -2
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +2 -2
- data/lib/kramdown/parser/kramdown/extensions.rb +31 -26
- data/lib/kramdown/parser/kramdown/footnote.rb +7 -6
- data/lib/kramdown/parser/kramdown/header.rb +6 -6
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +3 -3
- data/lib/kramdown/parser/kramdown/html.rb +31 -26
- data/lib/kramdown/parser/kramdown/html_entity.rb +6 -5
- data/lib/kramdown/parser/kramdown/line_break.rb +3 -3
- data/lib/kramdown/parser/kramdown/link.rb +13 -11
- data/lib/kramdown/parser/kramdown/list.rb +38 -40
- data/lib/kramdown/parser/kramdown/math.rb +4 -5
- data/lib/kramdown/parser/kramdown/paragraph.rb +5 -5
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +23 -23
- data/lib/kramdown/parser/kramdown/table.rb +18 -17
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +8 -8
- data/lib/kramdown/parser/markdown.rb +9 -8
- data/lib/kramdown/utils.rb +5 -6
- data/lib/kramdown/utils/configurable.rb +7 -6
- data/lib/kramdown/utils/entities.rb +286 -289
- data/lib/kramdown/utils/html.rb +10 -12
- data/lib/kramdown/utils/lru_cache.rb +3 -2
- data/lib/kramdown/utils/string_scanner.rb +2 -3
- data/lib/kramdown/utils/unidecoder.rb +8 -6
- data/lib/kramdown/version.rb +3 -3
- data/man/man1/kramdown.1 +3 -107
- data/test/run_tests.rb +6 -6
- data/test/test_files.rb +122 -298
- data/test/test_location.rb +8 -30
- data/test/test_string_scanner_kramdown.rb +6 -9
- data/test/testcases/block/06_codeblock/highlighting-opts.html +6 -6
- data/test/testcases/block/06_codeblock/highlighting.html +5 -6
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options +1 -1
- data/test/testcases/block/07_horizontal_rule/error.html +2 -2
- data/test/testcases/block/09_html/html5_attributes.html +2 -0
- data/test/testcases/block/09_html/html5_attributes.text +2 -0
- data/test/testcases/block/09_html/html_to_native/typography.html +1 -1
- data/test/testcases/block/09_html/simple.html +1 -1
- data/test/testcases/block/12_extension/options3.html +7 -6
- data/test/testcases/block/12_extension/options3.text +2 -2
- data/test/testcases/span/01_link/inline.html +1 -1
- data/test/testcases/span/01_link/reference.html +3 -3
- data/test/testcases/span/03_codespan/highlighting.html +1 -1
- data/test/testcases/span/text_substitutions/entities_as_char.html +1 -1
- metadata +5 -234
- data/Rakefile +0 -341
- data/benchmark/benchmark.rb +0 -43
- data/benchmark/benchmark.sh +0 -74
- data/benchmark/generate_data.rb +0 -119
- data/benchmark/mdbasics.text +0 -306
- data/benchmark/mdsyntax.text +0 -888
- data/benchmark/testing.sh +0 -12
- data/benchmark/timing.sh +0 -10
- data/doc/_design.scss +0 -441
- data/doc/bg.png +0 -0
- data/doc/default.scss +0 -217
- data/doc/default.template +0 -62
- data/doc/documentation.page +0 -84
- data/doc/documentation.template +0 -36
- data/doc/index.page +0 -113
- data/doc/installation.page +0 -88
- data/doc/links.markdown +0 -6
- data/doc/metainfo +0 -13
- data/doc/news.feed +0 -9
- data/doc/news.page +0 -29
- data/doc/options.page +0 -49
- data/doc/quickref.page +0 -603
- data/doc/sidebar.template +0 -22
- data/doc/sitemap.sitemap +0 -5
- data/doc/syntax.page +0 -1799
- data/doc/tests.page +0 -104
- data/doc/virtual +0 -14
- data/lib/kramdown/converter/math_engine/itex2mml.rb +0 -39
- data/lib/kramdown/converter/math_engine/katex.rb +0 -35
- data/lib/kramdown/converter/math_engine/mathjaxnode.rb +0 -56
- data/lib/kramdown/converter/math_engine/ritex.rb +0 -38
- data/lib/kramdown/converter/math_engine/sskatex.rb +0 -97
- data/lib/kramdown/converter/pdf.rb +0 -625
- data/lib/kramdown/converter/syntax_highlighter/coderay.rb +0 -81
- data/lib/kramdown/parser/gfm.rb +0 -188
- data/lib/kramdown/utils/ordered_hash.rb +0 -18
- data/setup.rb +0 -1585
- data/test/testcases/block/07_horizontal_rule/error.html.19 +0 -7
- data/test/testcases/block/09_html/html_to_native/typography.html.19 +0 -1
- data/test/testcases/block/09_html/simple.html.19 +0 -60
- data/test/testcases/block/15_math/itex2mml.html +0 -1
- data/test/testcases/block/15_math/itex2mml.options +0 -1
- data/test/testcases/block/15_math/itex2mml.text +0 -1
- data/test/testcases/block/15_math/katex.html.19 +0 -2
- data/test/testcases/block/15_math/katex.options +0 -1
- data/test/testcases/block/15_math/katex.text +0 -2
- data/test/testcases/block/15_math/mathjaxnode.html.19 +0 -27
- data/test/testcases/block/15_math/mathjaxnode.options +0 -1
- data/test/testcases/block/15_math/mathjaxnode.text +0 -1
- data/test/testcases/block/15_math/mathjaxnode_notexhints.html.19 +0 -23
- data/test/testcases/block/15_math/mathjaxnode_notexhints.options +0 -3
- data/test/testcases/block/15_math/mathjaxnode_notexhints.text +0 -1
- data/test/testcases/block/15_math/mathjaxnode_semantics.html.19 +0 -32
- data/test/testcases/block/15_math/mathjaxnode_semantics.options +0 -3
- data/test/testcases/block/15_math/mathjaxnode_semantics.text +0 -1
- data/test/testcases/block/15_math/ritex.html +0 -1
- data/test/testcases/block/15_math/ritex.options +0 -1
- data/test/testcases/block/15_math/ritex.text +0 -1
- data/test/testcases/block/15_math/sskatex.html.19 +0 -2
- data/test/testcases/block/15_math/sskatex.options +0 -1
- data/test/testcases/block/15_math/sskatex.text +0 -2
- data/test/testcases/span/01_link/inline.html.19 +0 -46
- data/test/testcases/span/01_link/reference.html.19 +0 -37
- data/test/testcases/span/math/itex2mml.html +0 -1
- data/test/testcases/span/math/itex2mml.options +0 -1
- data/test/testcases/span/math/itex2mml.text +0 -1
- data/test/testcases/span/math/katex.html.19 +0 -1
- data/test/testcases/span/math/katex.options +0 -1
- data/test/testcases/span/math/katex.text +0 -1
- data/test/testcases/span/math/mathjaxnode.html.19 +0 -27
- data/test/testcases/span/math/mathjaxnode.options +0 -1
- data/test/testcases/span/math/mathjaxnode.text +0 -1
- data/test/testcases/span/math/ritex.html +0 -1
- data/test/testcases/span/math/ritex.options +0 -1
- data/test/testcases/span/math/ritex.text +0 -1
- data/test/testcases/span/math/sskatex.html.19 +0 -1
- data/test/testcases/span/math/sskatex.options +0 -1
- data/test/testcases/span/math/sskatex.text +0 -1
- data/test/testcases/span/text_substitutions/entities_as_char.html.19 +0 -1
- data/test/testcases_gfm/atx_header.html +0 -3
- data/test/testcases_gfm/atx_header.text +0 -3
- data/test/testcases_gfm/backticks_disable_highlighting.html +0 -2
- data/test/testcases_gfm/backticks_disable_highlighting.options +0 -1
- data/test/testcases_gfm/backticks_disable_highlighting.text +0 -3
- data/test/testcases_gfm/backticks_syntax.html +0 -20
- data/test/testcases_gfm/backticks_syntax.text +0 -19
- data/test/testcases_gfm/codeblock_fenced.html +0 -20
- data/test/testcases_gfm/codeblock_fenced.options +0 -1
- data/test/testcases_gfm/codeblock_fenced.text +0 -21
- data/test/testcases_gfm/hard_line_breaks.html +0 -3
- data/test/testcases_gfm/hard_line_breaks.text +0 -3
- data/test/testcases_gfm/hard_line_breaks_off.html +0 -2
- data/test/testcases_gfm/hard_line_breaks_off.options +0 -1
- data/test/testcases_gfm/hard_line_breaks_off.text +0 -2
- data/test/testcases_gfm/header_ids.html +0 -27
- data/test/testcases_gfm/header_ids.html.19 +0 -27
- data/test/testcases_gfm/header_ids.options +0 -1
- data/test/testcases_gfm/header_ids.text +0 -27
- data/test/testcases_gfm/header_ids_with_prefix.html +0 -3
- data/test/testcases_gfm/header_ids_with_prefix.options +0 -2
- data/test/testcases_gfm/header_ids_with_prefix.text +0 -3
- data/test/testcases_gfm/no_typographic.html +0 -3
- data/test/testcases_gfm/no_typographic.html.19 +0 -3
- data/test/testcases_gfm/no_typographic.options +0 -1
- data/test/testcases_gfm/no_typographic.text +0 -3
- data/test/testcases_gfm/paragraph_end-disabled.html +0 -31
- data/test/testcases_gfm/paragraph_end-disabled.options +0 -1
- data/test/testcases_gfm/paragraph_end-disabled.text +0 -27
- data/test/testcases_gfm/paragraph_end.html +0 -38
- data/test/testcases_gfm/paragraph_end.text +0 -27
- data/test/testcases_gfm/strikethrough.html +0 -27
- data/test/testcases_gfm/strikethrough.html.19 +0 -27
- data/test/testcases_gfm/strikethrough.text +0 -27
- data/test/testcases_gfm/task_list.html +0 -40
- data/test/testcases_gfm/task_list.text +0 -26
- data/test/testcases_gfm/two_para_hard_line_breaks.html +0 -4
- 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']
|
data/benchmark/benchmark.rb
DELETED
@@ -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
|
data/benchmark/benchmark.sh
DELETED
@@ -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
|