kramdown 0.13.7 → 0.13.8
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.
- data/CONTRIBUTERS +5 -1
- data/ChangeLog +225 -0
- data/README.md +50 -0
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/doc/default.template +1 -1
- data/doc/sidebar.template +2 -2
- data/lib/kramdown/converter/base.rb +7 -0
- data/lib/kramdown/converter/html.rb +9 -6
- data/lib/kramdown/converter/kramdown.rb +4 -3
- data/lib/kramdown/converter/latex.rb +1 -1
- data/lib/kramdown/document.rb +29 -0
- data/lib/kramdown/options.rb +23 -2
- data/lib/kramdown/parser/kramdown/abbreviation.rb +2 -1
- data/lib/kramdown/version.rb +1 -1
- data/man/man1/kramdown.1 +142 -117
- data/test/test_files.rb +13 -2
- data/test/testcases/block/04_header/header_type_offset.html +11 -0
- data/test/testcases/block/04_header/header_type_offset.kramdown +12 -0
- data/test/testcases/block/04_header/header_type_offset.latex +12 -0
- data/test/testcases/block/04_header/header_type_offset.options +2 -0
- data/test/testcases/block/04_header/header_type_offset.text +13 -0
- data/test/testcases/block/06_codeblock/disable-highlighting.html +4 -0
- data/test/testcases/block/06_codeblock/disable-highlighting.options +1 -0
- data/test/testcases/block/06_codeblock/disable-highlighting.text +4 -0
- data/test/testcases/span/abbreviations/abbrev.html +2 -2
- data/test/testcases/span/abbreviations/abbrev.text +5 -2
- data/test/testcases/span/autolinks/url_links.html +2 -0
- data/test/testcases/span/autolinks/url_links.text +3 -0
- metadata +45 -53
- data/README +0 -43
@@ -117,7 +117,7 @@ module Kramdown
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def convert_header(el, opts)
|
120
|
-
type = @options[:latex_headers][el.options[:level] - 1]
|
120
|
+
type = @options[:latex_headers][output_header_level(el.options[:level]) - 1]
|
121
121
|
if ((id = el.attr['id']) ||
|
122
122
|
(@options[:auto_ids] && (id = generate_id(el.options[:raw_text])))) && in_toc?(el)
|
123
123
|
"\\#{type}{#{inner(el, opts)}}\\hypertarget{#{id}}{}\\label{#{id}}\n\n"
|
data/lib/kramdown/document.rb
CHANGED
@@ -19,6 +19,35 @@
|
|
19
19
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
20
|
#++
|
21
21
|
#
|
22
|
+
# = kramdown
|
23
|
+
#
|
24
|
+
# kramdown is yet-another-markdown-parser but fast, pure Ruby, using a strict syntax definition and
|
25
|
+
# supporting several common extensions.
|
26
|
+
#
|
27
|
+
# The kramdown library is mainly written to support the kramdown-to-HTML conversion chain. However,
|
28
|
+
# due to its flexibility it supports other input and output formats as well. Here is a list of the
|
29
|
+
# supported formats:
|
30
|
+
#
|
31
|
+
# * input formats: kramdown (a Markdown superset), Markdown, HTML
|
32
|
+
# * output formats: HTML, kramdown, LaTeX (and therefore PDF)
|
33
|
+
#
|
34
|
+
# All the documentation on the available input and output formats is available at
|
35
|
+
# http://kramdown.rubyforge.org.
|
36
|
+
#
|
37
|
+
# == Usage
|
38
|
+
#
|
39
|
+
# kramdown has a basic *Cloth API, so using kramdown is as easy as
|
40
|
+
#
|
41
|
+
# require 'kramdown'
|
42
|
+
#
|
43
|
+
# Kramdown::Document.new(text).to_html
|
44
|
+
#
|
45
|
+
# For detailed information have a look at the Kramdown::Document class.
|
46
|
+
#
|
47
|
+
# == License
|
48
|
+
#
|
49
|
+
# GPLv3 - see the COPYING file.
|
50
|
+
|
22
51
|
|
23
52
|
require 'kramdown/compatibility'
|
24
53
|
|
data/lib/kramdown/options.rb
CHANGED
@@ -241,6 +241,16 @@ footnote.
|
|
241
241
|
|
242
242
|
Default: 1
|
243
243
|
Used by: HTML converter
|
244
|
+
EOF
|
245
|
+
|
246
|
+
define(:enable_coderay, Boolean, true, <<EOF)
|
247
|
+
Use coderay for syntax highlighting
|
248
|
+
|
249
|
+
If this option is `true`, coderay is used by the HTML converter for
|
250
|
+
syntax highlighting the content of code spans and code blocks.
|
251
|
+
|
252
|
+
Default: true
|
253
|
+
Used by: HTML converter
|
244
254
|
EOF
|
245
255
|
|
246
256
|
define(:coderay_wrap, Symbol, :div, <<EOF)
|
@@ -294,7 +304,7 @@ Used by: HTML converter
|
|
294
304
|
EOF
|
295
305
|
|
296
306
|
define(:coderay_default_lang, Symbol, nil, <<EOF)
|
297
|
-
Sets the default language for highlighting
|
307
|
+
Sets the default language for highlighting code blocks
|
298
308
|
|
299
309
|
If no language is set for a code block, the default language is used
|
300
310
|
instead. The value has to be one of the languages supported by coderay
|
@@ -359,7 +369,7 @@ Defines the LaTeX commands for different header levels
|
|
359
369
|
The commands for the header levels one to six can be specified by
|
360
370
|
separating them with commas.
|
361
371
|
|
362
|
-
Default: section,subsection,subsubsection,paragraph,subparagraph,
|
372
|
+
Default: section,subsection,subsubsection,paragraph,subparagraph,subparagraph
|
363
373
|
Used by: Latex converter
|
364
374
|
EOF
|
365
375
|
simple_array_validator(val, :latex_headers, 6)
|
@@ -399,6 +409,17 @@ span HTML tags.
|
|
399
409
|
|
400
410
|
Default: false
|
401
411
|
Used by: RemoveHtmlTags converter
|
412
|
+
EOF
|
413
|
+
|
414
|
+
define(:header_offset, Integer, 0, <<EOF)
|
415
|
+
Sets the output offset for headers
|
416
|
+
|
417
|
+
If this option is c (may also be negative) then a header with level n
|
418
|
+
will be output as a header with level c+n. If c+n is lower than 1,
|
419
|
+
level 1 will be used. If c+n is greater than 6, level 6 will be used.
|
420
|
+
|
421
|
+
Default: 0
|
422
|
+
Used by: HTML converter, Kramdown converter, Latex converter
|
402
423
|
EOF
|
403
424
|
|
404
425
|
end
|
@@ -42,7 +42,8 @@ module Kramdown
|
|
42
42
|
def replace_abbreviations(el, regexps = nil)
|
43
43
|
return if @root.options[:abbrev_defs].empty?
|
44
44
|
if !regexps
|
45
|
-
|
45
|
+
sorted_abbrevs = @root.options[:abbrev_defs].keys.sort {|a,b| b.length <=> a.length}
|
46
|
+
regexps = [Regexp.union(*sorted_abbrevs.map {|k| /#{Regexp.escape(k)}/})]
|
46
47
|
regexps << /(?=(?:\W|^)#{regexps.first}(?!\w))/ # regexp should only match on word boundaries
|
47
48
|
end
|
48
49
|
el.children.map! do |child|
|
data/lib/kramdown/version.rb
CHANGED
data/man/man1/kramdown.1
CHANGED
@@ -35,66 +35,78 @@ Show the help.
|
|
35
35
|
.SH KRAMDOWN OPTIONS
|
36
36
|
|
37
37
|
.TP
|
38
|
-
.B \-\-
|
38
|
+
.B \-\-template ARG
|
39
39
|
|
40
|
-
|
40
|
+
The name of an ERB template file that should be used to wrap the output
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
This is used to wrap the output in an environment so that the output can
|
43
|
+
be used as a stand-alone document. For example, an HTML template would
|
44
|
+
provide the needed header and body tags so that the whole output is a
|
45
|
+
valid HTML file. If no template is specified, the output will be just
|
46
|
+
the converted text.
|
44
47
|
|
45
|
-
|
46
|
-
|
48
|
+
When resolving the template file, the given template name is used first.
|
49
|
+
If such a file is not found, the converter extension is appended. If the
|
50
|
+
file still cannot be found, the templates name is interpreted as a
|
51
|
+
template name that is provided by kramdown (without the converter
|
52
|
+
extension).
|
53
|
+
|
54
|
+
kramdown provides a default template named 'document' for each converter.
|
55
|
+
|
56
|
+
Default: ''
|
57
|
+
Used by: all converters
|
47
58
|
|
48
59
|
|
49
60
|
.TP
|
50
|
-
.B \-\-
|
61
|
+
.B \-\-[no\-]auto-ids
|
51
62
|
|
52
|
-
|
63
|
+
Use automatic header ID generation
|
53
64
|
|
54
|
-
|
65
|
+
If this option is `true`, ID values for all headers are automatically
|
66
|
+
generated if no ID is explicitly specified.
|
67
|
+
|
68
|
+
Default: true
|
69
|
+
Used by: HTML/Latex converter
|
55
70
|
|
56
71
|
|
57
72
|
.TP
|
58
|
-
.B \-\-
|
73
|
+
.B \-\-auto-id-prefix ARG
|
59
74
|
|
60
|
-
|
75
|
+
Prefix used for automatically generated heaer IDs
|
61
76
|
|
62
|
-
|
63
|
-
|
64
|
-
|
77
|
+
This option can be used to set a prefix for the automatically generated
|
78
|
+
header IDs so that there is no conflict when rendering multiple kramdown
|
79
|
+
documents into one output file separately. The prefix should only
|
80
|
+
contain characters that are valid in an ID!
|
65
81
|
|
66
|
-
Default:
|
82
|
+
Default: ''
|
67
83
|
Used by: HTML/Latex converter
|
68
84
|
|
69
85
|
|
70
86
|
.TP
|
71
|
-
.B \-\-[no\-]parse-
|
87
|
+
.B \-\-[no\-]parse-block-html
|
72
88
|
|
73
|
-
Process kramdown syntax in
|
89
|
+
Process kramdown syntax in block HTML tags
|
74
90
|
|
75
91
|
If this option is `true`, the kramdown parser processes the content of
|
76
|
-
|
92
|
+
block HTML tags as text containing block-level elements. Since this is
|
93
|
+
not wanted normally, the default is `false`. It is normally better to
|
94
|
+
selectively enable kramdown processing via the markdown attribute.
|
77
95
|
|
78
|
-
Default:
|
96
|
+
Default: false
|
79
97
|
Used by: kramdown parser
|
80
98
|
|
81
99
|
|
82
100
|
.TP
|
83
|
-
.B \-\-
|
84
|
-
|
85
|
-
Defines how often a line number should be made bold
|
86
|
-
|
87
|
-
Default: 10
|
88
|
-
Used by: HTML converter
|
89
|
-
|
101
|
+
.B \-\-[no\-]parse-span-html
|
90
102
|
|
91
|
-
|
92
|
-
.B \-\-line-width ARG
|
103
|
+
Process kramdown syntax in span HTML tags
|
93
104
|
|
94
|
-
|
105
|
+
If this option is `true`, the kramdown parser processes the content of
|
106
|
+
span HTML tags as text containing span-level elements.
|
95
107
|
|
96
|
-
Default:
|
97
|
-
Used by: kramdown
|
108
|
+
Default: true
|
109
|
+
Used by: kramdown parser
|
98
110
|
|
99
111
|
|
100
112
|
.TP
|
@@ -115,112 +127,101 @@ Used by: kramdown parser
|
|
115
127
|
|
116
128
|
|
117
129
|
.TP
|
118
|
-
.B \-\-
|
130
|
+
.B \-\-footnote-nr ARG
|
119
131
|
|
120
|
-
|
132
|
+
The number of the first footnote
|
121
133
|
|
122
|
-
|
123
|
-
|
124
|
-
styles are directly applied to the code elements).
|
134
|
+
This option can be used to specify the number that is used for the first
|
135
|
+
footnote.
|
125
136
|
|
126
|
-
Default:
|
137
|
+
Default: 1
|
127
138
|
Used by: HTML converter
|
128
139
|
|
129
140
|
|
130
141
|
.TP
|
131
|
-
.B \-\-
|
142
|
+
.B \-\-[no\-]enable-coderay
|
132
143
|
|
133
|
-
|
144
|
+
Use coderay for syntax highlighting
|
134
145
|
|
135
|
-
|
136
|
-
|
146
|
+
If this option is `true`, coderay is used by the HTML converter for
|
147
|
+
syntax highlighting the content of code spans and code blocks.
|
137
148
|
|
138
|
-
Default:
|
139
|
-
Used by:
|
149
|
+
Default: true
|
150
|
+
Used by: HTML converter
|
140
151
|
|
141
152
|
|
142
153
|
.TP
|
143
|
-
.B \-\-
|
154
|
+
.B \-\-coderay-wrap ARG
|
144
155
|
|
145
|
-
|
156
|
+
Defines how the highlighted code should be wrapped
|
146
157
|
|
147
|
-
|
148
|
-
footnote.
|
158
|
+
The possible values are :span, :div or nil.
|
149
159
|
|
150
|
-
Default:
|
160
|
+
Default: :div
|
151
161
|
Used by: HTML converter
|
152
162
|
|
153
163
|
|
154
164
|
.TP
|
155
|
-
.B \-\-
|
165
|
+
.B \-\-coderay-line-numbers ARG
|
156
166
|
|
157
|
-
|
167
|
+
Defines how and if line numbers should be shown
|
158
168
|
|
159
|
-
|
160
|
-
|
161
|
-
provide the needed header and body tags so that the whole output is a
|
162
|
-
valid HTML file. If no template is specified, the output will be just
|
163
|
-
the converted text.
|
169
|
+
The possible values are :table, :inline or nil. If this option is
|
170
|
+
nil, no line numbers are shown.
|
164
171
|
|
165
|
-
|
166
|
-
|
167
|
-
file still cannot be found, the templates name is interpreted as a
|
168
|
-
template name that is provided by kramdown (without the converter
|
169
|
-
extension).
|
172
|
+
Default: :inline
|
173
|
+
Used by: HTML converter
|
170
174
|
|
171
|
-
kramdown provides a default template named 'document' for each converter.
|
172
175
|
|
173
|
-
|
174
|
-
|
176
|
+
.TP
|
177
|
+
.B \-\-coderay-line-number-start ARG
|
175
178
|
|
179
|
+
The start value for the line numbers
|
176
180
|
|
177
|
-
|
178
|
-
|
181
|
+
Default: 1
|
182
|
+
Used by: HTML converter
|
179
183
|
|
180
|
-
Sets the default language for highlighting.
|
181
184
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
+
.TP
|
186
|
+
.B \-\-coderay-tab-width ARG
|
187
|
+
|
188
|
+
The tab width used in highlighted code
|
185
189
|
|
186
|
-
Default: nil
|
187
190
|
Used by: HTML converter
|
188
191
|
|
189
192
|
|
190
193
|
.TP
|
191
|
-
.B \-\-coderay-
|
192
|
-
|
193
|
-
Defines how and if line numbers should be shown
|
194
|
+
.B \-\-coderay-bold-every ARG
|
194
195
|
|
195
|
-
|
196
|
-
nil, no line numbers are shown.
|
196
|
+
Defines how often a line number should be made bold
|
197
197
|
|
198
|
-
Default:
|
198
|
+
Default: 10
|
199
199
|
Used by: HTML converter
|
200
200
|
|
201
201
|
|
202
202
|
.TP
|
203
|
-
.B \-\-
|
203
|
+
.B \-\-coderay-css ARG
|
204
204
|
|
205
|
-
Defines the
|
205
|
+
Defines how the highlighted code gets styled
|
206
206
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
commas.
|
207
|
+
Possible values are :class (CSS classes are applied to the code
|
208
|
+
elements, one must supply the needed CSS file) or :style (default CSS
|
209
|
+
styles are directly applied to the code elements).
|
211
210
|
|
212
|
-
Default:
|
213
|
-
Used by: HTML
|
211
|
+
Default: style
|
212
|
+
Used by: HTML converter
|
214
213
|
|
215
214
|
|
216
215
|
.TP
|
217
|
-
.B \-\-coderay-
|
216
|
+
.B \-\-coderay-default-lang ARG
|
218
217
|
|
219
|
-
|
218
|
+
Sets the default language for highlighting code blocks
|
220
219
|
|
221
|
-
|
220
|
+
If no language is set for a code block, the default language is used
|
221
|
+
instead. The value has to be one of the languages supported by coderay
|
222
|
+
or nil if no default language should be used.
|
222
223
|
|
223
|
-
Default:
|
224
|
+
Default: nil
|
224
225
|
Used by: HTML converter
|
225
226
|
|
226
227
|
|
@@ -240,64 +241,88 @@ Used by: HTML converter, kramdown converter
|
|
240
241
|
|
241
242
|
|
242
243
|
.TP
|
243
|
-
.B \-\-
|
244
|
+
.B \-\-toc-levels ARG
|
244
245
|
|
245
|
-
|
246
|
+
Defines the levels that are used for the table of contents
|
246
247
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
contain characters that are valid in an ID!
|
248
|
+
The individual levels can be specified by separating them with commas
|
249
|
+
(e.g. 1,2,3) or by using the range syntax (e.g. 1..3). Only the
|
250
|
+
specified levels are used for the table of contents.
|
251
251
|
|
252
|
-
Default:
|
252
|
+
Default: 1..6
|
253
253
|
Used by: HTML/Latex converter
|
254
254
|
|
255
255
|
|
256
256
|
.TP
|
257
|
-
.B \-\-
|
257
|
+
.B \-\-line-width ARG
|
258
258
|
|
259
|
-
|
259
|
+
Defines the line width to be used when outputting a document
|
260
260
|
|
261
|
-
|
262
|
-
|
261
|
+
Default: 72
|
262
|
+
Used by: kramdown converter
|
263
263
|
|
264
|
-
|
265
|
-
|
264
|
+
|
265
|
+
.TP
|
266
|
+
.B \-\-latex-headers ARG
|
267
|
+
|
268
|
+
Defines the LaTeX commands for different header levels
|
269
|
+
|
270
|
+
The commands for the header levels one to six can be specified by
|
271
|
+
separating them with commas.
|
272
|
+
|
273
|
+
Default: section,subsection,subsubsection,paragraph,subparagraph,subparagraph
|
274
|
+
Used by: Latex converter
|
266
275
|
|
267
276
|
|
268
277
|
.TP
|
269
|
-
.B \-\-
|
278
|
+
.B \-\-smart-quotes ARG
|
270
279
|
|
271
|
-
|
280
|
+
Defines the HTML entity names or code points for smart quote output
|
272
281
|
|
273
|
-
|
274
|
-
|
282
|
+
The entities identified by entity name or code point that should be
|
283
|
+
used for, in order, a left single quote, a right single quote, a left
|
284
|
+
double and a right double quote are specified by separating them with
|
285
|
+
commas.
|
286
|
+
|
287
|
+
Default: lsquo,rsquo,ldquo,rdquo
|
288
|
+
Used by: HTML/Latex converter
|
275
289
|
|
276
290
|
|
277
291
|
.TP
|
278
|
-
.B \-\-[no\-]
|
292
|
+
.B \-\-[no\-]remove-block-html-tags
|
279
293
|
|
280
|
-
|
294
|
+
Remove block HTML tags
|
281
295
|
|
282
|
-
If this option is `true`,
|
283
|
-
|
296
|
+
If this option is `true`, the RemoveHtmlTags converter removes
|
297
|
+
block HTML tags.
|
284
298
|
|
285
299
|
Default: true
|
286
|
-
Used by:
|
300
|
+
Used by: RemoveHtmlTags converter
|
287
301
|
|
288
302
|
|
289
303
|
.TP
|
290
|
-
.B \-\-[no\-]
|
304
|
+
.B \-\-[no\-]remove-span-html-tags
|
291
305
|
|
292
|
-
|
306
|
+
Remove span HTML tags
|
293
307
|
|
294
|
-
If this option is `true`, the
|
295
|
-
|
296
|
-
not wanted normally, the default is `false`. It is normally better to
|
297
|
-
selectively enable kramdown processing via the markdown attribute.
|
308
|
+
If this option is `true`, the RemoveHtmlTags converter removes
|
309
|
+
span HTML tags.
|
298
310
|
|
299
311
|
Default: false
|
300
|
-
Used by:
|
312
|
+
Used by: RemoveHtmlTags converter
|
313
|
+
|
314
|
+
|
315
|
+
.TP
|
316
|
+
.B \-\-header-offset ARG
|
317
|
+
|
318
|
+
Sets the output offset for headers
|
319
|
+
|
320
|
+
If this option is c (may also be negative) then a header with level n
|
321
|
+
will be output as a header with level c+n. If c+n is lower than 1,
|
322
|
+
level 1 will be used. If c+n is greater than 6, level 6 will be used.
|
323
|
+
|
324
|
+
Default: 0
|
325
|
+
Used by: HTML converter, Kramdown converter, Latex converter
|
301
326
|
|
302
327
|
|
303
328
|
.SH EXIT STATUS
|