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
@@ -0,0 +1,90 @@
1
+ ---
2
+ title: Download & Installation
3
+ in_menu: true
4
+ sort_info: 5
5
+ ---
6
+ # Download & Installation
7
+
8
+ ## Compatibility Notes
9
+
10
+ kramdown should work on any platform which supports Ruby. It has been successfully tested on the
11
+ following platforms:
12
+
13
+ * Linux with Ruby 1.8.6
14
+ * Mac OSX with Ruby 1.8.6, 1.8.7, 1.9.1, 1.9.2-preview1 and jruby 1.4.0.
15
+
16
+ See the platform specific installation notes for more information!
17
+
18
+
19
+ ## Platform Specific Installation Instructions
20
+
21
+ ### Linux
22
+
23
+ There are a variety of Linux distributions out there with different package management systems. So we
24
+ will focus on instructions for Ubuntu 9.04 here (which should probably also work for any recent
25
+ Debian based distribution).
26
+
27
+ After running the following commands, kramdown is installed and ready to use:
28
+
29
+ sudo aptitude install ruby rubygems
30
+ sudo gem1.8 install kramdown
31
+
32
+ > You will also need to add `export PATH=$PATH:/var/lib/gems/1.8/bin` to your `~/.bashrc` because
33
+ > this is the binary path the executable files get installed.
34
+
35
+
36
+ ### Mac OS X
37
+
38
+ Mac OS X Snow Leopard comes with Ruby and Rubygems preinstalled. So installing kramdown is as easy
39
+ as running:
40
+
41
+ sudo gem install kramdown
42
+
43
+
44
+ ### Windows
45
+
46
+ You need to install Ruby first. This can easily be done by using the One-Click-Installer - just
47
+ download the *latest* installation binary from the [files section][1] of the One-Click-Installer
48
+ homepage and run it. After that open a command shell (select `Start -> Run...`, then enter `cmd` and
49
+ click on `Ok`) and type in the following:
50
+
51
+ gem install kramdown
52
+
53
+ [1]: http://rubyforge.org/frs/?group_id=167
54
+
55
+
56
+ ## Generic Installation Instructions
57
+
58
+
59
+ ### Using Rubygems
60
+
61
+ If you are using Rubygems, installing the latest version of kramdown is as simple as executing
62
+
63
+ gem install kramdown
64
+
65
+
66
+ ### Manual Installation
67
+
68
+ The latest version of kramdown can always be downloaded as `.tar.gz` or `.zip` from [its files
69
+ section on Rubyforge](http://rubyforge.org/frs/?group_id=7403). After the download the package needs
70
+ to be decompressed and then you can install kramdown using the included `setup.rb` installation
71
+ method:
72
+
73
+ $ ruby setup.rb config
74
+ $ ruby setup.rb setup
75
+ $ ruby setup.rb install
76
+
77
+
78
+ ### Using the repository version
79
+
80
+ kramdown uses git as its versioning system and kramdown's repository is hosted on GitHub. The
81
+ repository always contains a clean state of the current development version of kramdown. To check
82
+ out kramdown use the following command:
83
+
84
+ git clone git://github.com/gettalong/kramdown.git
85
+
86
+
87
+ ## Dependencies
88
+
89
+ Since kramdown is written in Ruby, you just need the [Ruby interpreter](http://www.ruby-lang.org)
90
+ versions 1.8.6, 1.8.7 or 1.9.1. There are no other dependencies.
@@ -0,0 +1,10 @@
1
+ ---
2
+ title: kramdown News
3
+ description: kramdown - a fast, pure Ruby Markdown+extensions converter
4
+ site_url: http://kramdown.rubyforge.org/
5
+ author: Thomas Leitner
6
+ author_url: http://kramdown.rubyforge.org
7
+ number_of_entries: 10
8
+ rss: false
9
+ entries: [news/*.html]
10
+
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: News
3
+ in_menu: true
4
+ sort_info: 30
5
+ --- pipeline:tags,blocks,fragments
6
+
7
+ <h1>News</h1>
8
+
9
+ <a href="{relocatable: news.atom}">Atom-Feed</a>
10
+
11
+ <webgen:block name="newsdata" node="current" />
12
+
13
+ --- name:newsdata pipeline:erb
14
+ <%
15
+ context.content_node.tree.node_access[:alcn].select do |na,no|
16
+ na =~ /\/news\/.+/ && no.is_file?
17
+ end.collect {|na,no| no}.sort.reverse.each do |node|
18
+ %>
19
+
20
+ <div class='news-item'>
21
+ <div class="news-date f-right">
22
+ Published on <%= node['created_at'].strftime("%A, %d %B %Y") %>
23
+ </div>
24
+ <%= context.render_block(:name => 'content', :chain => [node]) %>
25
+ </div>
26
+
27
+ <% end %>
@@ -0,0 +1,474 @@
1
+ ---
2
+ title: Quick Reference
3
+ in_menu: true
4
+ sort_info: 9
5
+ ---
6
+ # Quick Reference
7
+
8
+ Below are examples of all available structural elements that can be used in kramdown text. Note,
9
+ that only the most basic syntax information is given. However, a link to the detailed syntax for
10
+ each element is provided.
11
+
12
+ kramdown has two main classes of elements: block and span level elements. Block level elements are
13
+ used to create paragraphs, headers, lists and so on whereas span level elements are used to markup
14
+ text phrases as emphasized, as a link and so on.
15
+
16
+ All examples below feature the kramdown source, the converted HTML source and the output as it
17
+ appears in the browser. This looks like this:
18
+
19
+ {::nokramdown:}
20
+ <div class="kdexample">
21
+ <pre class="kdexample-before"><code>kramdown example code
22
+ </code></pre>
23
+ <pre class="kdexample-after-source"><code>Example code converted to HTML
24
+ </code></pre>
25
+ <div class="kdexample-after-live">
26
+ Live browser view of example code
27
+ </div>
28
+ </div>
29
+ <div class="clear"></div>
30
+ {::nokramdown:}
31
+
32
+
33
+ # Block Level Elements - Main Structural Elements
34
+
35
+ ## Paragraphs
36
+
37
+ {::kdlink:: #paragraphs part="paragraphs"}
38
+
39
+ Paragraphs are separated by one or more blank lines:
40
+
41
+ {::kdexample:}
42
+ The first paragraph.
43
+
44
+ Another paragraph
45
+ {::kdexample:}
46
+
47
+ Explicit line breaks in a paragraph can be made by using two spaces or two backslashes at the end of a line:
48
+
49
+ {::kdexample:}
50
+ This is a paragraph
51
+ which contains a hard line break.
52
+ {::kdexample:}
53
+
54
+
55
+ ## Headers
56
+
57
+ {::kdlink:: #headers part="headers"}
58
+
59
+ kramdown supports Setext style headers and atx style headers. A header must always be preceeded by a
60
+ blank line except at the beginning of the document:
61
+
62
+ {::kdexample:}
63
+ First level header
64
+ ==================
65
+
66
+ Second level header
67
+ -------------------
68
+ {::kdexample:}
69
+
70
+ {::kdexample:}
71
+ # H1 header
72
+
73
+ ## H2 header
74
+
75
+ ### H3 header
76
+
77
+ #### H4 header
78
+
79
+ ##### H5 header
80
+
81
+ ###### H6 header
82
+ {::kdexample:}
83
+
84
+ If you set the option `auto_ids` to `true` (for example, by using the `kdoptions` extension, see
85
+ [Extension Blocks](#extension-blocks)), then all headers are automatically given header IDs based on
86
+ the header text:
87
+
88
+ {::kdexample:}
89
+ # A header without an ID
90
+
91
+ {::kdoptions:: auto_ids="true"}
92
+
93
+ # A header with an ID
94
+ {::kdexample:}
95
+
96
+
97
+ ## Blockquotes
98
+
99
+ {::kdlink:: #blockquotes part="blockquotes"}
100
+
101
+ A blockquote is started using the `>` marker followed by an optional space; all following lines that
102
+ are also started with the blockquote marker belong to the blockquote. You can use any block level
103
+ elements inside a blockquote:
104
+
105
+ {::kdexample:}
106
+ > A sample blockquote.
107
+ > >Nested blockquotes are
108
+ > >also possible.
109
+ >
110
+ > ## Headers work too
111
+ > This is the outer quote again.
112
+ {::kdexample:}
113
+
114
+
115
+ ## Code Blocks
116
+
117
+ {::kdlink:: #code-blocks part="code blocks"}
118
+
119
+ kramdown supports two different code block styles. One uses lines indented with either four spaces
120
+ or one tab whereas the other uses lines with tilde characters as delimiters -- therefore the content
121
+ does not need to be indented:
122
+
123
+ {::kdexample:}
124
+ This is a sample code block.
125
+
126
+ Continued here.
127
+ {::kdexample:}
128
+
129
+ {::kdexample:}
130
+ ~~~~~~
131
+ This is also a code block.
132
+ ~~~
133
+ Ending lines must have at least as
134
+ many tildes as the starting line.
135
+ ~~~~~~~~~~~~
136
+ {::kdexample:}
137
+
138
+
139
+ ## Horizontal Rules
140
+
141
+ {::kdlink:: #horizontal-rules part="horizontal rules"}
142
+
143
+ It is easy to insert a horizontal rule in kramdown: just use three or more asterisks, dashes or
144
+ underscores, optionally separated by spaces or tabs, on an otherwise blank line:
145
+
146
+ {::kdexample:}
147
+ * * *
148
+
149
+ \---
150
+
151
+ _ _ _ _
152
+
153
+ ---------------
154
+ {::kdexample:}
155
+
156
+
157
+ ## Lists
158
+
159
+ {::kdlink:: #lists part="lists"}
160
+
161
+ kramdown supports ordered and unordered lists. Ordered lists are started by using a number followed
162
+ by a period, a space and then the list item text. The content of a list item consists of block level
163
+ elements. All lines which have the same indent as the text of the line with the list marker belong
164
+ to the list item:
165
+
166
+ {::kdexample:}
167
+ 1. This is a list item
168
+ 2. And another item
169
+ 2. And the third one
170
+ with additional. text
171
+ {::kdexample:}
172
+
173
+ As the content consists of block level elements you can do things like the following:
174
+
175
+ {::kdexample:}
176
+ 1. This is a list item
177
+
178
+ > with a blockquote
179
+
180
+ # And a header
181
+
182
+ 2. Followed by another item
183
+ {::kdexample:}
184
+
185
+ Nested lists are also easy to create:
186
+
187
+ {::kdexample:}
188
+ 1. Item one
189
+ 1. sub item one
190
+ 2. sub item two
191
+ 3. sub item three
192
+ 2. Item two
193
+ {::kdexample:}
194
+
195
+ Lists can occur directly after other block level elements, however, there has to be at least one
196
+ blank line if you want to follow a paragraph with a list:
197
+
198
+ {::kdexample:}
199
+ This is a paragraph.
200
+ 1. This is NOT a list.
201
+
202
+ 1. This is a list!
203
+ {::kdexample:}
204
+
205
+ Unordered lists are started by using an asterisk, a dash or a plus sign (they can be mixed) and a
206
+ space. Apart from that unordered lists follow the same rules as ordered lists:
207
+
208
+ {::kdexample:}
209
+ * Item one
210
+ + Item two
211
+ - Item three
212
+ {::kdexample:}
213
+
214
+
215
+ ## HTML elements
216
+
217
+ kramdown allows you to use block level HTML tags (`div`, `p`, `pre`, ...) to markup whole blocks of
218
+ text -- just start a line with a block level HTML tag. The content of a block level HTML tag is
219
+ parsed by kramdown either as block level or span level text, depending on the tag:
220
+
221
+ {::kdexample:}
222
+ <div style="float: right">
223
+ Something that stays right.
224
+ </div>
225
+ Normal text flow.
226
+ <p>
227
+ This can contain only *span* level elements.
228
+ </p>
229
+ {::kdexample:}
230
+
231
+
232
+ ## Block Attributes
233
+
234
+ {::kdlink:: #block-inline-attribute-lists part="block IALs"}
235
+ {::kdlink:: #attribute-list-definitions part="ALDs"}
236
+
237
+ You can assign any attribute to a block level element. Just directly follow the block with a *block
238
+ inline attribute list* (or short: block IAL). A block IAL consists of a left curly brace, followed
239
+ by a colon, the attribute definitions and a right curly brace. Here is a simple example which sets the
240
+ `title` attribute of a block quote:
241
+
242
+ {::kdexample:}
243
+ > A nice blockquote
244
+ {: title="Blockquote title"}
245
+ {::kdexample:}
246
+
247
+ As one often wants to set one or more CSS classes on an element, there is an easy shortcut:
248
+
249
+ {::kdexample:}
250
+ > A nice blockquote
251
+ {: .class1 .class2}
252
+ {::kdexample:}
253
+
254
+ A shortcut for setting the ID is also provided. Just prefix the ID with a hash symbol:
255
+
256
+ {::kdexample:}
257
+ > A nice blockquote
258
+ {: #with-an-id}
259
+ {::kdexample:}
260
+
261
+ Sometimes one wants to use the same attributes for many elements. kramdown allows you to define the
262
+ attributes in one place with an *attribute list definition* (or short: ALD) and just reference this
263
+ definition in a block IAL. An ALD has the same structure as a block IAL but the colon has to be
264
+ replace with a colon, the reference name and another colon. By just using the reference name as-is
265
+ in a block IAL, one can include the attributes of the referenced ALD:
266
+
267
+ {::kdexample:}
268
+ {:refdef: .c1 #id .c2 title="title"}
269
+ paragraph
270
+ {: refdef}
271
+ {::kdexample:}
272
+
273
+ The order in a block IAL or ALD is important because later defined attributes overwrite (with the
274
+ exception of the shortcut for CSS classes) prior defined attributes:
275
+
276
+ {::kdexample:}
277
+ {:refdef: .c1 #id .c2 title="title"}
278
+ paragraph
279
+ {: refdef .c3 title="t" #para}
280
+ {::kdexample:}
281
+
282
+
283
+ ## Extension Blocks
284
+
285
+ {::kdlink:: #extension-blocks part="extension blocks"}
286
+
287
+ Extension blocks can be used to add custom behaviour to kramdown. For more information on how to do
288
+ this have a look at the [API documentation]({relocatable: /rdoc/index.html}). kramdown comes with
289
+ some built-in extensions for ignoring text (i.e. treating text as comment), for inserting arbitrary
290
+ text into the output and for setting kramdown options.
291
+
292
+ Here is an example that shows how to insert comments into text:
293
+
294
+ {::kdexample:}
295
+ This is a paragraph
296
+ {::comment:}
297
+ This is a comment which is
298
+ completely ignored.
299
+ {::comment:}
300
+ ... paragraph continues here.
301
+
302
+ {::nokramdown:}
303
+ This is not parsed *by* kramdown
304
+ {::nokramdown:}
305
+ {::kdexample:}
306
+
307
+ As one can see from the above example, the syntax for extension blocks is virtually the same as for
308
+ block IALs and ALDs, except that the colon of a block IAL has to be replaced by two colons, the name
309
+ of the extension and then one or two colons. If one colon is used, it means that the extension has
310
+ body text and continues until a matching ending line (as in the example above). If two colons are
311
+ used, then the extension does not have a body, for example:
312
+
313
+ {::kdexample:}
314
+ # Header without id
315
+ {::kdoptions:: auto_ids="true"}
316
+
317
+ # Header with id
318
+ {::kdoptions:: auto_ids="false"}
319
+
320
+ # Header without id
321
+ {::kdexample:}
322
+
323
+
324
+
325
+
326
+ # Span Level Elements - Text Modifiers
327
+
328
+ ## Emphasis
329
+
330
+ {::kdlink:: #emphasis part="emphasis"}
331
+
332
+ Emphasis can be added to text by surrounding the text with either asterisks or underscores:
333
+
334
+ {::kdexample:}
335
+ This is *emphasized*,
336
+ _this_ too!
337
+ {::kdexample:}
338
+
339
+ Strong emphasis can be done by doubling the delimiters:
340
+
341
+ {::kdexample:}
342
+ This is **strong**,
343
+ __this__ too!
344
+ {::kdexample:}
345
+
346
+ The form with the asterisks can also be used to markup parts of words:
347
+
348
+ {::kdexample:}
349
+ This w**ork**s as expected!
350
+ {::kdexample:}
351
+
352
+
353
+ ## Links and Images
354
+
355
+ {::kdlink:: #links-and-images part="links and images"}
356
+
357
+ A simple link can be created by surrounding the text with square brackets and the link URL with
358
+ parentheses:
359
+
360
+ {::kdexample:}
361
+ A [link](http://kramdown.rubyforge.org)
362
+ to the kramdown homepage.
363
+ {::kdexample:}
364
+
365
+ You can also add title information to the link:
366
+
367
+ {::kdexample:}
368
+ A [link](http://kramdown.rubyforge.org "hp")
369
+ to the homepage.
370
+ {::kdexample:}
371
+
372
+ There is another way to create links which does not interrupt the text flow. The URL and title are
373
+ defined using a reference name and this reference name is then used in square brackets instead of
374
+ the link URL:
375
+
376
+ {::kdexample:}
377
+ A [link][kramdown hp]
378
+ to the homepage.
379
+
380
+ [kramdown hp]: http://kramdown.rubyforge.org "hp"
381
+ {::kdexample:}
382
+
383
+ If the link text itself is the reference name, the second set of square brackets can be omitted:
384
+
385
+ {::kdexample:}
386
+ A link to the [kramdown hp].
387
+
388
+ [kramdown hp]: http://kramdown.rubyforge.org "hp"
389
+ {::kdexample:}
390
+
391
+ Images can be created in a similar way: just use an exclamation mark before the square brackets. The
392
+ link text will become the alternative text of the image and the link URL specifies the image source:
393
+
394
+ {::kdexample:}
395
+ An image: ![gras](img/image.jpg)
396
+ {::kdexample:}
397
+
398
+
399
+ ## Inline Code
400
+
401
+ {::kdlink:: #code-spans part="code spans"}
402
+
403
+ Text phrases can be easily marked up as code by surrounding them with backticks:
404
+
405
+ {::kdexample:}
406
+ Use `Kramdown::Document.new(text).to_html`
407
+ to convert the `text` in kramdown
408
+ syntax to HTML.
409
+ {::kdexample:}
410
+
411
+ If you want to use literal backticks in your code, just use two or more backticks as delimiters. The
412
+ space right after the beginning delimiter and the one right before the closing delimiter are ignore:
413
+
414
+ {::kdexample:}
415
+ Use backticks to markup code,
416
+ e.g. `` `code` ``.
417
+ {::kdexample:}
418
+
419
+
420
+ ## Footnotes
421
+
422
+ {::kdlink:: #footnotes part="footnotes"}
423
+
424
+ Footnotes can easily be used in kramdown. Just set a footnote marker (consists of square brackets
425
+ with a caret and the footname inside) in the text and somewhere else the footnote definition (which
426
+ basically looks like a reference link definition):
427
+
428
+ {::kdexample:}
429
+ This is a text with a
430
+ footnote[^1].
431
+
432
+ [^1]: And here is the definition.
433
+ {::kdexample:}
434
+
435
+ The footnote definition can contain any block level element, all lines following a footnote
436
+ definition indented with four spaces or one tab belong to the definition:
437
+
438
+ {::kdexample:}
439
+ This is a text with a
440
+ footnote[^2].
441
+
442
+ [^2]:
443
+ And here is the definition.
444
+
445
+ > With a quote!
446
+ {::kdexample:}
447
+
448
+ As can be seen above the footnote name is only used for the anchors and the numbering is done
449
+ automatically in document order.
450
+
451
+
452
+ ## HTML Elements
453
+
454
+ {::kdlink:: #html-spans part="HTML spans"}
455
+
456
+ HTML is not only supported on the block level but also on the span level:
457
+
458
+ {::kdexample:}
459
+ This is <span style="color: red">written in
460
+ red</span>.
461
+ {::kdexample:}
462
+
463
+
464
+ ## Inline Attributes
465
+
466
+ {::kdlink:: #span-inline-attribute-lists part="span IALs"}
467
+
468
+ As with a block level element you can assign any attribute to a span level elements using a *span
469
+ inline attribute list* (or short: span IAL). A span IAL has the same syntax as a block IAL and must
470
+ immediately follow the span level element:
471
+
472
+ {::kdexample:}
473
+ This is *red*{: style="color: red"}.
474
+ {::kdexample:}