kramdown 0.1.0

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 (201) hide show
  1. data/AUTHORS +1 -0
  2. data/COPYING +24 -0
  3. data/ChangeLog +1416 -0
  4. data/GPL +674 -0
  5. data/README +20 -0
  6. data/Rakefile +300 -0
  7. data/VERSION +1 -0
  8. data/benchmark/benchmark.rb +33 -0
  9. data/benchmark/mdbasics.text +306 -0
  10. data/benchmark/mdsyntax.text +888 -0
  11. data/benchmark/testing.sh +9 -0
  12. data/benchmark/timing.sh +10 -0
  13. data/bin/kramdown +26 -0
  14. data/doc/default.css +293 -0
  15. data/doc/default.template +78 -0
  16. data/doc/index.page +89 -0
  17. data/doc/installation.page +90 -0
  18. data/doc/news.feed +10 -0
  19. data/doc/news.page +27 -0
  20. data/doc/quickref.page +474 -0
  21. data/doc/syntax.page +1089 -0
  22. data/doc/tests.page +44 -0
  23. data/doc/virtual +2 -0
  24. data/lib/kramdown.rb +23 -0
  25. data/lib/kramdown/converter.rb +215 -0
  26. data/lib/kramdown/document.rb +150 -0
  27. data/lib/kramdown/error.rb +27 -0
  28. data/lib/kramdown/extension.rb +73 -0
  29. data/lib/kramdown/parser.rb +1056 -0
  30. data/lib/kramdown/parser/registry.rb +62 -0
  31. data/setup.rb +1585 -0
  32. data/test/run_tests.rb +58 -0
  33. data/test/test_files.rb +39 -0
  34. data/test/testcases/block/01_blank_line/spaces.html +1 -0
  35. data/test/testcases/block/01_blank_line/spaces.text +3 -0
  36. data/test/testcases/block/01_blank_line/tabs.html +1 -0
  37. data/test/testcases/block/01_blank_line/tabs.text +6 -0
  38. data/test/testcases/block/02_eob/beginning.html +1 -0
  39. data/test/testcases/block/02_eob/beginning.text +3 -0
  40. data/test/testcases/block/02_eob/end.html +1 -0
  41. data/test/testcases/block/02_eob/end.text +3 -0
  42. data/test/testcases/block/02_eob/middle.html +1 -0
  43. data/test/testcases/block/02_eob/middle.text +5 -0
  44. data/test/testcases/block/03_paragraph/indented.html +18 -0
  45. data/test/testcases/block/03_paragraph/indented.text +19 -0
  46. data/test/testcases/block/03_paragraph/no_newline_at_end.html +5 -0
  47. data/test/testcases/block/03_paragraph/no_newline_at_end.text +5 -0
  48. data/test/testcases/block/03_paragraph/one_para.html +1 -0
  49. data/test/testcases/block/03_paragraph/one_para.text +1 -0
  50. data/test/testcases/block/03_paragraph/two_para.html +4 -0
  51. data/test/testcases/block/03_paragraph/two_para.text +4 -0
  52. data/test/testcases/block/04_header/atx_header.html +26 -0
  53. data/test/testcases/block/04_header/atx_header.text +24 -0
  54. data/test/testcases/block/04_header/atx_header_no_newline_at_end.html +1 -0
  55. data/test/testcases/block/04_header/atx_header_no_newline_at_end.text +1 -0
  56. data/test/testcases/block/04_header/setext_header.html +25 -0
  57. data/test/testcases/block/04_header/setext_header.text +27 -0
  58. data/test/testcases/block/04_header/setext_header_no_newline_at_end.html +1 -0
  59. data/test/testcases/block/04_header/setext_header_no_newline_at_end.text +2 -0
  60. data/test/testcases/block/04_header/with_auto_ids.html +17 -0
  61. data/test/testcases/block/04_header/with_auto_ids.options +1 -0
  62. data/test/testcases/block/04_header/with_auto_ids.text +19 -0
  63. data/test/testcases/block/05_blockquote/indented.html +25 -0
  64. data/test/testcases/block/05_blockquote/indented.text +14 -0
  65. data/test/testcases/block/05_blockquote/nested.html +9 -0
  66. data/test/testcases/block/05_blockquote/nested.text +5 -0
  67. data/test/testcases/block/05_blockquote/no_newline_at_end.html +4 -0
  68. data/test/testcases/block/05_blockquote/no_newline_at_end.text +2 -0
  69. data/test/testcases/block/05_blockquote/only_first_quoted.html +8 -0
  70. data/test/testcases/block/05_blockquote/only_first_quoted.text +4 -0
  71. data/test/testcases/block/05_blockquote/with_code_blocks.html +15 -0
  72. data/test/testcases/block/05_blockquote/with_code_blocks.text +11 -0
  73. data/test/testcases/block/06_codeblock/error.html +4 -0
  74. data/test/testcases/block/06_codeblock/error.text +4 -0
  75. data/test/testcases/block/06_codeblock/no_newline_at_end.html +2 -0
  76. data/test/testcases/block/06_codeblock/no_newline_at_end.text +1 -0
  77. data/test/testcases/block/06_codeblock/normal.html +13 -0
  78. data/test/testcases/block/06_codeblock/normal.text +10 -0
  79. data/test/testcases/block/06_codeblock/tilde_syntax.html +7 -0
  80. data/test/testcases/block/06_codeblock/tilde_syntax.text +9 -0
  81. data/test/testcases/block/06_codeblock/whitespace.html +3 -0
  82. data/test/testcases/block/06_codeblock/whitespace.text +3 -0
  83. data/test/testcases/block/06_codeblock/with_blank_line.html +13 -0
  84. data/test/testcases/block/06_codeblock/with_blank_line.text +11 -0
  85. data/test/testcases/block/06_codeblock/with_eob_marker.html +6 -0
  86. data/test/testcases/block/06_codeblock/with_eob_marker.text +5 -0
  87. data/test/testcases/block/07_horizontal_rule/error.html +7 -0
  88. data/test/testcases/block/07_horizontal_rule/error.text +7 -0
  89. data/test/testcases/block/07_horizontal_rule/normal.html +19 -0
  90. data/test/testcases/block/07_horizontal_rule/normal.text +19 -0
  91. data/test/testcases/block/08_list/escaping.html +17 -0
  92. data/test/testcases/block/08_list/escaping.text +17 -0
  93. data/test/testcases/block/08_list/list_and_hr.html +9 -0
  94. data/test/testcases/block/08_list/list_and_hr.text +5 -0
  95. data/test/testcases/block/08_list/list_and_others.html +38 -0
  96. data/test/testcases/block/08_list/list_and_others.text +25 -0
  97. data/test/testcases/block/08_list/mixed.html +111 -0
  98. data/test/testcases/block/08_list/mixed.text +66 -0
  99. data/test/testcases/block/08_list/nested.html +17 -0
  100. data/test/testcases/block/08_list/nested.text +7 -0
  101. data/test/testcases/block/08_list/other_first_element.html +39 -0
  102. data/test/testcases/block/08_list/other_first_element.text +18 -0
  103. data/test/testcases/block/08_list/simple_ol.html +19 -0
  104. data/test/testcases/block/08_list/simple_ol.text +13 -0
  105. data/test/testcases/block/08_list/simple_ul.html +61 -0
  106. data/test/testcases/block/08_list/simple_ul.text +43 -0
  107. data/test/testcases/block/08_list/single_item.html +3 -0
  108. data/test/testcases/block/08_list/single_item.text +1 -0
  109. data/test/testcases/block/08_list/special_cases.html +29 -0
  110. data/test/testcases/block/08_list/special_cases.text +19 -0
  111. data/test/testcases/block/09_html/auto_parse_block_html.html +17 -0
  112. data/test/testcases/block/09_html/auto_parse_block_html.options +1 -0
  113. data/test/testcases/block/09_html/auto_parse_block_html.text +14 -0
  114. data/test/testcases/block/09_html/comment.html +12 -0
  115. data/test/testcases/block/09_html/comment.text +12 -0
  116. data/test/testcases/block/09_html/filtered_html.html +1 -0
  117. data/test/testcases/block/09_html/filtered_html.options +1 -0
  118. data/test/testcases/block/09_html/filtered_html.text +1 -0
  119. data/test/testcases/block/09_html/html_and_codeblocks.html +15 -0
  120. data/test/testcases/block/09_html/html_and_codeblocks.options +1 -0
  121. data/test/testcases/block/09_html/html_and_codeblocks.text +13 -0
  122. data/test/testcases/block/09_html/invalid_html_1.html +5 -0
  123. data/test/testcases/block/09_html/invalid_html_1.text +5 -0
  124. data/test/testcases/block/09_html/invalid_html_2.html +6 -0
  125. data/test/testcases/block/09_html/invalid_html_2.text +5 -0
  126. data/test/testcases/block/09_html/parse_as_raw.html +26 -0
  127. data/test/testcases/block/09_html/parse_as_raw.text +16 -0
  128. data/test/testcases/block/09_html/parse_as_span.html +12 -0
  129. data/test/testcases/block/09_html/parse_as_span.text +7 -0
  130. data/test/testcases/block/09_html/processing_instruction.html +12 -0
  131. data/test/testcases/block/09_html/processing_instruction.text +12 -0
  132. data/test/testcases/block/09_html/simple.html +78 -0
  133. data/test/testcases/block/09_html/simple.text +56 -0
  134. data/test/testcases/block/10_ald/simple.html +2 -0
  135. data/test/testcases/block/10_ald/simple.text +8 -0
  136. data/test/testcases/block/11_ial/simple.html +17 -0
  137. data/test/testcases/block/11_ial/simple.text +25 -0
  138. data/test/testcases/block/12_extension/comment.html +5 -0
  139. data/test/testcases/block/12_extension/comment.text +11 -0
  140. data/test/testcases/block/12_extension/ignored.html +6 -0
  141. data/test/testcases/block/12_extension/ignored.text +11 -0
  142. data/test/testcases/block/12_extension/kdoptions.html +15 -0
  143. data/test/testcases/block/12_extension/kdoptions.text +18 -0
  144. data/test/testcases/block/12_extension/kdoptions2.html +10 -0
  145. data/test/testcases/block/12_extension/kdoptions2.text +5 -0
  146. data/test/testcases/block/12_extension/nokramdown.html +6 -0
  147. data/test/testcases/block/12_extension/nokramdown.text +11 -0
  148. data/test/testcases/span/01_link/empty.html +3 -0
  149. data/test/testcases/span/01_link/empty.text +3 -0
  150. data/test/testcases/span/01_link/image_in_a.html +5 -0
  151. data/test/testcases/span/01_link/image_in_a.text +5 -0
  152. data/test/testcases/span/01_link/imagelinks.html +12 -0
  153. data/test/testcases/span/01_link/imagelinks.text +14 -0
  154. data/test/testcases/span/01_link/inline.html +40 -0
  155. data/test/testcases/span/01_link/inline.text +42 -0
  156. data/test/testcases/span/01_link/link_defs.html +8 -0
  157. data/test/testcases/span/01_link/link_defs.text +22 -0
  158. data/test/testcases/span/01_link/links_with_angle_brackets.html +3 -0
  159. data/test/testcases/span/01_link/links_with_angle_brackets.text +3 -0
  160. data/test/testcases/span/01_link/reference.html +32 -0
  161. data/test/testcases/span/01_link/reference.text +42 -0
  162. data/test/testcases/span/02_emphasis/empty.html +3 -0
  163. data/test/testcases/span/02_emphasis/empty.text +3 -0
  164. data/test/testcases/span/02_emphasis/errors.html +9 -0
  165. data/test/testcases/span/02_emphasis/errors.text +9 -0
  166. data/test/testcases/span/02_emphasis/nesting.html +34 -0
  167. data/test/testcases/span/02_emphasis/nesting.text +30 -0
  168. data/test/testcases/span/02_emphasis/normal.html +42 -0
  169. data/test/testcases/span/02_emphasis/normal.text +42 -0
  170. data/test/testcases/span/03_codespan/empty.html +5 -0
  171. data/test/testcases/span/03_codespan/empty.text +5 -0
  172. data/test/testcases/span/03_codespan/errors.html +1 -0
  173. data/test/testcases/span/03_codespan/errors.text +1 -0
  174. data/test/testcases/span/03_codespan/normal.html +16 -0
  175. data/test/testcases/span/03_codespan/normal.text +16 -0
  176. data/test/testcases/span/04_footnote/definitions.html +14 -0
  177. data/test/testcases/span/04_footnote/definitions.text +18 -0
  178. data/test/testcases/span/04_footnote/footnote_nr.html +12 -0
  179. data/test/testcases/span/04_footnote/footnote_nr.options +1 -0
  180. data/test/testcases/span/04_footnote/footnote_nr.text +4 -0
  181. data/test/testcases/span/04_footnote/markers.html +46 -0
  182. data/test/testcases/span/04_footnote/markers.text +26 -0
  183. data/test/testcases/span/05_html/normal.html +17 -0
  184. data/test/testcases/span/05_html/normal.text +17 -0
  185. data/test/testcases/span/autolinks/url_links.html +9 -0
  186. data/test/testcases/span/autolinks/url_links.text +9 -0
  187. data/test/testcases/span/escaped_chars/normal.html +33 -0
  188. data/test/testcases/span/escaped_chars/normal.text +33 -0
  189. data/test/testcases/span/ial/simple.html +5 -0
  190. data/test/testcases/span/ial/simple.text +5 -0
  191. data/test/testcases/span/line_breaks/normal.html +11 -0
  192. data/test/testcases/span/line_breaks/normal.text +11 -0
  193. data/test/testcases/span/text_substitutions/entities.html +4 -0
  194. data/test/testcases/span/text_substitutions/entities.text +4 -0
  195. data/test/testcases/span/text_substitutions/greaterthan.html +1 -0
  196. data/test/testcases/span/text_substitutions/greaterthan.text +1 -0
  197. data/test/testcases/span/text_substitutions/lowerthan.html +1 -0
  198. data/test/testcases/span/text_substitutions/lowerthan.text +1 -0
  199. data/test/testcases/span/text_substitutions/typography.html +3 -0
  200. data/test/testcases/span/text_substitutions/typography.text +3 -0
  201. metadata +259 -0
data/README ADDED
@@ -0,0 +1,20 @@
1
+ # kramdown
2
+
3
+ kramdown is yet-another-markdown-parser but fast, pure Ruby, using a strict syntax definition and
4
+ supporting several common extensions.
5
+
6
+ The syntax definition can be found in doc/syntax.page, a quick reference in doc/quickref.page. All
7
+ the documentation is available online at http://kramdown.rubyforge.org.
8
+
9
+ # Usage
10
+
11
+ kramdown has a basic *Cloth API, so using kramdown is as easy as
12
+
13
+ require 'kramdown'
14
+
15
+ Kramdown::Document.new(text).to_html
16
+
17
+
18
+ # License
19
+
20
+ See the COPYING file.
@@ -0,0 +1,300 @@
1
+ # -*- ruby -*-
2
+
3
+ # load all optional developer libraries
4
+ begin
5
+ require 'rubygems'
6
+ require 'rake/gempackagetask'
7
+ rescue LoadError
8
+ end
9
+
10
+ begin
11
+ require 'webgen/webgentask'
12
+ require 'webgen/page'
13
+ rescue LoadError
14
+ end
15
+
16
+ require 'rdoc/task'
17
+ require 'rdoc/rdoc'
18
+
19
+
20
+ begin
21
+ require 'rubyforge'
22
+ rescue LoadError
23
+ end
24
+
25
+ begin
26
+ require 'rcov/rcovtask'
27
+ rescue LoadError
28
+ end
29
+
30
+ require 'fileutils'
31
+ require 'rake/clean'
32
+ require 'rake/testtask'
33
+ require 'rake/packagetask'
34
+
35
+ $:.unshift('lib')
36
+ require 'kramdown'
37
+
38
+ # End user tasks ################################################################
39
+
40
+ task :default => :test
41
+
42
+ desc "Install using setup.rb"
43
+ task :install do
44
+ ruby "setup.rb config"
45
+ ruby "setup.rb setup"
46
+ ruby "setup.rb install"
47
+ end
48
+
49
+ task :clobber do
50
+ ruby "setup.rb clean"
51
+ end
52
+
53
+
54
+ if defined? Webgen
55
+ desc "Generate the HTML documentation"
56
+ Webgen::WebgenTask.new('htmldoc') do |site|
57
+ site.clobber_outdir = true
58
+ site.config_block = lambda do |config|
59
+ config['sources'] = [['/', "Webgen::Source::FileSystem", 'doc']]
60
+ config['output'] = ['Webgen::Output::FileSystem', 'htmldoc']
61
+ config.default_processing_pipeline('Page' => 'erb,tags,kramdown,blocks,fragments')
62
+ config['contentprocessor.map']['kramdown'] = 'Kramdown::KDConverter'
63
+ end
64
+ end
65
+
66
+ task :doc => :htmldoc
67
+ end
68
+
69
+ rd = Rake::RDocTask.new do |rdoc|
70
+ rdoc.rdoc_dir = 'htmldoc/rdoc'
71
+ rdoc.title = 'kramdown'
72
+ rdoc.main = 'Kramdown'
73
+ rdoc.options << '--line-numbers'
74
+ rdoc.rdoc_files.include('lib/**/*.rb')
75
+ end
76
+
77
+ desc "Build the whole user documentation"
78
+ task :doc => :rdoc
79
+
80
+ tt = Rake::TestTask.new do |test|
81
+ test.warning = true
82
+ test.libs << 'test'
83
+ end
84
+
85
+ # Release tasks and development tasks ############################################
86
+
87
+ namespace :dev do
88
+
89
+ SUMMARY = 'kramdown is a fast, pure-Ruby converter for Markdown-like markup.'
90
+ DESCRIPTION = <<EOF
91
+ kramdown is yet-another-markdown-parser but fast, pure Ruby,
92
+ using a strict syntax definition and supporting several common extensions.
93
+ EOF
94
+
95
+ begin
96
+ REL_PAGE = Webgen::Page.from_data(File.read('doc/news/release_' + Kramdown::VERSION.split('.').join('_') + '.page'))
97
+ rescue
98
+ puts 'NO RELEASE NOTES/CHANGES FILE'
99
+ end
100
+
101
+ PKG_FILES = FileList.new([
102
+ 'Rakefile',
103
+ 'setup.rb',
104
+ 'COPYING', 'GPL', 'README', 'AUTHORS',
105
+ 'VERSION', 'ChangeLog',
106
+ 'bin/*',
107
+ 'benchmark/*',
108
+ 'lib/**/*.rb',
109
+ 'doc/**',
110
+ 'test/**/*'
111
+ ])
112
+
113
+ CLOBBER << "VERSION"
114
+ file 'VERSION' do
115
+ puts "Generating VERSION file"
116
+ File.open('VERSION', 'w+') {|file| file.write(Kramdown::VERSION + "\n")}
117
+ end
118
+
119
+ CLOBBER << 'ChangeLog'
120
+ file 'ChangeLog' do
121
+ puts "Generating ChangeLog file"
122
+ `git log --name-only > ChangeLog`
123
+ end
124
+
125
+ Rake::PackageTask.new('kramdown', Kramdown::VERSION) do |pkg|
126
+ pkg.need_tar = true
127
+ pkg.need_zip = true
128
+ pkg.package_files = PKG_FILES
129
+ end
130
+
131
+ if defined? Gem
132
+ spec = Gem::Specification.new do |s|
133
+
134
+ #### Basic information
135
+ s.name = 'kramdown'
136
+ s.version = Kramdown::VERSION
137
+ s.summary = SUMMARY
138
+ s.description = DESCRIPTION
139
+
140
+ #### Dependencies, requirements and files
141
+ s.files = PKG_FILES.to_a
142
+
143
+ s.require_path = 'lib'
144
+ s.executables = ['kramdown']
145
+ s.default_executable = 'kramdown'
146
+
147
+ #### Documentation
148
+
149
+ s.has_rdoc = true
150
+ s.rdoc_options = ['--line-numbers', '--main', 'Kramdown']
151
+
152
+ #### Author and project details
153
+
154
+ s.author = 'Thomas Leitner'
155
+ s.email = 't_leitner@gmx.at'
156
+ s.homepage = "http://kramdown.rubyforge.org"
157
+ s.rubyforge_project = 'kramdown'
158
+ end
159
+
160
+ Rake::GemPackageTask.new(spec) do |pkg|
161
+ pkg.need_zip = true
162
+ pkg.need_tar = true
163
+ end
164
+
165
+ end
166
+
167
+ desc 'Release Kramdown version ' + Kramdown::VERSION
168
+ task :release => [:clobber, :package, :publish_files, :publish_doc, :post_news]
169
+
170
+ if defined? RubyForge
171
+ desc "Upload the release to Rubyforge"
172
+ task :publish_files => [:package] do
173
+ print 'Uploading files to Rubyforge...'
174
+ $stdout.flush
175
+
176
+ rf = RubyForge.new
177
+ rf.configure
178
+ rf.login
179
+
180
+ rf.userconfig["release_notes"] = REL_PAGE.blocks['content'].content
181
+ rf.userconfig["preformatted"] = false
182
+
183
+ files = %w[.gem .tgz .zip].collect {|ext| "pkg/kramdown-#{Kramdown::VERSION}" + ext}
184
+
185
+ rf.add_release('kramdown', 'kramdown', Kramdown::VERSION, *files)
186
+ puts 'done'
187
+ end
188
+
189
+ desc 'Post announcement to rubyforge.'
190
+ task :post_news do
191
+ print 'Posting announcement to Rubyforge ...'
192
+ $stdout.flush
193
+ rf = RubyForge.new
194
+ rf.configure
195
+ rf.login
196
+
197
+ content = REL_PAGE.blocks['content'].content
198
+ content += "\n\n\nAbout kramdown\n\n#{SUMMARY}\n\n#{DESCRIPTION}"
199
+ rf.post_news('kramdown', "kramdown #{Kramdown::VERSION} released", content)
200
+ puts "done"
201
+ end
202
+ end
203
+
204
+ desc "Upload the website to Rubyforge"
205
+ task :publish_website => ['rdoc', :website] do
206
+ sh "rsync -avc --delete --exclude 'wiki' --exclude 'robots.txt' htmldoc/ gettalong@rubyforge.org:/var/www/gforge-projects/kramdown/"
207
+ end
208
+
209
+
210
+ if defined? Rcov
211
+ Rcov::RcovTask.new do |rcov|
212
+ rcov.libs << 'test'
213
+ end
214
+ end
215
+
216
+ COPYRIGHT=<<EOF
217
+ # -*- coding: utf-8 -*-
218
+ #
219
+ #--
220
+ # Copyright (C) 2009 Thomas Leitner <t_leitner@gmx.at>
221
+ #
222
+ # This file is part of kramdown.
223
+ #
224
+ # kramdown is free software: you can redistribute it and/or modify
225
+ # it under the terms of the GNU General Public License as published by
226
+ # the Free Software Foundation, either version 3 of the License, or
227
+ # (at your option) any later version.
228
+ #
229
+ # This program is distributed in the hope that it will be useful,
230
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
231
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
232
+ # GNU General Public License for more details.
233
+ #
234
+ # You should have received a copy of the GNU General Public License
235
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
236
+ #++
237
+ #
238
+ EOF
239
+
240
+ desc "Insert copyright notice"
241
+ task :insert_copyright do
242
+ inserted = false
243
+ Dir["lib/**/*.rb"].each do |file|
244
+ if !File.read(file).start_with?(COPYRIGHT)
245
+ inserted = true
246
+ puts "Updating file #{file}"
247
+ data = COPYRIGHT + "\n" + File.read(file)
248
+ File.open(file, 'w+') {|f| f.puts(data)}
249
+ end
250
+ end
251
+ puts "Look through the above mentioned files and correct all problems" if inserted
252
+ end
253
+
254
+ end
255
+
256
+ task :clobber => ['dev:clobber']
257
+
258
+ # Helper methods and misc ###################################################################
259
+
260
+ module Kramdown
261
+
262
+ # Processes content in kramdown format using the +maruku+ library.
263
+ class KDConverter
264
+
265
+ # Convert the content in +context+ to HTML.
266
+ def call(context)
267
+ extend Webgen::Loggable
268
+ doc = ::Kramdown::Document.new(context.content, :auto_ids => true)
269
+ context.content = doc.to_html
270
+ doc.warnings.each do |warn|
271
+ log(:warn) { "Warning while parsing #{context.ref_node} with kramdown: #{warn}" }
272
+ end
273
+ context
274
+ end
275
+
276
+ end
277
+
278
+ class Extension
279
+
280
+ def parse_kdexample(parser, opts, body)
281
+ wrap = Element.new(:html_element, 'div', :attr => {'class' => 'kdexample'})
282
+ wrap.children << Element.new(:codeblock, body, :attr => {'class' => 'kdexample-before'})
283
+ doc = ::Kramdown::Document.new(body)
284
+ wrap.children << Element.new(:codeblock, doc.to_html, :attr => {'class' => 'kdexample-after-source'})
285
+ wrap.children << Element.new(:html_element, 'div', :attr => {'class' => 'kdexample-after-live'})
286
+ wrap.children.last.children << Element.new(:raw, doc.to_html)
287
+ parser.tree.children << wrap
288
+ parser.tree.children << Element.new(:html_element, 'div', :attr => {'class' => 'clear'})
289
+ end
290
+
291
+ def parse_kdlink(parser, opts, body)
292
+ wrap = Element.new(:html_element, 'div', :attr => {'class' => 'kdsyntaxlink'})
293
+ wrap.children << Element.new(:a, nil, :attr => {'href' => "syntax.html##{opts['id']}"})
294
+ wrap.children.last.children << Element.new(:text, "&rarr; Syntax for #{opts['part']}")
295
+ parser.tree.children << wrap
296
+ end
297
+
298
+ end
299
+
300
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,33 @@
1
+ require 'benchmark'
2
+ require 'stringio'
3
+
4
+ require 'kramdown'
5
+ require 'bluecloth'
6
+ require 'maruku'
7
+ require 'rdiscount'
8
+ require 'bluefeather'
9
+
10
+ module MaRuKu::Errors
11
+ def tell_user(s)
12
+ end
13
+ end
14
+
15
+
16
+ RUNS=20
17
+
18
+ FILES=['mdsyntax.text', 'mdbasics.text']
19
+
20
+ puts "Running tests on #{Time.now.strftime("%Y-%M-%d")} under #{RUBY_DESCRIPTION}"
21
+
22
+ FILES.each do |file|
23
+ data = File.read(File.join(File.dirname(__FILE__), file))
24
+ puts
25
+ puts "Test using file #{file} and #{RUNS} runs"
26
+ Benchmark.bmbm do |b|
27
+ b.report("kramdown #{Kramdown::VERSION}") { RUNS.times { Kramdown::Document.new(data).to_html } }
28
+ b.report("Maruku #{Maruku::VERSION}") { RUNS.times { Maruku.new(data, :on_error => :ignore).to_html } }
29
+ b.report("BlueFeather #{BlueFeather::VERSION}") { RUNS.times { BlueFeather.parse(data) } }
30
+ b.report("BlueCloth #{BlueCloth::VERSION}") { RUNS.times { BlueCloth.new(data).to_html } }
31
+ b.report("RDiscount #{RDiscount::VERSION}") { RUNS.times { RDiscount.new(data).to_html } }
32
+ end
33
+ end
@@ -0,0 +1,306 @@
1
+ Markdown: Basics
2
+ ================
3
+
4
+ <ul id="ProjectSubmenu">
5
+ <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
6
+ <li><a class="selected" title="Markdown Basics">Basics</a></li>
7
+ <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
8
+ <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
9
+ <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
10
+ </ul>
11
+
12
+
13
+ Getting the Gist of Markdown's Formatting Syntax
14
+ ------------------------------------------------
15
+
16
+ This page offers a brief overview of what it's like to use Markdown.
17
+ The [syntax page] [s] provides complete, detailed documentation for
18
+ every feature, but Markdown should be very easy to pick up simply by
19
+ looking at a few examples of it in action. The examples on this page
20
+ are written in a before/after style, showing example syntax and the
21
+ HTML output produced by Markdown.
22
+
23
+ It's also helpful to simply try Markdown out; the [Dingus] [d] is a
24
+ web application that allows you type your own Markdown-formatted text
25
+ and translate it to XHTML.
26
+
27
+ **Note:** This document is itself written using Markdown; you
28
+ can [see the source for it by adding '.text' to the URL] [src].
29
+
30
+ [s]: /projects/markdown/syntax "Markdown Syntax"
31
+ [d]: /projects/markdown/dingus "Markdown Dingus"
32
+ [src]: /projects/markdown/basics.text
33
+
34
+
35
+ ## Paragraphs, Headers, Blockquotes ##
36
+
37
+ A paragraph is simply one or more consecutive lines of text, separated
38
+ by one or more blank lines. (A blank line is any line that looks like a
39
+ blank line -- a line containing nothing spaces or tabs is considered
40
+ blank.) Normal paragraphs should not be intended with spaces or tabs.
41
+
42
+ Markdown offers two styles of headers: *Setext* and *atx*.
43
+ Setext-style headers for `<h1>` and `<h2>` are created by
44
+ "underlining" with equal signs (`=`) and hyphens (`-`), respectively.
45
+ To create an atx-style header, you put 1-6 hash marks (`#`) at the
46
+ beginning of the line -- the number of hashes equals the resulting
47
+ HTML header level.
48
+
49
+ Blockquotes are indicated using email-style '`>`' angle brackets.
50
+
51
+ Markdown:
52
+
53
+ A First Level Header
54
+ ====================
55
+
56
+ A Second Level Header
57
+ ---------------------
58
+
59
+ Now is the time for all good men to come to
60
+ the aid of their country. This is just a
61
+ regular paragraph.
62
+
63
+ The quick brown fox jumped over the lazy
64
+ dog's back.
65
+
66
+ ### Header 3
67
+
68
+ > This is a blockquote.
69
+ >
70
+ > This is the second paragraph in the blockquote.
71
+ >
72
+ > ## This is an H2 in a blockquote
73
+
74
+
75
+ Output:
76
+
77
+ <h1>A First Level Header</h1>
78
+
79
+ <h2>A Second Level Header</h2>
80
+
81
+ <p>Now is the time for all good men to come to
82
+ the aid of their country. This is just a
83
+ regular paragraph.</p>
84
+
85
+ <p>The quick brown fox jumped over the lazy
86
+ dog's back.</p>
87
+
88
+ <h3>Header 3</h3>
89
+
90
+ <blockquote>
91
+ <p>This is a blockquote.</p>
92
+
93
+ <p>This is the second paragraph in the blockquote.</p>
94
+
95
+ <h2>This is an H2 in a blockquote</h2>
96
+ </blockquote>
97
+
98
+
99
+
100
+ ### Phrase Emphasis ###
101
+
102
+ Markdown uses asterisks and underscores to indicate spans of emphasis.
103
+
104
+ Markdown:
105
+
106
+ Some of these words *are emphasized*.
107
+ Some of these words _are emphasized also_.
108
+
109
+ Use two asterisks for **strong emphasis**.
110
+ Or, if you prefer, __use two underscores instead__.
111
+
112
+ Output:
113
+
114
+ <p>Some of these words <em>are emphasized</em>.
115
+ Some of these words <em>are emphasized also</em>.</p>
116
+
117
+ <p>Use two asterisks for <strong>strong emphasis</strong>.
118
+ Or, if you prefer, <strong>use two underscores instead</strong>.</p>
119
+
120
+
121
+
122
+ ## Lists ##
123
+
124
+ Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
125
+ `+`, and `-`) as list markers. These three markers are
126
+ interchangable; this:
127
+
128
+ * Candy.
129
+ * Gum.
130
+ * Booze.
131
+
132
+ this:
133
+
134
+ + Candy.
135
+ + Gum.
136
+ + Booze.
137
+
138
+ and this:
139
+
140
+ - Candy.
141
+ - Gum.
142
+ - Booze.
143
+
144
+ all produce the same output:
145
+
146
+ <ul>
147
+ <li>Candy.</li>
148
+ <li>Gum.</li>
149
+ <li>Booze.</li>
150
+ </ul>
151
+
152
+ Ordered (numbered) lists use regular numbers, followed by periods, as
153
+ list markers:
154
+
155
+ 1. Red
156
+ 2. Green
157
+ 3. Blue
158
+
159
+ Output:
160
+
161
+ <ol>
162
+ <li>Red</li>
163
+ <li>Green</li>
164
+ <li>Blue</li>
165
+ </ol>
166
+
167
+ If you put blank lines between items, you'll get `<p>` tags for the
168
+ list item text. You can create multi-paragraph list items by indenting
169
+ the paragraphs by 4 spaces or 1 tab:
170
+
171
+ * A list item.
172
+
173
+ With multiple paragraphs.
174
+
175
+ * Another item in the list.
176
+
177
+ Output:
178
+
179
+ <ul>
180
+ <li><p>A list item.</p>
181
+ <p>With multiple paragraphs.</p></li>
182
+ <li><p>Another item in the list.</p></li>
183
+ </ul>
184
+
185
+
186
+
187
+ ### Links ###
188
+
189
+ Markdown supports two styles for creating links: *inline* and
190
+ *reference*. With both styles, you use square brackets to delimit the
191
+ text you want to turn into a link.
192
+
193
+ Inline-style links use parentheses immediately after the link text.
194
+ For example:
195
+
196
+ This is an [example link](http://example.com/).
197
+
198
+ Output:
199
+
200
+ <p>This is an <a href="http://example.com/">
201
+ example link</a>.</p>
202
+
203
+ Optionally, you may include a title attribute in the parentheses:
204
+
205
+ This is an [example link](http://example.com/ "With a Title").
206
+
207
+ Output:
208
+
209
+ <p>This is an <a href="http://example.com/" title="With a Title">
210
+ example link</a>.</p>
211
+
212
+ Reference-style links allow you to refer to your links by names, which
213
+ you define elsewhere in your document:
214
+
215
+ I get 10 times more traffic from [Google][1] than from
216
+ [Yahoo][2] or [MSN][3].
217
+
218
+ [1]: http://google.com/ "Google"
219
+ [2]: http://search.yahoo.com/ "Yahoo Search"
220
+ [3]: http://search.msn.com/ "MSN Search"
221
+
222
+ Output:
223
+
224
+ <p>I get 10 times more traffic from <a href="http://google.com/"
225
+ title="Google">Google</a> than from <a href="http://search.yahoo.com/"
226
+ title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
227
+ title="MSN Search">MSN</a>.</p>
228
+
229
+ The title attribute is optional. Link names may contain letters,
230
+ numbers and spaces, but are *not* case sensitive:
231
+
232
+ I start my morning with a cup of coffee and
233
+ [The New York Times][NY Times].
234
+
235
+ [ny times]: http://www.nytimes.com/
236
+
237
+ Output:
238
+
239
+ <p>I start my morning with a cup of coffee and
240
+ <a href="http://www.nytimes.com/">The New York Times</a>.</p>
241
+
242
+
243
+ ### Images ###
244
+
245
+ Image syntax is very much like link syntax.
246
+
247
+ Inline (titles are optional):
248
+
249
+ ![alt text](/path/to/img.jpg "Title")
250
+
251
+ Reference-style:
252
+
253
+ ![alt text][id]
254
+
255
+ [id]: /path/to/img.jpg "Title"
256
+
257
+ Both of the above examples produce the same output:
258
+
259
+ <img src="/path/to/img.jpg" alt="alt text" title="Title" />
260
+
261
+
262
+
263
+ ### Code ###
264
+
265
+ In a regular paragraph, you can create code span by wrapping text in
266
+ backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
267
+ `>`) will automatically be translated into HTML entities. This makes
268
+ it easy to use Markdown to write about HTML example code:
269
+
270
+ I strongly recommend against using any `<blink>` tags.
271
+
272
+ I wish SmartyPants used named entities like `&mdash;`
273
+ instead of decimal-encoded entites like `&#8212;`.
274
+
275
+ Output:
276
+
277
+ <p>I strongly recommend against using any
278
+ <code>&lt;blink&gt;</code> tags.</p>
279
+
280
+ <p>I wish SmartyPants used named entities like
281
+ <code>&amp;mdash;</code> instead of decimal-encoded
282
+ entites like <code>&amp;#8212;</code>.</p>
283
+
284
+
285
+ To specify an entire block of pre-formatted code, indent every line of
286
+ the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
287
+ and `>` characters will be escaped automatically.
288
+
289
+ Markdown:
290
+
291
+ If you want your page to validate under XHTML 1.0 Strict,
292
+ you've got to put paragraph tags in your blockquotes:
293
+
294
+ <blockquote>
295
+ <p>For example.</p>
296
+ </blockquote>
297
+
298
+ Output:
299
+
300
+ <p>If you want your page to validate under XHTML 1.0 Strict,
301
+ you've got to put paragraph tags in your blockquotes:</p>
302
+
303
+ <pre><code>&lt;blockquote&gt;
304
+ &lt;p&gt;For example.&lt;/p&gt;
305
+ &lt;/blockquote&gt;
306
+ </code></pre>