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
@@ -1,88 +0,0 @@
1
- ---
2
- title: Installation
3
- in_menu: true
4
- sort_info: 5
5
- ---
6
- # Download & Installation
7
-
8
- ## Dependencies
9
-
10
- Since kramdown is written in Ruby, you just need the [Ruby interpreter](http://www.ruby-lang.org),
11
- version 2.x. There are no other dependencies.
12
-
13
-
14
- ## Compatibility Notes
15
-
16
- kramdown should work on any platform which supports Ruby. It has been successfully tested on the
17
- following platforms:
18
-
19
- * Linux with Ruby 2.x and jruby 9.0.0.0.
20
-
21
- See the platform specific installation notes for more information!
22
-
23
-
24
- ## Platform Specific Installation Instructions
25
-
26
- ### Linux
27
-
28
- You need to make sure that Ruby is installed. If it isn't, consult the documentation of the Linux
29
- distribution you are using on how to install it. For example, in case of Ubuntu 17.10 (this should
30
- probably also work for any newer Ubuntu version or any recent Debian based distribution) all you
31
- need to do is:
32
-
33
- sudo apt-get install ruby
34
-
35
- Once you have Ruby installed, you need to execute the following command to install kramdown:
36
-
37
- sudo gem install kramdown
38
-
39
-
40
- ### Mac OS X
41
-
42
- Mac OS X Snow Leopard comes with Ruby and Rubygems preinstalled. So installing kramdown is as easy
43
- as running:
44
-
45
- sudo gem install kramdown
46
-
47
-
48
- ### Windows
49
-
50
- You need to install Ruby first. This can easily be done by using the [RubyInstaller] - just download
51
- the installation binary and run it. After that open a command shell (select `Start -> Run...`, then
52
- enter `cmd` and click on `Ok`) and type in the following:
53
-
54
- gem install kramdown
55
-
56
- [RubyInstaller]: http://rubyinstaller.org
57
-
58
-
59
- ## Generic Installation Instructions
60
-
61
-
62
- ### Using Rubygems
63
-
64
- If you are using Rubygems, installing the latest version of kramdown is as simple as executing
65
-
66
- gem install kramdown
67
-
68
-
69
- ### Manual Installation
70
-
71
- The latest version of kramdown can always be downloaded as `.tar.gz` or `.zip` via the [Github
72
- releases page][ghreleases]. After the download the package needs to be decompressed and then you can
73
- install kramdown using the included `setup.rb` installation method:
74
-
75
- $ ruby setup.rb config
76
- $ ruby setup.rb setup
77
- $ ruby setup.rb install
78
-
79
- [ghreleases]: https://github.com/gettalong/kramdown/releases
80
-
81
-
82
- ### Using the repository version
83
-
84
- kramdown uses git as its versioning system and kramdown's repository is hosted on GitHub. The
85
- repository always contains a clean state of the current development version of kramdown. To check
86
- out kramdown use the following command:
87
-
88
- git clone git://github.com/gettalong/kramdown.git
@@ -1,6 +0,0 @@
1
- [Maruku]: http://maruku.rubyforge.org
2
- [PHP Markdown Extra]: http://michelf.com/projects/php-markdown/extra/
3
- [Pandoc]: http://johnmacfarlane.net/pandoc/
4
- [MathJax]: http://www.mathjax.org
5
- [BlueCloth]: http://deveiate.org/projects/BlueCloth
6
- [RedCloth]: http://redcloth.org/
@@ -1,13 +0,0 @@
1
- --- paths
2
- [/**/*.js, /**/*.css]:
3
- modified_at_in_dest_path: true
4
-
5
- /**/*.scss:
6
- modified_at_in_dest_path: true
7
-
8
- --- alcn
9
- [converter/*.html, parser/*.html, documentation.en.html, options.en.html, tests.en.html]:
10
- template: ../documentation.template
11
-
12
- /**/*.css:
13
- pipeline: scss,cssminify
@@ -1,9 +0,0 @@
1
- ---
2
- title: kramdown News
3
- description: kramdown - a fast, pure Ruby Markdown-superset converter
4
- author: Thomas Leitner
5
- author_url: https://kramdown.gettalong.org
6
- entries: {alcn: news/*.html, sort: sort_info, reverse: true, limit: 10}
7
- versions:
8
- atom:
9
-
@@ -1,29 +0,0 @@
1
- ---
2
- title: News
3
- in_menu: false
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
- opts = {:alcn => '/news/*.html', :sort => 'sort_info', :reverse => true, :flatten => true}
16
- context.website.ext.item_tracker.add(context.dest_node, :nodes, :node_finder_option_set,
17
- {:opts => opts, :ref_alcn => context.node.alcn}, :content)
18
- context.website.ext.node_finder.find(opts, context.node).each do |node|
19
- # context.options['contentprocessor.kramdown.options'] = {:auto_id_prefix => node.lcn.tr('.', '-')}
20
- %>
21
-
22
- <div class='news-item'>
23
- <div class="news-date float-right">
24
- Published on <%= node['created_at'].strftime("%A, %d %B %Y") %>
25
- </div>
26
- <%= context.render_block(:name => 'content', :chain => [node]) %>
27
- </div>
28
-
29
- <% end %>
@@ -1,49 +0,0 @@
1
- ---
2
- title: Options
3
- ---
4
- ## Options
5
-
6
- The behaviour of kramdown can be adjusted via the available options.
7
-
8
- Options can be specified in multiple ways:
9
-
10
- On the command line
11
- : The `kramdown` binary allows setting any option by using command line switches.
12
-
13
- For example, the following command will disable automatic header ID generation and defines the
14
- first footnote number as 5:
15
-
16
- ~~~
17
- $ kramdown --no-auto-ids --footnote-nr 5
18
- ~~~
19
-
20
- As you can see all underscores in option names have to be replaced with dashes. The built-in help
21
- of the binary as well as the man-page show all available options.
22
-
23
- Within a kramdown document
24
- : By using the special extension syntax, it is possible to set options within a document.
25
-
26
- Using the above example, the options would be set like this within a document:
27
-
28
- ~~~
29
- {::options auto_ids="false" footnote_nr="5" /}
30
- ~~~
31
-
32
- Using Ruby code
33
-
34
- : If you are using kramdown as a library, you can pass any options as second parameter to the
35
- `Kramdown::Document.new` method.
36
-
37
- Again, using the above example you would initalize the kramdown document class as follows:
38
-
39
- ~~~ ruby
40
- Kramdown::Document.new(source_text, \{auto_ids: false, footnote_nr: 5})
41
- ~~~
42
-
43
-
44
- ## Available Options
45
-
46
- Below is a list of all currently available options. Have a look at the documentation of a converter
47
- or parser to see directly which options they support!
48
-
49
- {options: {items: all}}
@@ -1,603 +0,0 @@
1
- ---
2
- title: Quick Reference
3
- in_menu: true
4
- sort_info: 9
5
- --- name:sidebar
6
- <div style="text-align: right">
7
- <a href="https://www.patreon.com/bePatron?u=4908963" class="patreon">Become a Patron!</a>
8
- </div>
9
-
10
- <h1>Contents</h1>
11
-
12
- {menu: {options: {descendants: true, levels: [2,6]}}}
13
- --- name:content
14
- # Quick Reference
15
-
16
- Below are examples of all available structural elements that can be used in a kramdown text. Since
17
- the kramdown syntax is a superset of the Markdown syntax, only a small part of the available syntax
18
- is not available in standard Markdown syntax. Note, that only the most basic syntax information is
19
- given. However, a link to the detailed syntax for each element is provided (which also details the
20
- differences to the standard Markdown syntax). The quick reference is for version **<%=
21
- ::Kramdown::VERSION %>** of the syntax documentation.
22
-
23
- kramdown has two main classes of elements: block and span-level elements. Block-level elements are
24
- used to create paragraphs, headers, lists and so on whereas span-level elements are used to markup
25
- text phrases as emphasized, as a link and so on.
26
-
27
- All examples below feature the kramdown source, the converted HTML source (shown when hovering over
28
- the kramdown source) and the output as it appears in the browser. This looks like this:
29
-
30
- <table class="kdexample">
31
- <tr>
32
- <td><pre class="kdexample-before"><code>kramdown example code</code></pre></td>
33
- <td><pre class="kdexample-after-source"><code>Example code converted to HTML</code></pre>
34
- <div class="kdexample-after-live" style="clear:none">
35
- Live browser view of example code
36
- </div>
37
- </td>
38
- </tr>
39
- </table>
40
-
41
-
42
- # Block-level Elements - Main Structural Elements
43
-
44
- ## Paragraphs
45
-
46
- {kdlink: {oid: paragraphs, part: "paragraphs"}}
47
-
48
- Consecutive lines of text are considered to be one paragraph. As with other block level elements you
49
- have to add a blank line to separate it from the following block-level element:
50
-
51
- {kdexample::}
52
- The first paragraph.
53
-
54
- Another paragraph
55
- {kdexample}
56
-
57
- Explicit line breaks in a paragraph can be made by using two spaces or two backslashes at the end of a line:
58
-
59
- {kdexample::}
60
- This is a paragraph
61
- which contains a hard line break.
62
- {kdexample}
63
-
64
-
65
- ## Headers
66
-
67
- {kdlink: {oid: headers, part: "headers"}}
68
-
69
- kramdown supports Setext style headers and atx style headers. A header must always be preceded by a
70
- blank line except at the beginning of the document:
71
-
72
-
73
- {kdexample::}
74
- First level header
75
- ==================
76
-
77
- Second level header
78
- -------------------
79
- {kdexample}
80
-
81
- {kdexample::}
82
- # H1 header
83
-
84
- ## H2 header
85
-
86
- ### H3 header
87
-
88
- #### H4 header
89
-
90
- ##### H5 header
91
-
92
- ###### H6 header
93
- {kdexample}
94
-
95
- If you set the option `auto_ids` to `false` (for example, by using the `options` extension, see
96
- [Extensions](#extensions)), then the automatic header ID generation is turned off:
97
-
98
- {kdexample::}
99
- {::options auto_ids="false" /}
100
-
101
- # A header without an ID
102
- {kdexample}
103
-
104
-
105
- ## Blockquotes
106
-
107
- {kdlink: {oid: blockquotes, part: "blockquotes"}}
108
-
109
- A blockquote is started using the `>` marker followed by an optional space; all following lines that
110
- are also started with the blockquote marker belong to the blockquote. You can use any block-level
111
- elements inside a blockquote:
112
-
113
- {kdexample::}
114
- > A sample blockquote.
115
- >
116
- > >Nested blockquotes are
117
- > >also possible.
118
- >
119
- > ## Headers work too
120
- > This is the outer quote again.
121
- {kdexample}
122
-
123
- You may also be lazy with the `>` markers as long as there is no blank line:
124
-
125
- {kdexample::}
126
- > This is a blockquote
127
- continued on this
128
- and this line.
129
-
130
- But this is a separate paragraph.
131
- {kdexample}
132
-
133
- ## Code Blocks
134
-
135
- {kdlink: {oid: code-blocks, part: "code blocks"}}
136
-
137
- kramdown supports two different code block styles. One uses lines indented with either four spaces
138
- or one tab whereas the other uses lines with tilde characters as delimiters -- therefore the content
139
- does not need to be indented:
140
-
141
- {kdexample::}
142
- This is a sample code block.
143
-
144
- Continued here.
145
- {kdexample}
146
-
147
- {kdexample::}
148
- ~~~~~~
149
- This is also a code block.
150
- ~~~
151
- Ending lines must have at least as
152
- many tildes as the starting line.
153
- ~~~~~~~~~~~~
154
- {kdexample}
155
-
156
- The following is a code block with a language specified:
157
-
158
- {kdexample::}
159
- ~~~ ruby
160
- def what?
161
- 42
162
- end
163
- ~~~
164
- {kdexample}
165
-
166
-
167
- ## Horizontal Rules
168
-
169
- {kdlink: {oid: horizontal-rules, part: "horizontal rules"}}
170
-
171
- It is easy to insert a horizontal rule in kramdown: just use three or more asterisks, dashes or
172
- underscores, optionally separated by spaces or tabs, on an otherwise blank line:
173
-
174
- {kdexample::}
175
- * * *
176
-
177
- \---
178
-
179
- _ _ _ _
180
-
181
- ---------------
182
- {kdexample}
183
-
184
-
185
- ## Lists
186
-
187
- {kdlink: {oid: lists, part: "lists"}}
188
-
189
- kramdown supports ordered and unordered lists. Ordered lists are started by using a number followed
190
- by a period, a space and then the list item text. The content of a list item consists of block-level
191
- elements. All lines which have the same indent as the text of the line with the list marker belong
192
- to the list item:
193
-
194
- {kdexample::}
195
- 1. This is a list item
196
- 2. And another item
197
- 2. And the third one
198
- with additional text
199
- {kdexample}
200
-
201
- As with block quotes, you may be lazy when using the list item marker:
202
-
203
- {kdexample::}
204
- * A list item
205
- with additional text
206
- {kdexample}
207
-
208
- As the content consists of block-level elements you can do things like the following:
209
-
210
- {kdexample::}
211
- 1. This is a list item
212
-
213
- > with a blockquote
214
-
215
- # And a header
216
-
217
- 2. Followed by another item
218
- {kdexample}
219
-
220
- Nested lists are also easy to create:
221
-
222
- {kdexample::}
223
- 1. Item one
224
- 1. sub item one
225
- 2. sub item two
226
- 3. sub item three
227
- 2. Item two
228
- {kdexample}
229
-
230
- Lists can occur directly after other block-level elements, however, there has to be at least one
231
- blank line if you want to follow a paragraph with a list:
232
-
233
- {kdexample::}
234
- This is a paragraph.
235
- 1. This is NOT a list.
236
-
237
- 1. This is a list!
238
- {kdexample}
239
-
240
- Unordered lists are started by using an asterisk, a dash or a plus sign (they can be mixed) and a
241
- space. Apart from that unordered lists follow the same rules as ordered lists:
242
-
243
- {kdexample::}
244
- * Item one
245
- + Item two
246
- - Item three
247
- {kdexample}
248
-
249
- ## Definition Lists
250
-
251
- {kdlink: {oid: definition-lists, part: "definition lists"}}
252
-
253
- A definition list works similar to a normal list and is used to associate definitions with terms.
254
- Definition lists are started when a normal paragraph is followed by a line starting with a colon and
255
- then the definition text. One term can have many definitions and multiple terms can have the same
256
- definition. Each line of the preceding paragraph is assumed to contain one term, for example:
257
-
258
- {kdexample::}
259
- term
260
- : definition
261
- : another definition
262
-
263
- another term
264
- and another term
265
- : and a definition for the term
266
- {kdexample}
267
-
268
- If you insert a blank line before a definition (note: there must only be one blank line between the
269
- terms and the first definition), the definition will be wrapped in a paragraph:
270
-
271
- {kdexample::}
272
- term
273
-
274
- : definition
275
- : definition
276
- {kdexample}
277
-
278
- Each term can be styled using span-level elements and each definition is parsed as block-level
279
- elements, i.e. you can use any block-level in a definition. Just use the same indent for the lines
280
- following the definition line:
281
-
282
- {kdexample::}
283
- This *is* a term
284
-
285
- : This will be a para
286
-
287
- > a blockquote
288
-
289
- # A header
290
- {kdexample}
291
-
292
-
293
- ## Tables
294
-
295
- {kdlink: {oid: tables, part: "tables"}}
296
-
297
- kramdown supports a syntax for creating simple tables. A line starting with a pipe character (`|`)
298
- starts a table row. However, if the pipe characters is immediately followed by a dash (`-`), a
299
- separator line is created. Separator lines are used to split the table header from the table body
300
- (and optionally align the table columns) and to split the table body into multiple parts. If the
301
- pipe character is followed by an equal sign (`=`), the tables rows below it are part of the table
302
- footer.
303
-
304
- {kdexample::}
305
- | A simple | table |
306
- | with multiple | lines|
307
- {kdexample}
308
-
309
- {kdexample::}
310
- | Header1 | Header2 | Header3 |
311
- |:--------|:-------:|--------:|
312
- | cell1 | cell2 | cell3 |
313
- | cell4 | cell5 | cell6 |
314
- |----
315
- | cell1 | cell2 | cell3 |
316
- | cell4 | cell5 | cell6 |
317
- |=====
318
- | Foot1 | Foot2 | Foot3
319
- {: rules="groups"}
320
- {kdexample}
321
-
322
-
323
- ## HTML elements
324
-
325
- {kdlink: {oid: html-blocks, part: "HTML blocks"}}
326
-
327
- kramdown allows you to use block-level HTML tags (`div`, `p`, `pre`, ...) to markup whole blocks of
328
- text -- just start a line with a block-level HTML tag. kramdown syntax is normally not processed
329
- inside an HTML tag but this can be changed with the `parse_block_html` option. If this options is
330
- set to `true`, then the content of a block-level HTML tag is parsed by kramdown either as block
331
- level or span-level text, depending on the tag:
332
-
333
- {kdexample::}
334
- <div style="float: right">
335
- Something that stays right and is not wrapped in a para.
336
- </div>
337
-
338
- {::options parse_block_html="true" /}
339
-
340
- <div>
341
- This is wrapped in a para.
342
- </div>
343
- <p>
344
- This can contain only *span* level elements.
345
- </p>
346
- {kdexample}
347
-
348
-
349
- ## Block Attributes
350
-
351
- {kdlink: {oid: block-ials, part: "block IALs"}}
352
- {kdlink: {oid: attribute-list-definitions, part: "ALDs"}}
353
-
354
- You can assign any attribute to a block-level element. Just directly follow the block with a *block
355
- inline attribute list* (or short: block IAL). A block IAL consists of a left curly brace, followed
356
- by a colon, the attribute definitions and a right curly brace. Here is a simple example which sets the
357
- `title` attribute of a block quote:
358
-
359
- {kdexample::}
360
- > A nice blockquote
361
- {: title="Blockquote title"}
362
- {kdexample}
363
-
364
- As one often wants to set one or more CSS classes on an element, there is an easy shortcut:
365
-
366
- {kdexample::}
367
- > A nice blockquote
368
- {: .class1 .class2}
369
- {kdexample}
370
-
371
- A shortcut for setting the ID is also provided. Just prefix the ID with a hash symbol:
372
-
373
- {kdexample::}
374
- > A nice blockquote
375
- {: #with-an-id}
376
- {kdexample}
377
-
378
- Sometimes one wants to use the same attributes for many elements. kramdown allows you to define the
379
- attributes in one place with an *attribute list definition* (or short: ALD) and just reference this
380
- definition in a block IAL. An ALD has the same structure as a block IAL but the colon has to be
381
- replace with a colon, the reference name and another colon. By just using the reference name as-is
382
- in a block IAL, one can include the attributes of the referenced ALD:
383
-
384
- {kdexample::}
385
- {:refdef: .c1 #id .c2 title="title"}
386
- paragraph
387
- {: refdef}
388
- {kdexample}
389
-
390
- The order in a block IAL or ALD is important because later defined attributes overwrite (with the
391
- exception of the shortcut for CSS classes) prior defined attributes:
392
-
393
- {kdexample::}
394
- {:refdef: .c1 #id .c2 title="title"}
395
- paragraph
396
- {: refdef .c3 title="t" #para}
397
- {kdexample}
398
-
399
-
400
- ## Extensions
401
-
402
- {kdlink: {oid: extensions, part: "extensions"}}
403
-
404
- kramdown provides some less used functionality through a common syntax. This will allow the easy
405
- addition of other extensions if need arises. Currently, there are extensions for ignoring text (i.e.
406
- treating text as comment), for inserting arbitrary text as-is into the output and for setting
407
- kramdown options.
408
-
409
- Here is an example that shows how to insert comments into text:
410
-
411
- {kdexample::}
412
- This is a paragraph
413
- {::comment}
414
- This is a comment which is
415
- completely ignored.
416
- {:/comment}
417
- ... paragraph continues here.
418
-
419
- Extensions can also be used
420
- inline {::nomarkdown}**see**{:/}!
421
- {kdexample}
422
-
423
- As one can see from the above example, the syntax for extensions is nearly identical to that of
424
- ALDs. However, there is no trailing colon after the extension name and the extension end tag needs a
425
- slash between the colon and the extension name. One can also use the short form of the end tag, i.e.
426
- `{:/}`. Attribute definitions can be specified on the start tag by separating them with a space from
427
- the extension name. Also, if the extension does not have a body, there needs to be a slash right
428
- before the closing brace:
429
-
430
- {kdexample::}
431
- {::options auto_ids="false" /}
432
-
433
- # Header without id
434
- {kdexample}
435
-
436
-
437
-
438
-
439
- # Span-Level Elements - Text Modifiers
440
-
441
- ## Emphasis
442
-
443
- {kdlink: {oid: emphasis, part: "emphasis"}}
444
-
445
- Emphasis can be added to text by surrounding the text with either asterisks or underscores:
446
-
447
- {kdexample::}
448
- This is *emphasized*,
449
- _this_ too!
450
- {kdexample}
451
-
452
- Strong emphasis can be done by doubling the delimiters:
453
-
454
- {kdexample::}
455
- This is **strong**,
456
- __this__ too!
457
- {kdexample}
458
-
459
- The form with the asterisks can also be used to markup parts of words:
460
-
461
- {kdexample::}
462
- This w**ork**s as expected!
463
- {kdexample}
464
-
465
-
466
- ## Links and Images
467
-
468
- {kdlink: {oid: links-and-images, part: "links and images"}}
469
-
470
- A simple link can be created by surrounding the text with square brackets and the link URL with
471
- parentheses:
472
-
473
- {kdexample::}
474
- A [link](http://kramdown.gettalong.org)
475
- to the kramdown homepage.
476
- {kdexample}
477
-
478
- You can also add title information to the link:
479
-
480
- {kdexample::}
481
- A [link](http://kramdown.gettalong.org "hp")
482
- to the homepage.
483
- {kdexample}
484
-
485
- There is another way to create links which does not interrupt the text flow. The URL and title are
486
- defined using a reference name and this reference name is then used in square brackets instead of
487
- the link URL:
488
-
489
- {kdexample::}
490
- A [link][kramdown hp]
491
- to the homepage.
492
-
493
- [kramdown hp]: http://kramdown.gettalong.org "hp"
494
- {kdexample}
495
-
496
- If the link text itself is the reference name, the second set of square brackets can be omitted:
497
-
498
- {kdexample::}
499
- A link to the [kramdown hp].
500
-
501
- [kramdown hp]: http://kramdown.gettalong.org "hp"
502
- {kdexample}
503
-
504
- Images can be created in a similar way: just use an exclamation mark before the square brackets. The
505
- link text will become the alternative text of the image and the link URL specifies the image source:
506
-
507
- {kdexample::}
508
- An image: ![gras](img/image.jpg)
509
- {kdexample}
510
-
511
-
512
- ## Inline Code
513
-
514
- {kdlink: {oid: code-spans, part: "code spans"}}
515
-
516
- Text phrases can be easily marked up as code by surrounding them with backticks:
517
-
518
- {kdexample::}
519
- Use `Kramdown::Document.new(text).to_html`
520
- to convert the `text` in kramdown
521
- syntax to HTML.
522
- {kdexample}
523
-
524
- If you want to use literal backticks in your code, just use two or more backticks as delimiters. The
525
- space right after the beginning delimiter and the one right before the closing delimiter are ignored:
526
-
527
- {kdexample::}
528
- Use backticks to markup code,
529
- e.g. `` `code` ``.
530
- {kdexample}
531
-
532
-
533
- ## Footnotes
534
-
535
- {kdlink: {oid: footnotes, part: "footnotes"}}
536
-
537
- Footnotes can easily be used in kramdown. Just set a footnote marker (consists of square brackets
538
- with a caret and the footnote name inside) in the text and somewhere else the footnote definition (which
539
- basically looks like a reference link definition):
540
-
541
- {kdexample::}
542
- This is a text with a
543
- footnote[^1].
544
-
545
- [^1]: And here is the definition.
546
- {kdexample}
547
-
548
- The footnote definition can contain any block-level element, all lines following a footnote
549
- definition indented with four spaces or one tab belong to the definition:
550
-
551
- {kdexample::}
552
- This is a text with a
553
- footnote[^2].
554
-
555
- [^2]:
556
- And here is the definition.
557
-
558
- > With a quote!
559
- {kdexample}
560
-
561
- As can be seen above the footnote name is only used for the anchors and the numbering is done
562
- automatically in document order. Repeated footnote markers will link to the same footnote
563
- definition.
564
-
565
-
566
- ## Abbreviations
567
-
568
- {kdlink: {oid: abbreviations, part: "abbreviations"}}
569
-
570
- Abbreviations will work out of the box once you add an abbreviation definition. So you can just
571
- write the text and add the definitions later on.
572
-
573
- {kdexample::}
574
- This is an HTML
575
- example.
576
-
577
- *[HTML]: Hyper Text Markup Language
578
- {kdexample}
579
-
580
-
581
- ## HTML Elements
582
-
583
- {kdlink: {oid: html-spans, part: "HTML spans"}}
584
-
585
- HTML is not only supported on the block-level but also on the span-level:
586
-
587
- {kdexample::}
588
- This is <span style="color: red">written in
589
- red</span>.
590
- {kdexample}
591
-
592
-
593
- ## Inline Attributes
594
-
595
- {kdlink: {oid: span-ials, part: "span IALs"}}
596
-
597
- As with a block-level element you can assign any attribute to a span-level elements using a *span
598
- inline attribute list* (or short: span IAL). A span IAL has the same syntax as a block IAL and must
599
- immediately follow the span-level element:
600
-
601
- {kdexample::}
602
- This is *red*{: style="color: red"}.
603
- {kdexample}