kramdown 0.6.0 → 0.7.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 (66) hide show
  1. data/ChangeLog +346 -0
  2. data/Rakefile +36 -29
  3. data/VERSION +1 -1
  4. data/benchmark/testing.sh +1 -1
  5. data/bin/kramdown +0 -4
  6. data/doc/index.page +1 -1
  7. data/doc/links.markdown +4 -0
  8. data/doc/news.page +2 -1
  9. data/doc/quickref.page +134 -125
  10. data/doc/syntax.page +304 -302
  11. data/lib/kramdown/converter/base.rb +14 -0
  12. data/lib/kramdown/converter/html.rb +64 -2
  13. data/lib/kramdown/converter/latex.rb +14 -7
  14. data/lib/kramdown/document.rb +7 -3
  15. data/lib/kramdown/options.rb +13 -1
  16. data/lib/kramdown/parser/kramdown.rb +70 -17
  17. data/lib/kramdown/parser/kramdown/abbreviation.rb +65 -0
  18. data/lib/kramdown/parser/kramdown/attribute_list.rb +2 -1
  19. data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
  20. data/lib/kramdown/parser/kramdown/blockquote.rb +1 -1
  21. data/lib/kramdown/parser/kramdown/codeblock.rb +2 -2
  22. data/lib/kramdown/parser/kramdown/eob.rb +1 -1
  23. data/lib/kramdown/parser/kramdown/extension.rb +86 -6
  24. data/lib/kramdown/parser/kramdown/header.rb +2 -17
  25. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
  26. data/lib/kramdown/parser/kramdown/list.rb +8 -2
  27. data/lib/kramdown/parser/kramdown/math.rb +1 -1
  28. data/lib/kramdown/parser/kramdown/paragraph.rb +1 -1
  29. data/lib/kramdown/parser/kramdown/smart_quotes.rb +2 -2
  30. data/lib/kramdown/parser/kramdown/table.rb +1 -1
  31. data/lib/kramdown/version.rb +1 -1
  32. data/man/man1/kramdown.1 +77 -63
  33. data/test/testcases/block/04_header/with_auto_id_prefix.html +3 -0
  34. data/test/testcases/block/04_header/with_auto_id_prefix.options +2 -0
  35. data/test/testcases/block/04_header/with_auto_id_prefix.text +3 -0
  36. data/test/testcases/block/08_list/item_ial.html +9 -0
  37. data/test/testcases/block/08_list/item_ial.text +5 -0
  38. data/test/testcases/block/11_ial/auto_id_and_ial.html +1 -1
  39. data/test/testcases/block/11_ial/auto_id_and_ial.text +1 -1
  40. data/test/testcases/block/11_ial/simple.html +5 -0
  41. data/test/testcases/block/11_ial/simple.text +7 -0
  42. data/test/testcases/block/12_extension/comment.text +5 -5
  43. data/test/testcases/block/12_extension/ignored.html +0 -2
  44. data/test/testcases/block/12_extension/ignored.text +3 -6
  45. data/test/testcases/block/12_extension/nomarkdown.text +4 -4
  46. data/test/testcases/block/12_extension/options.html +1 -1
  47. data/test/testcases/block/12_extension/options.text +5 -6
  48. data/test/testcases/block/12_extension/options2.text +1 -1
  49. data/test/testcases/block/12_extension/options3.text +1 -1
  50. data/test/testcases/span/abbreviations/abbrev.html +8 -0
  51. data/test/testcases/span/abbreviations/abbrev.text +15 -0
  52. data/test/testcases/span/abbreviations/abbrev_defs.html +2 -0
  53. data/test/testcases/span/abbreviations/abbrev_defs.text +5 -0
  54. data/test/testcases/span/extension/comment.html +6 -0
  55. data/test/testcases/span/extension/comment.text +6 -0
  56. data/test/testcases/span/extension/ignored.html +1 -0
  57. data/test/testcases/span/extension/ignored.text +1 -0
  58. data/test/testcases/span/extension/nomarkdown.html +1 -0
  59. data/test/testcases/span/extension/nomarkdown.text +1 -0
  60. data/test/testcases/span/extension/options.html +1 -0
  61. data/test/testcases/span/extension/options.text +1 -0
  62. data/test/testcases/span/ial/simple.html +2 -1
  63. data/test/testcases/span/ial/simple.text +1 -0
  64. data/test/testcases/span/text_substitutions/typography.html +3 -0
  65. data/test/testcases/span/text_substitutions/typography.text +3 -0
  66. metadata +275 -263
data/doc/syntax.page CHANGED
@@ -17,19 +17,16 @@ it strives to provide a strict syntax with definite rules and therefore isn't co
17
17
  with Markdown. Nonetheless, most Markdown documents should work fine when parsed with kramdown. All
18
18
  places where the kramdown syntax differs from the Markdown syntax are highlighted.
19
19
 
20
- Following is the complete syntax definition so that you know what you will get when a kramdown
21
- document is converted to, for example, HTML.
22
-
23
- [Maruku]: http://maruku.rubyforge.org
24
- [PHP Markdown Extra]: http://michelf.com/projects/php-markdown/extra/
25
- [Pandoc]: http://johnmacfarlane.net/pandoc/
20
+ Following is the complete syntax definition for all elements kramdown supports. Together with the
21
+ documentation on the available converters, it is clearly specified what you will get when a kramdown
22
+ document is converted.
26
23
 
27
24
 
28
25
  ## Source Text Formatting
29
26
 
30
27
  A kramdown document may be in any encoding, for example ASCII, UTF-8 or ISO-8859-1, and the output
31
- will have the same encoding as the source. It consists of two types of elements, block level
32
- elements and span level elements:
28
+ will have the same encoding as the source. The document consists of two types of elements, block
29
+ level elements and span level elements:
33
30
 
34
31
  * Block level elements define the main structure of the content, for example, what part of the text
35
32
  should be a paragraph, a list, a blockquote and so on.
@@ -38,6 +35,12 @@ elements and span level elements:
38
35
 
39
36
  Thus span level elements can only occur inside block level elements or other span level elements.
40
37
 
38
+ You will often find references to the "first column" or "first character" of a line in a block level
39
+ element descriptions. Such a reference is always to be taken relative to the current indentation
40
+ level because some block level elements open up a new indentation level (e.g. blockquotes). The
41
+ beginning of a kramdown document opens up the default indentation level which begins at the first
42
+ column of the text.
43
+
41
44
 
42
45
  ### Usage of Tabs
43
46
 
@@ -57,9 +60,9 @@ This means, for example, that you can just use `<`, `>` and `&` in a kramdown do
57
60
  think about when to use their HTML entity counterparts. However, if you *do use* HTML entitys or
58
61
  HTML tags which use one of the characters, the result will be correct nonetheless!
59
62
 
60
- Since kramdown also uses some characters to mark-up the text, there need to be a way to escape these
61
- special characters so that they can have their normal meaning. This can be done by using backslash
62
- escapes. For example, you can use a literal backtick like this:
63
+ Since kramdown also uses some characters to mark-up the text, there needs to be a way to escape
64
+ these special characters so that they can have their normal meaning. This can be done by using
65
+ backslash escapes. For example, you can use a literal backtick like this:
63
66
 
64
67
  This \`is not a code\` span!
65
68
 
@@ -84,16 +87,10 @@ Following is a list of all the characters (character sequences) that can be esca
84
87
  $ dollar sign
85
88
 
86
89
 
87
- # Block Level Elements
90
+ # Structural Elements
88
91
 
89
- Block level elements are used to structure the content. They can mark up some text as, for example,
90
- a simple paragraph, a quote or as a list item.
91
-
92
- You will often find references to the "first column" or "first character" of a line in the block
93
- level element descriptions. Such a reference is always to be taken relative to the current
94
- indentation level because some block level elements open up a new indentation level (e.g.
95
- blockquotes). The beginning of a kramdown document opens up the default indentation level which
96
- begins at the first column of the text.
92
+ All structural elements are block level elements and they are used to structure the content. They
93
+ can mark up some text as, for example, a simple paragraph, a quote or as a list item.
97
94
 
98
95
 
99
96
  ## Blank lines
@@ -109,33 +106,6 @@ meaning:
109
106
  * When used in lists -- see the [lists section](#lists)
110
107
 
111
108
 
112
- ## End-Of-Block Marker {#eob-marker}
113
-
114
- > The EOB marker is not part of the standard Markdown syntax.
115
- {: .markdown-difference}
116
-
117
- The End-Of-Block (EOB) marker -- a `^` as first character on an otherwise empty line -- can be used
118
- to specify the end of a block level element even if the block level element, after which it is used,
119
- would continue otherwise. If there is no block level element to end, the EOB marker is simply
120
- ignored.
121
-
122
- You won't find an EOB marker in most kramdown documents but sometimes it is necessary to use it to
123
- achieve the wanted results which would be impossible otherwise. However, it should only be used when
124
- absolutely necesary!
125
-
126
- For example, the following gives you one list with two items:
127
-
128
- * list item one
129
-
130
- * list item two
131
-
132
- By using an EOB marker, you can make two lists with one item each:
133
-
134
- * list one
135
- ^
136
- * list two
137
-
138
-
139
109
  ## Paragraphs
140
110
 
141
111
  Paragraphs are the most used block level elements. One or more consecutive lines of text are
@@ -160,7 +130,8 @@ The following gives you an example of how paragraphs look like:
160
130
 
161
131
  ## Headers
162
132
 
163
- kramdown supports so called Setext style and atx style headers.
133
+ kramdown supports so called Setext style and atx style headers. Both forms can be used inside a
134
+ single document.
164
135
 
165
136
  ### Setext Style
166
137
 
@@ -231,56 +202,14 @@ the header text. For example:
231
202
  > Again, the original Markdown syntax allows one to omit the blank line before an atx style header.
232
203
  {: .markdown-difference}
233
204
 
234
- ### Automatic Generation of Header IDs
235
-
236
- kramdown supports the automatic generation of header IDs if the option `auto_ids` is set to `true`
237
- (which is the default). This is done by converting the untransformed, i.e. plain, header text via the
238
- following steps:
239
-
240
- * All characters except letters, numbers, spaces and dashes are removed.
241
- * All characters from the start of the line until the first letter are removed.
242
- * Everything except letters and numbers is converted to dashes.
243
- * Everything is lowercased.
244
- * If nothing is left, the identifier `section` is used.
245
- * If a such created identifier already exists, a dash and a sequential number is added (first `-1`,
246
- then `-2` and so on).
247
-
248
- Following are some examples of header texts and their respective generated IDs:
249
-
250
- # This is a header
251
- auto_id: this-is-a-header
252
-
253
- ## 12. Another one 1 here
254
- auto_id: another-one-1-here
255
-
256
- ### Do ^& it now
257
- auto_id: do--it-now
258
-
259
- Hallo
260
- =====
261
- auto_id: hallo
262
-
263
- Not now
264
- -------
265
- auto_id: not-now
266
-
267
- # Hallo
268
- auto_id: hallo-1
269
-
270
- # 123456789
271
- auto_id: section
272
-
273
- > The automatic creation of header IDs is not part of standard Markdown. The rules on how header
274
- > text is converted to an identifier are based on the rules specified by [Pandoc].
275
- {: .markdown-difference}
276
205
 
277
- ### Manually Specifying a Header ID
206
+ ### Specifying a Header ID
278
207
 
279
- Additionally to automatic header ID generation, kramdown supports a nice way for explicitly setting
280
- the header ID which is taken from [PHP Markdown Extra] and [Maruku]: If you follow the header text
281
- with an opening curly bracket (separated from the text with a least one space), a hash, the ID and a
282
- closing curly bracket, the ID is set on the header. If you use the trailing hash feature of atx
283
- style headers, the header ID has to go after the trailing hashes. For example:
208
+ kramdown supports a nice way for explicitly setting the header ID which is taken from [PHP Markdown
209
+ Extra] and [Maruku]: If you follow the header text with an opening curly bracket (separated from the
210
+ text with a least one space), a hash, the ID and a closing curly bracket, the ID is set on the
211
+ header. If you use the trailing hash feature of atx style headers, the header ID has to go after the
212
+ trailing hashes. For example:
284
213
 
285
214
  Hello {#id}
286
215
  -----
@@ -390,49 +319,6 @@ example:
390
319
  This type of code block is especially useful for copy-pasted code since you don't need to indent the
391
320
  code.
392
321
 
393
- ### Showing Whitespace in a Code Block
394
-
395
- It is sometimes useful to visualize whitespace within a code block. This can be achieved in kramdown
396
- by adding the class `show-whitespaces` to a code block (using a [block
397
- IAL](#block-inline-attribute-lists)).
398
-
399
- Here is an example where the whitespaces are shown:
400
-
401
- leading tab and space
402
- trailing tab and space
403
- {: .show-whitespaces}
404
-
405
-
406
- ### Automatic Syntax Highlighting {#syntax-highlighting}
407
-
408
- kramdown supports syntax highlighting of code. Just add the key `lang` to a code block (using a
409
- [block IAL](#block-inline-attribute-lists)) and it will be highlighted using the specified language.
410
- Details on the supported languages can be found in the documentation for each converter.
411
-
412
- Here is an example on how Ruby code is highlighted:
413
-
414
- require 'kramdown'
415
-
416
- Kramdown::Document.new('* something').to_html
417
- puts 1 + 1
418
- {: lang='ruby'}
419
-
420
-
421
- ## Horizontal Rules
422
-
423
- A horizontal rule for visually separating content is created by using three or more asterisks,
424
- dashes or underscores (these may not be mixed on a line), optionally separated by spaces or tabs, on
425
- an otherwise blank line. The first asterisk, dash or underscore may optionally be indented up to
426
- three spaces. The following examples show different possibilities to create a horizontal rule:
427
-
428
- * * *
429
-
430
- ---
431
-
432
- _ _ _ _
433
-
434
- ---------------
435
-
436
322
 
437
323
  ## Lists
438
324
 
@@ -445,7 +331,8 @@ Both ordered and unordered lists follow the same rules.
445
331
 
446
332
  A list is started with a list marker (in case of unordered lists one of `+`, `-` or `*` -- you can
447
333
  mix them -- and in case of ordered lists a number followed by a period) followed by one tab or at
448
- least one space and then the first part of the content of the list item. The leading tabs or spaces
334
+ least one space, optionally followed by an [IAL](#inline-attribute-lists) that should be applied to
335
+ the list item and then the first part of the content of the list item. The leading tabs or spaces
449
336
  are stripped away from this first line of content to allow for a nice alignment with the following
450
337
  content of a list item (see below). All following list items with the same marker type (unordered or
451
338
  ordered) are put into the same list. The numbers used for ordered lists are irrelevant, an ordered
@@ -624,6 +511,14 @@ useful when the paragraph starts with something looking like a list item marker)
624
511
  1984\. It was great
625
512
  \- others say that, too!
626
513
 
514
+ As mentioned at the beginning, an optional IAL for applying attributes to a list item can be used
515
+ after the list item marker:
516
+
517
+ * {:.cls} This item has the class "cls".
518
+ Here continues the above paragraph.
519
+
520
+ * This is a normal list item.
521
+
627
522
 
628
523
  ### Definition Lists
629
524
 
@@ -820,6 +715,22 @@ editor. However, the table syntax is flexible and the above table could also be
820
715
  | Footer row
821
716
 
822
717
 
718
+ ## Horizontal Rules
719
+
720
+ A horizontal rule for visually separating content is created by using three or more asterisks,
721
+ dashes or underscores (these may not be mixed on a line), optionally separated by spaces or tabs, on
722
+ an otherwise blank line. The first asterisk, dash or underscore may optionally be indented up to
723
+ three spaces. The following examples show different possibilities to create a horizontal rule:
724
+
725
+ * * *
726
+
727
+ ---
728
+
729
+ _ _ _ _
730
+
731
+ ---------------
732
+
733
+
823
734
  ## Math Blocks
824
735
 
825
736
  > This syntax feature is not part of the original Markdown syntax. The idea comes from the [Maruku]
@@ -1038,167 +949,8 @@ comments is not processed:
1038
949
  continues here.
1039
950
 
1040
951
 
1041
- ## Attribute List Definitions
1042
-
1043
- > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1044
- > the [Maruku] package.
1045
- {: .markdown-difference}
1046
-
1047
- This is an implementation of [Maruku]'s feature for adding attributes to block and span level
1048
- elements (the naming is also taken from Maruku). This block level element is used to define
1049
- attributes which can be referenced later. The [Block Inline Attribute
1050
- List](#block-inline-attribute-lists) is used to attach attributes to a block level element and the
1051
- [Span Inline Attribute List](#span-inline-attribute-lists) is used to attach attributes to a span
1052
- level element.
1053
-
1054
- Following are some examples of attribute list definitions (ALDs) and afterwards comes the syntax
1055
- explanation:
1056
-
1057
- {:ref-name: #myid .my-class}
1058
- {:other: ref-name #id-of-other title="hallo you"}
1059
- {:test: key="value \" with quote" and other='quote brace \}'}
1060
-
1061
- An ALD line has the following structure:
1062
-
1063
- * a left brace, optionally preceded by up to three spaces,
1064
- * followed by a colon, the reference name and another colon,
1065
- * followed by attribute definitions (allowed characters are backslash-escaped closing braces or any
1066
- character except a not escaped closing brace),
1067
- * followed by a closing brace and optional spaces until the end of the line.
1068
-
1069
- The reference name needs to start with a word character or a digit, optionally followed by other word
1070
- characters, digits or dashes.
1071
-
1072
- There are four different types of attribute definitions which have to be separated by one or more
1073
- spaces:
1074
-
1075
- references
1076
-
1077
- : This must be a valid reference name. It is used to reference an other ALD so that the attributes
1078
- of the other ALD are also included in this one. The reference name is ignored when collecting the
1079
- attributes if no attribute definition list with this reference name exists. For example, a
1080
- simple reference looks like `id`.
1081
-
1082
- key-value pairs
1083
-
1084
- : A key-value pair is defined by a key name, which must follow the rules for reference names, then
1085
- an equal sign and then the value in single or double quotes. If you need to use the value
1086
- delimiter (a single or a double quote) inside the value, you need to escape it with a backslash.
1087
- Key-value pairs can be used to specify arbitrary attributes for block or span level elements. For
1088
- example, a key-value pair looks like `key1="bef \"quoted\" aft"` or `title='This is a title'`.
1089
-
1090
- ID name
1091
-
1092
- : An ID name is defined by using a hash and then the identifier name which must follow the rules
1093
- for reference names. This is a short hand for the key-value pair `id="IDNAME"` since this is
1094
- often used. The ID name specifies the unique ID of a block or span level element. For example,
1095
- an ID name looks like `#myid`.
1096
-
1097
- class names
1098
-
1099
- : A class name is defined by using a dot and then the class name. This is (almost, but not quite)
1100
- a short hand for the key-value pair `class="class-name"`. Almost because it actually means that
1101
- the class name should be appended to the current value of the `class` attribute. The following
1102
- ALDs are all equivalent:
1103
-
1104
- {:id: .cls1 .cls2}
1105
- {:id: class="cls1" .cls2}
1106
- {:id: class="something" class="cls1" .cls2}
1107
- {:id: class="cls1 cls2}
1108
-
1109
- As can be seen from the example of the class names, attributes that are defined earlier are
1110
- overwritten by ones with the same name defined later. Also, everything in the attribute definitions
1111
- part that does not match one of the above four types is ignored.
1112
-
1113
- If there is more than one ALD with the same reference name, the attribute definitions of all the
1114
- ALDs are processed like they are defined in one ALD.
1115
-
1116
-
1117
- ## Block Inline Attribute Lists
1118
-
1119
- > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1120
- > the [Maruku] package.
1121
- {: .markdown-difference}
1122
-
1123
- This block level element is used to attach attributes to a block level element. A block inline
1124
- attribute list (block IAL) has the same structure as an [ALD](#attribute-list-definitions) except
1125
- that the colon/reference name/colon part is replaced by a colon. A block IAL (or two or more block
1126
- IALs) has to be put directly after the block level element to which the attributes should be
1127
- attached, otherwise it is ignored. This is, for example, the case when there is a blank line between
1128
- the block level element and the IAL.
1129
-
1130
- Key-value pairs of an IAL take precedence over equally named key-value pairs in referenced ALDs.
1131
-
1132
- Here are some examples for block IALs:
1133
-
1134
- A simple paragraph with an ID attribute.
1135
- {: #para-one}
1136
-
1137
- > A blockquote with a title
1138
- {:title="The blockquote title"}
1139
- {: #myid}
1140
-
1141
- Some code here
1142
- {:.ruby}
1143
-
1144
-
1145
- ## Extension Blocks
1146
-
1147
- > This syntax feature is not part of the original Markdown syntax.
1148
- {: .markdown-difference}
1149
-
1150
- Extension blocks can be used, for example, to treat whole sections of text specially. For example,
1151
- one could write an extension that highlights a code fragment specified in an extension block.
1152
-
1153
- An extension block has two forms, one with a body and one without a body:
1154
-
1155
- Without a body
1156
-
1157
- : The extension block line has the same structure as an [ALD](#attribute-list-definitions) except
1158
- that the reference name needs to prefixed and postfixed with `:` and identifies the extension to
1159
- be used. Attributes can be defined like it is done for an ALD.
1160
-
1161
- With a body
1162
-
1163
- : The starting and ending lines of an extension block with a body have the same structure as an
1164
- [ALD](#attribute-list-definitions) except that the reference name needs to prefixed with `:` and
1165
- identifies the extension to be used; attributes can be defined on the starting or ending line.
1166
- The text between the starting and ending line is passed to the extension and not parsed by
1167
- kramdown. If no ending line is found, the starting line is ignored and the body is parsed
1168
- normally by kramdown.
1169
-
1170
- If the specified extension is not found, a warning is shown and the whole extension block including
1171
- the body is ignored. The following extensions are built-in:
1172
-
1173
- `comment`
1174
-
1175
- : Treats the body text as a comment which does not show in the output.
1176
-
1177
- `nomarkdown`
1178
-
1179
- : The body is not processed with kramdown but output as-is.
1180
952
 
1181
- `options`
1182
-
1183
- : Should be used without a body since the body is ignored. Is used for setting the global options
1184
- for the kramdown processor (for example, to enable automatic header ID generation). Note that
1185
- options that are used by the parser are immediately effective whereas all other options are not!
1186
- This means, for example, that it is not possible to set converter options only for some part of
1187
- a kramdown document.
1188
-
1189
- Here are some examples for how extension blocks look like:
1190
-
1191
- {::toc::}
1192
-
1193
- The above extension block could be replaced by a table of contents.
1194
-
1195
- {::comment:}
1196
- This text is completely ignored by kramdown - a comment in the text.
1197
- {::comment:}
1198
-
1199
-
1200
-
1201
- # Span Level Elements
953
+ # Text Markup
1202
954
 
1203
955
  These elements are used inside block level elements to markup text fragments. For example, one can
1204
956
  easily create links or apply emphasis to certain text parts.
@@ -1481,6 +1233,39 @@ foot note definitions are ignored. If more than one footnote definitions have th
1481
1233
  name, all footnote definitions but the last are ignored.
1482
1234
 
1483
1235
 
1236
+ ## Abbreviations
1237
+
1238
+ > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1239
+ > the [PHP Markdown Extra] package.
1240
+ {: .markdown-difference}
1241
+
1242
+ kramdown provides a syntax to assign the full phrase to an abbreviation. When writing the text, you
1243
+ don't need to do anything special. However, once you add abbreviation definitions, the
1244
+ abbreviations in the text get marked up automatically. Abbreviations can consist of any character
1245
+ except a closing bracket.
1246
+
1247
+ An abbreviation definition is used to define the full phrase for an abbreviation and has the
1248
+ following structure:
1249
+
1250
+ * An asterisk and the abbreviation in square brackets, optionally indented up to three
1251
+ spaces,
1252
+ * then a colon and the full phrase of the abbreviation on one line (leading and trailing spaces are
1253
+ stripped from the full phrase).
1254
+
1255
+ Later abbreviation definition for the same abbreviation override prior ones and it does not matter
1256
+ where you put an abbreviation definition in a kramdown document. Empty definitions are also allowed.
1257
+
1258
+ Here are some examples:
1259
+
1260
+ This is some text not written in HTML but in another language!
1261
+
1262
+ *[another language]: It's called Markdown
1263
+ *[HTML]: HyperTextMarkupLanguage
1264
+
1265
+ > Abbreviation definitions are, despite being described here, block level elements.
1266
+ {: .information}
1267
+
1268
+
1484
1269
  ## Typographic Symbols
1485
1270
 
1486
1271
  > The original Markdown syntax does not support these transformations.
@@ -1501,7 +1286,149 @@ when kramdown falsely replace the quotes. If this is the case, just \'escape\" t
1501
1286
  won't be replaced with fancy ones.
1502
1287
 
1503
1288
 
1504
- ## Span Inline Attribute Lists
1289
+
1290
+ # Other Markup
1291
+
1292
+ This section describes markup that is not widely used in kramdown documents but which are sometimes
1293
+ needed nonetheless.
1294
+
1295
+
1296
+ ## End-Of-Block Marker {#eob-marker}
1297
+
1298
+ > The EOB marker is not part of the standard Markdown syntax.
1299
+ {: .markdown-difference}
1300
+
1301
+ The End-Of-Block (EOB) marker -- a `^` as first character on an otherwise empty line -- is a block
1302
+ level element that can be used to specify the end of a block level element even if the block level
1303
+ element, after which it is used, would continue otherwise. If there is no block level element to
1304
+ end, the EOB marker is simply ignored.
1305
+
1306
+ You won't find an EOB marker in most kramdown documents but sometimes it is necessary to use it to
1307
+ achieve the wanted results which would be impossible otherwise. However, it should only be used when
1308
+ absolutely necesary!
1309
+
1310
+ For example, the following gives you one list with two items:
1311
+
1312
+ * list item one
1313
+
1314
+ * list item two
1315
+
1316
+ By using an EOB marker, you can make two lists with one item each:
1317
+
1318
+ * list one
1319
+ ^
1320
+ * list two
1321
+
1322
+
1323
+ ## Attribute List Definitions
1324
+
1325
+ > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1326
+ > the [Maruku] package.
1327
+ {: .markdown-difference}
1328
+
1329
+ This is an implementation of [Maruku]'s feature for adding attributes to block and span level
1330
+ elements (the naming is also taken from Maruku). This block level element is used to define
1331
+ attributes which can be referenced later. The [Block Inline Attribute
1332
+ List](#block-inline-attribute-lists) is used to attach attributes to a block level element and the
1333
+ [Span Inline Attribute List](#span-inline-attribute-lists) is used to attach attributes to a span
1334
+ level element.
1335
+
1336
+ Following are some examples of attribute list definitions (ALDs) and afterwards comes the syntax
1337
+ explanation:
1338
+
1339
+ {:ref-name: #myid .my-class}
1340
+ {:other: ref-name #id-of-other title="hallo you"}
1341
+ {:test: key="value \" with quote" and other='quote brace \}'}
1342
+
1343
+ An ALD line has the following structure:
1344
+
1345
+ * a left brace, optionally preceded by up to three spaces,
1346
+ * followed by a colon, the reference name and another colon,
1347
+ * followed by attribute definitions (allowed characters are backslash-escaped closing braces or any
1348
+ character except a not escaped closing brace),
1349
+ * followed by a closing brace and optional spaces until the end of the line.
1350
+
1351
+ The reference name needs to start with a word character or a digit, optionally followed by other word
1352
+ characters, digits or dashes.
1353
+
1354
+ There are four different types of attribute definitions which have to be separated by one or more
1355
+ spaces:
1356
+
1357
+ references
1358
+
1359
+ : This must be a valid reference name. It is used to reference an other ALD so that the attributes
1360
+ of the other ALD are also included in this one. The reference name is ignored when collecting the
1361
+ attributes if no attribute definition list with this reference name exists. For example, a
1362
+ simple reference looks like `id`.
1363
+
1364
+ key-value pairs
1365
+
1366
+ : A key-value pair is defined by a key name, which must follow the rules for reference names, then
1367
+ an equal sign and then the value in single or double quotes. If you need to use the value
1368
+ delimiter (a single or a double quote) inside the value, you need to escape it with a backslash.
1369
+ Key-value pairs can be used to specify arbitrary attributes for block or span level elements. For
1370
+ example, a key-value pair looks like `key1="bef \"quoted\" aft"` or `title='This is a title'`.
1371
+
1372
+ ID name
1373
+
1374
+ : An ID name is defined by using a hash and then the identifier name which must follow the rules
1375
+ for reference names. This is a short hand for the key-value pair `id="IDNAME"` since this is
1376
+ often used. The ID name specifies the unique ID of a block or span level element. For example,
1377
+ an ID name looks like `#myid`.
1378
+
1379
+ class names
1380
+
1381
+ : A class name is defined by using a dot and then the class name. This is (almost, but not quite)
1382
+ a short hand for the key-value pair `class="class-name"`. Almost because it actually means that
1383
+ the class name should be appended to the current value of the `class` attribute. The following
1384
+ ALDs are all equivalent:
1385
+
1386
+ {:id: .cls1 .cls2}
1387
+ {:id: class="cls1" .cls2}
1388
+ {:id: class="something" class="cls1" .cls2}
1389
+ {:id: class="cls1 cls2}
1390
+
1391
+ As can be seen from the example of the class names, attributes that are defined earlier are
1392
+ overwritten by ones with the same name defined later. Also, everything in the attribute definitions
1393
+ part that does not match one of the above four types is ignored.
1394
+
1395
+ If there is more than one ALD with the same reference name, the attribute definitions of all the
1396
+ ALDs are processed like they are defined in one ALD.
1397
+
1398
+
1399
+ ## Inline Attribute Lists
1400
+
1401
+ These elements are used to attach attributes to another element.
1402
+
1403
+ ### Block Inline Attribute Lists
1404
+
1405
+ > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1406
+ > the [Maruku] package.
1407
+ {: .markdown-difference}
1408
+
1409
+ This block level element is used to attach attributes to a block level element. A block inline
1410
+ attribute list (block IAL) has the same structure as an [ALD](#attribute-list-definitions) except
1411
+ that the colon/reference name/colon part is replaced by a colon. A block IAL (or two or more block
1412
+ IALs) has to be put directly before or after the block level element to which the attributes should
1413
+ be attached. If a block IAL is directly after *and* before a block level element, it is applied to
1414
+ preceding element. The block IAL is ignored in all other cases, for example, when the block IAL is
1415
+ surrounded by blank lines.
1416
+
1417
+ Key-value pairs of an IAL take precedence over equally named key-value pairs in referenced ALDs.
1418
+
1419
+ Here are some examples for block IALs:
1420
+
1421
+ A simple paragraph with an ID attribute.
1422
+ {: #para-one}
1423
+
1424
+ > A blockquote with a title
1425
+ {:title="The blockquote title"}
1426
+ {: #myid}
1427
+
1428
+ {:.ruby}
1429
+ Some code here
1430
+
1431
+ ### Span Inline Attribute Lists
1505
1432
 
1506
1433
  > This syntax feature is not part of the original Markdown syntax. The idea and syntax comes from
1507
1434
  > the [Maruku] package.
@@ -1510,9 +1437,84 @@ won't be replaced with fancy ones.
1510
1437
  This is a version of the [block inline attribute list](#block-inline-attribute-lists) for span level
1511
1438
  elements. It has the same structure as the block IAL except that leading and trailing spaces are not
1512
1439
  allowed. A span IAL (or two or more span IALs) has to be put directly after the span level element
1513
- to which it should be applied, no additional character is allowed between.
1440
+ to which it should be applied, no additional character is allowed between, otherwise it is ignored
1441
+ and only removed from the output.
1514
1442
 
1515
1443
  Here are some examples for span IALs:
1516
1444
 
1517
1445
  This *is*{:.underline} some `code`{:#id}{:.class}.
1518
1446
  A [link](test.html){:rel='something'} and some **tools**{:.tools}.
1447
+
1448
+
1449
+ ## Extensions
1450
+
1451
+ > This syntax feature is not part of the original Markdown syntax.
1452
+ {: .markdown-difference}
1453
+
1454
+ Extensions provide additional functionality but use the same syntax for it. They are available as
1455
+ block as well as span level elements.
1456
+
1457
+ The syntax for an extension is very similar to the syntax of [ALDs](#attribute-list-definitions).
1458
+ Here are some examples of how to specify extensions and afterwards is the syntax definition:
1459
+
1460
+ {::comment}
1461
+ This text is completely ignored by kramdown - a comment in the text.
1462
+ {:/comment}
1463
+
1464
+ Do you see {::comment}this text{:/comment}?
1465
+ {::comment}some other comment{:/}
1466
+
1467
+ {::options key="val" /}
1468
+
1469
+ An extension can be specified with or without a body. Therefore there exist a start and an end tag
1470
+ for extensions. The start tag has the following structure:
1471
+
1472
+ * an left brace,
1473
+ * followed by two colons and the extension name,
1474
+ * optionally followed by a space and attribute definitions (allowed characters are backslash-escaped
1475
+ closing braces or any character except a not escaped closing brace -- same as with ALDs),
1476
+ * followed by a slash and a right brace (in case the extension has no body) or only a right
1477
+ brace (in case the extension has a body).
1478
+
1479
+ The stop tag has the following structure:
1480
+
1481
+ * a left brace,
1482
+ * followed by a colon and a slash,
1483
+ * optionally followed by the extension name,
1484
+ * followed by a right brace.
1485
+
1486
+ A stop tag is only needed if the extension has a body!
1487
+
1488
+ The above syntax can be used as is for span level extensions. The starting and ending lines for block level
1489
+ extensions are defined as:
1490
+
1491
+ * The starting line consists of the extension start tag, optionally preceded by up to three spaces,
1492
+ and followed by optional spaces until the end of the line.
1493
+ * The ending line consists of the extension stop tag, optionally preceded by up to three spaces,
1494
+ and followed by optional spaces until the end of the line.
1495
+
1496
+ If no end tag can be found for an extension start tag, the start tag is treated as if it has no
1497
+ body. If an invalid extension stop tag is found, it is ignored. If an invalid extension name is
1498
+ specified the extension (and the eventually specified body) are ignored.
1499
+
1500
+ The following extensions can be used with kramdown:
1501
+
1502
+ `comment`
1503
+
1504
+ : Treat the body text as a comment which does not show in the output.
1505
+
1506
+ `nomarkdown`
1507
+
1508
+ : Don't process the body with kramdown but output it as-is.
1509
+
1510
+ `options`
1511
+
1512
+ : Should be used without a body since the body is ignored. Is used for setting the global options
1513
+ for the kramdown processor (for example, to disable automatic header ID generation). Note that
1514
+ options that are used by the parser are immediately effective whereas all other options are not!
1515
+ This means, for example, that it is not possible to set converter options only for some part of
1516
+ a kramdown document.
1517
+
1518
+
1519
+
1520
+ {include_file: doc/links.markdown}