kramdown 0.13.6 → 0.13.7

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.

@@ -1,6 +1,6 @@
1
1
  Count Name
2
2
  ======= ====
3
- 501 Thomas Leitner <t_leitner@gmx.at>
3
+ 513 Thomas Leitner <t_leitner@gmx.at>
4
4
  3 gettalong <t_leitner@gmx.at>
5
5
  3 Ben Armston <ben.armston@googlemail.com>
6
6
  3 Alex Marandon <contact@alexmarandon.com>
data/ChangeLog CHANGED
@@ -1,3 +1,134 @@
1
+ commit 0914bb652dad9ab1d48abc6de6da7a5ccc0e7996
2
+ Author: Thomas Leitner <t_leitner@gmx.at>
3
+ Date: Sun Jun 3 09:48:58 2012 +0200
4
+
5
+ Updated release notes and version number
6
+
7
+ doc/news/release_0_13_7.page
8
+ doc/sidebar.template
9
+ lib/kramdown/version.rb
10
+
11
+ commit 02bdb1072156b80ef114afbf363db92b6c62f65f
12
+ Author: Thomas Leitner <t_leitner@gmx.at>
13
+ Date: Sun Jun 3 09:42:26 2012 +0200
14
+
15
+ Docu fix
16
+
17
+ doc/converter/html.page
18
+
19
+ commit 6eeb2cc07876257eec1aaff77a213962378431e2
20
+ Author: Thomas Leitner <t_leitner@gmx.at>
21
+ Date: Sun Jun 3 09:00:14 2012 +0200
22
+
23
+ Updated kramdown executable to specify output format chain
24
+
25
+ This was needed since the new RemoteHtmlTags converter can only be
26
+ used before any standard converter.
27
+
28
+ bin/kramdown
29
+ man/man1/kramdown.1.erb
30
+
31
+ commit af9adbc5a94e55e05023d609fb3fb9f6878dd645
32
+ Author: Thomas Leitner <t_leitner@gmx.at>
33
+ Date: Sun Jun 3 08:59:13 2012 +0200
34
+
35
+ Implemented converter RemoveHtmlTags
36
+
37
+ This converter conditionally removes all plain block and/or span
38
+ HTML elements from an element tree. The resulting tree should, in
39
+ most cases, only consist of native kramdown elements.
40
+
41
+ doc/converter/remove_html_tags.page
42
+ doc/documentation.page
43
+ lib/kramdown/converter.rb
44
+ lib/kramdown/converter/remove_html_tags.rb
45
+ lib/kramdown/options.rb
46
+ test/test_files.rb
47
+
48
+ commit 912e905f952e5d1ffc3d2ce4973228bdd89a6750
49
+ Author: Thomas Leitner <t_leitner@gmx.at>
50
+ Date: Sun Jun 3 08:45:21 2012 +0200
51
+
52
+ Doctype declaration is now correctly parsed independent of case
53
+
54
+ lib/kramdown/parser/html.rb
55
+
56
+ commit ae13451867f8ca9070c6e714c0183754992bcff1
57
+ Author: Thomas Leitner <t_leitner@gmx.at>
58
+ Date: Sun Jun 3 07:28:10 2012 +0200
59
+
60
+ Fixed problem parsing multi-line link titles
61
+
62
+ lib/kramdown/parser/kramdown/link.rb
63
+
64
+ commit 8dc30e47144bde35bac1af8b74567fc09b553735
65
+ Author: Thomas Leitner <t_leitner@gmx.at>
66
+ Date: Sun Jun 3 07:10:55 2012 +0200
67
+
68
+ Fixed problems with setting Symbol options
69
+
70
+ * The nil value can now be specified by the String value 'nil'
71
+ * A colon at the start of a String value is removed before
72
+ converting the String value into a Symbol
73
+
74
+ lib/kramdown/options.rb
75
+
76
+ commit 4727a0a3816f149b9c7bea523b918602eb77962e
77
+ Author: Thomas Leitner <t_leitner@gmx.at>
78
+ Date: Sun Jun 3 06:57:51 2012 +0200
79
+
80
+ Fixed bug RF#29575: Added &shy; entity
81
+
82
+ lib/kramdown/converter/latex.rb
83
+ lib/kramdown/utils/entities.rb
84
+
85
+ commit 17625c80825a494065b5d9e4201f1e2fc6ab5104
86
+ Author: Thomas Leitner <t_leitner@gmx.at>
87
+ Date: Sat Jun 2 09:13:16 2012 +0200
88
+
89
+ Added new option for setting default coderay highlighting language
90
+
91
+ doc/converter/html.page
92
+ lib/kramdown/converter/html.rb
93
+ lib/kramdown/options.rb
94
+ test/testcases/block/06_codeblock/highlighting.html
95
+ test/testcases/block/06_codeblock/highlighting.options
96
+ test/testcases/block/06_codeblock/highlighting.text
97
+
98
+ commit b0fed40ba8d863f349e3f90e7cc40146bf01507a
99
+ Author: Thomas Leitner <t_leitner@gmx.at>
100
+ Date: Sat Jun 2 08:54:07 2012 +0200
101
+
102
+ Fixed RF#29576: Footnotes in headers resulted in duplicated id attr in TOC
103
+
104
+ Footnotes are now removed from the TOC to avoid this problem.
105
+
106
+ lib/kramdown/converter/html.rb
107
+ test/testcases/block/16_toc/toc_with_footnotes.html
108
+ test/testcases/block/16_toc/toc_with_footnotes.options
109
+ test/testcases/block/16_toc/toc_with_footnotes.text
110
+
111
+ commit c3ae4a3a0272cb376947f95ad1444c1bd4878301
112
+ Author: Thomas Leitner <t_leitner@gmx.at>
113
+ Date: Sat Jun 2 08:52:39 2012 +0200
114
+
115
+ Fixed toc test cases
116
+
117
+ Test went green although the meaning of the test was not
118
+ satisfied due to copy-paste.
119
+
120
+ test/testcases/block/16_toc/no_toc.html
121
+ test/testcases/block/16_toc/no_toc.options
122
+ test/testcases/block/16_toc/toc_levels.options
123
+
124
+ commit 56f3eb3c2610100c9785d98904d1dcd823e02917
125
+ Author: Thomas Leitner <t_leitner@gmx.at>
126
+ Date: Mon May 21 21:56:07 2012 +0200
127
+
128
+ RF#29577: Fixed broken link
129
+
130
+ doc/sidebar.template
131
+
1
132
  commit 40e6cde2d3e1a4f9f6bc14a243b22b4ae3311ca2
2
133
  Author: Thomas Leitner <t_leitner@gmx.at>
3
134
  Date: Wed May 9 19:53:47 2012 +0200
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.6
1
+ 0.13.7
@@ -25,7 +25,7 @@ require 'optparse'
25
25
  require 'kramdown'
26
26
 
27
27
  options = {}
28
- format = 'html'
28
+ format = ['html']
29
29
  OptionParser.new do |opts|
30
30
  opts.banner = "Usage: kramdown [options] [FILE FILE ...]"
31
31
  opts.summary_indent = ' '*4
@@ -35,7 +35,7 @@ OptionParser.new do |opts|
35
35
  opts.separator ""
36
36
 
37
37
  opts.on("-i", "--input ARG", "Specify the input format: kramdown (default) or html") {|v| options[:input] = v}
38
- opts.on("-o", "--output ARG", "Specify the output format: html (default), kramdown or latex") {|v| format = v}
38
+ opts.on("-o", "--output ARG", Array, "Specify one or more output formats separated by commas: html (default), kramdown, latex or remove_html_tags") {|v| format = v}
39
39
 
40
40
  opts.on("-v", "--version", "Show the version of kramdown") do
41
41
  puts Kramdown::VERSION
@@ -70,7 +70,9 @@ end.parse!
70
70
 
71
71
  begin
72
72
  doc = Kramdown::Document.new(ARGF.read, options)
73
- puts doc.send("to_#{format}")
73
+ result = ''
74
+ format.each {|f| result = doc.send("to_#{f}")}
75
+ puts result
74
76
  doc.warnings.each {|warn| $stderr.puts "Warning: #{warn}"}
75
77
  rescue Kramdown::Error => e
76
78
  $stderr.puts "Error: #{e.message}"
@@ -9,9 +9,13 @@ kramdown is first and foremost a library for converting text written in a supers
9
9
  HTML. However, due to its modular architecture it is able to support additional input and output
10
10
  formats. The following input and output formats are currently supported:
11
11
 
12
- * Input: [kramdown](parser/kramdown.html) (a superset of Markdown), [Markdown](parser/markdown.html),
13
- [HTML](parser/html.html)
14
- * Output: [HTML](converter/html.html), [LaTeX](converter/latex.html), [kramdown](converter/kramdown.html)
12
+ * Input: [kramdown](parser/kramdown.html) (a superset of Markdown),
13
+ [Markdown](parser/markdown.html), [HTML](parser/html.html)
14
+
15
+ * Output: [HTML](converter/html.html), [LaTeX](converter/latex.html),
16
+ [kramdown](converter/kramdown.html), [RemoveHtmlTags](converter/remove_html_tags.html) (a special
17
+ converter which removes HTML tags, normally used in conjunction with the LaTeX or kramdown
18
+ converters)
15
19
 
16
20
  The [kramdown syntax page](syntax.html) describes in detail what is supported and how it differs
17
21
  from standard Markdown.
@@ -1,9 +1,9 @@
1
1
  <h2>News</h2>
2
2
 
3
- <p>The latest version of kramdown is <b>0.13.6</b> and it was released
4
- on <b>2012-05-09</b>.</p>
3
+ <p>The latest version of kramdown is <b>0.13.7</b> and it was released
4
+ on <b>2012-06-03</b>.</p>
5
5
 
6
- <p>More <a href="news.html">news</a>…</p>
6
+ <p>More <a href="{relocatable: news.html}">news</a>…</p>
7
7
 
8
8
  <h2>Support kramdown</h2>
9
9
 
@@ -35,6 +35,7 @@ module Kramdown
35
35
  autoload :Latex, 'kramdown/converter/latex'
36
36
  autoload :Kramdown, 'kramdown/converter/kramdown'
37
37
  autoload :Toc, 'kramdown/converter/toc'
38
+ autoload :RemoveHtmlTags, 'kramdown/converter/remove_html_tags'
38
39
 
39
40
  end
40
41
 
@@ -108,12 +108,13 @@ module Kramdown
108
108
  end
109
109
 
110
110
  def convert_codeblock(el, indent)
111
- if el.attr['lang'] && HIGHLIGHTING_AVAILABLE
111
+ if (el.attr['lang'] || @options[:coderay_default_lang]) && HIGHLIGHTING_AVAILABLE
112
112
  attr = el.attr.dup
113
113
  opts = {:wrap => @options[:coderay_wrap], :line_numbers => @options[:coderay_line_numbers],
114
114
  :line_number_start => @options[:coderay_line_number_start], :tab_width => @options[:coderay_tab_width],
115
115
  :bold_every => @options[:coderay_bold_every], :css => @options[:coderay_css]}
116
- result = CodeRay.scan(el.value, attr.delete('lang').to_sym).html(opts).chomp << "\n"
116
+ lang = (attr.delete('lang') || @options[:coderay_default_lang]).to_sym
117
+ result = CodeRay.scan(el.value, lang).html(opts).chomp << "\n"
117
118
  "#{' '*indent}<div#{html_attributes(attr)}>#{result}#{' '*indent}</div>\n"
118
119
  else
119
120
  result = escape_html(el.value)
@@ -348,7 +349,7 @@ module Kramdown
348
349
  li = Element.new(:li, nil, nil, {:level => level})
349
350
  li.children << Element.new(:p, nil, nil, {:transparent => true})
350
351
  a = Element.new(:a, nil, {'href' => "##{id}"})
351
- a.children.concat(children)
352
+ a.children.concat(remove_footnotes(Marshal.load(Marshal.dump(children))))
352
353
  li.children.last.children << a
353
354
  li.children << Element.new(type)
354
355
 
@@ -375,6 +376,14 @@ module Kramdown
375
376
  sections
376
377
  end
377
378
 
379
+ # Remove all footnotes from the given elements.
380
+ def remove_footnotes(elements)
381
+ elements.delete_if do |c|
382
+ remove_footnotes(c.children)
383
+ c.type == :footnote
384
+ end
385
+ end
386
+
378
387
  # Obfuscate the +text+ by using HTML entities.
379
388
  def obfuscate(text)
380
389
  result = ""
@@ -429,6 +429,7 @@ module Kramdown
429
429
  174 => ['\textregistered'],
430
430
  170 => ['\textordfeminine'],
431
431
  172 => ['$\neg$'],
432
+ 173 => ['\-'],
432
433
  176 => ['$\degree$', 'mathabx'],
433
434
  177 => ['$\pm$'],
434
435
  180 => ['\''],
@@ -0,0 +1,66 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown.
7
+ #
8
+ # kramdown is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ #++
21
+ #
22
+
23
+ module Kramdown
24
+
25
+ module Converter
26
+
27
+ # Removes all block (and optionally span) level HTML tags from the element tree.
28
+ #
29
+ # This converter can be used on parsed HTML documents to get an element tree that will only
30
+ # contain native kramdown elements.
31
+ #
32
+ # *Note* that the returned element tree may not be fully conformant (i.e. the content models of
33
+ # *some elements may be violated)!
34
+ #
35
+ # This converter modifies the given tree in-place and returns it.
36
+ class RemoveHtmlTags < Base
37
+
38
+ def initialize(root, options)
39
+ super
40
+ @options[:template] = ''
41
+ end
42
+
43
+ def convert(el)
44
+ children = el.children.dup
45
+ index = 0
46
+ while index < children.length
47
+ if [:xml_pi].include?(children[index].type) ||
48
+ (children[index].type == :html_element && %w[style script].include?(children[index].value))
49
+ children[index..index] = []
50
+ elsif children[index].type == :html_element &&
51
+ ((@options[:remove_block_html_tags] && children[index].options[:category] == :block) ||
52
+ (@options[:remove_span_html_tags] && children[index].options[:category] == :span))
53
+ children[index..index] = children[index].children
54
+ else
55
+ convert(children[index])
56
+ index += 1
57
+ end
58
+ end
59
+ el.children = children
60
+ el
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+ end
@@ -110,7 +110,9 @@ module Kramdown
110
110
  elsif @options[name].type == Float
111
111
  Float(data) rescue raise Kramdown::Error, "Invalid float value for option '#{name}': '#{data}'"
112
112
  elsif @options[name].type == Symbol
113
- (data.strip.empty? ? nil : data.to_sym)
113
+ data.strip!
114
+ data = data[1..-1] if data[0] == ?:
115
+ (data.empty? || data == 'nil' ? nil : data.to_sym)
114
116
  elsif @options[name].type == Boolean
115
117
  data.downcase.strip != 'false' && !data.empty?
116
118
  end
@@ -253,7 +255,7 @@ EOF
253
255
  define(:coderay_line_numbers, Symbol, :inline, <<EOF)
254
256
  Defines how and if line numbers should be shown
255
257
 
256
- The possible values are :table, :inline, :list or nil. If this option is
258
+ The possible values are :table, :inline or nil. If this option is
257
259
  nil, no line numbers are shown.
258
260
 
259
261
  Default: :inline
@@ -289,6 +291,17 @@ styles are directly applied to the code elements).
289
291
 
290
292
  Default: style
291
293
  Used by: HTML converter
294
+ EOF
295
+
296
+ define(:coderay_default_lang, Symbol, nil, <<EOF)
297
+ Sets the default language for highlighting.
298
+
299
+ If no language is set for a code block, the default language is used
300
+ instead. The value has to be one of the languages supported by coderay
301
+ or nil if no default language should be used.
302
+
303
+ Default: nil
304
+ Used by: HTML converter
292
305
  EOF
293
306
 
294
307
  define(:entity_output, Symbol, :as_char, <<EOF)
@@ -368,6 +381,26 @@ EOF
368
381
  val
369
382
  end
370
383
 
384
+ define(:remove_block_html_tags, Boolean, true, <<EOF)
385
+ Remove block HTML tags
386
+
387
+ If this option is `true`, the RemoveHtmlTags converter removes
388
+ block HTML tags.
389
+
390
+ Default: true
391
+ Used by: RemoveHtmlTags converter
392
+ EOF
393
+
394
+ define(:remove_span_html_tags, Boolean, false, <<EOF)
395
+ Remove span HTML tags
396
+
397
+ If this option is `true`, the RemoveHtmlTags converter removes
398
+ span HTML tags.
399
+
400
+ Default: false
401
+ Used by: RemoveHtmlTags converter
402
+ EOF
403
+
371
404
  end
372
405
 
373
406
  end
@@ -37,7 +37,7 @@ module Kramdown
37
37
 
38
38
  #:stopdoc:
39
39
  # The following regexps are based on the ones used by REXML, with some slight modifications.
40
- HTML_DOCTYPE_RE = /<!DOCTYPE.*?>/m
40
+ HTML_DOCTYPE_RE = /<!DOCTYPE.*?>/im
41
41
  HTML_COMMENT_RE = /<!--(.*?)-->/m
42
42
  HTML_INSTRUCTION_RE = /<\?(.*?)\?>/m
43
43
  HTML_ATTRIBUTE_RE = /\s*(#{REXML::Parsers::BaseParser::UNAME_STR})(?:\s*=\s*(["'])(.*?)\2)?/m
@@ -60,7 +60,7 @@ module Kramdown
60
60
  LINK_BRACKET_STOP_RE = /(\])|!?\[/
61
61
  LINK_PAREN_STOP_RE = /(\()|(\))|\s(?=['"])/
62
62
  LINK_INLINE_ID_RE = /\s*?\[([^\]]+)?\]/
63
- LINK_INLINE_TITLE_RE = /\s*?(["'])(.+?)\1\s*?\)/
63
+ LINK_INLINE_TITLE_RE = /\s*?(["'])(.+?)\1\s*?\)/m
64
64
  LINK_START = /!?\[(?=[^^])/
65
65
 
66
66
  # Parse the link at the current scanner position. This method is used to parse normal links as
@@ -200,6 +200,7 @@ module Kramdown
200
200
  [174, 'reg'],
201
201
  [170, 'ordf'],
202
202
  [172, 'not'],
203
+ [173, 'shy'],
203
204
  [176, 'deg'],
204
205
  [177, 'plusmn'],
205
206
  [180, 'acute'],
@@ -23,6 +23,6 @@
23
23
  module Kramdown
24
24
 
25
25
  # The kramdown version.
26
- VERSION = '0.13.6'
26
+ VERSION = '0.13.7'
27
27
 
28
28
  end
@@ -23,7 +23,8 @@ converts its input.
23
23
  Specify the input format. Available input formats: kramdown (this is the default) or html.
24
24
  .TP
25
25
  .B \-o, \-\-output ARG
26
- Specify the output format. Available output formats: html (this is the default), kramdown or latex.
26
+ Specify one or more output formats separated by commas: html (default), kramdown, latex or
27
+ remove_html_tags.
27
28
  .TP
28
29
  .B \-v, \-\-version
29
30
  Show the version of kramdown.
@@ -34,78 +35,66 @@ Show the help.
34
35
  .SH KRAMDOWN OPTIONS
35
36
 
36
37
  .TP
37
- .B \-\-template ARG
38
-
39
- The name of an ERB template file that should be used to wrap the output
38
+ .B \-\-[no\-]remove-span-html-tags
40
39
 
41
- This is used to wrap the output in an environment so that the output can
42
- be used as a stand-alone document. For example, an HTML template would
43
- provide the needed header and body tags so that the whole output is a
44
- valid HTML file. If no template is specified, the output will be just
45
- the converted text.
40
+ Remove span HTML tags
46
41
 
47
- When resolving the template file, the given template name is used first.
48
- If such a file is not found, the converter extension is appended. If the
49
- file still cannot be found, the templates name is interpreted as a
50
- template name that is provided by kramdown (without the converter
51
- extension).
42
+ If this option is `true`, the RemoveHtmlTags converter removes
43
+ span HTML tags.
52
44
 
53
- kramdown provides a default template named 'document' for each converter.
54
-
55
- Default: ''
56
- Used by: all converters
45
+ Default: false
46
+ Used by: RemoveHtmlTags converter
57
47
 
58
48
 
59
49
  .TP
60
- .B \-\-[no\-]auto-ids
61
-
62
- Use automatic header ID generation
50
+ .B \-\-coderay-tab-width ARG
63
51
 
64
- If this option is `true`, ID values for all headers are automatically
65
- generated if no ID is explicitly specified.
52
+ The tab width used in highlighted code
66
53
 
67
- Default: true
68
- Used by: HTML/Latex converter
54
+ Used by: HTML converter
69
55
 
70
56
 
71
57
  .TP
72
- .B \-\-auto-id-prefix ARG
58
+ .B \-\-toc-levels ARG
73
59
 
74
- Prefix used for automatically generated heaer IDs
60
+ Defines the levels that are used for the table of contents
75
61
 
76
- This option can be used to set a prefix for the automatically generated
77
- header IDs so that there is no conflict when rendering multiple kramdown
78
- documents into one output file separately. The prefix should only
79
- contain characters that are valid in an ID!
62
+ The individual levels can be specified by separating them with commas
63
+ (e.g. 1,2,3) or by using the range syntax (e.g. 1..3). Only the
64
+ specified levels are used for the table of contents.
80
65
 
81
- Default: ''
66
+ Default: 1..6
82
67
  Used by: HTML/Latex converter
83
68
 
84
69
 
85
70
  .TP
86
- .B \-\-[no\-]parse-block-html
71
+ .B \-\-[no\-]parse-span-html
87
72
 
88
- Process kramdown syntax in block HTML tags
73
+ Process kramdown syntax in span HTML tags
89
74
 
90
75
  If this option is `true`, the kramdown parser processes the content of
91
- block HTML tags as text containing block-level elements. Since this is
92
- not wanted normally, the default is `false`. It is normally better to
93
- selectively enable kramdown processing via the markdown attribute.
76
+ span HTML tags as text containing span-level elements.
94
77
 
95
- Default: false
78
+ Default: true
96
79
  Used by: kramdown parser
97
80
 
98
81
 
99
82
  .TP
100
- .B \-\-[no\-]parse-span-html
83
+ .B \-\-coderay-bold-every ARG
101
84
 
102
- Process kramdown syntax in span HTML tags
85
+ Defines how often a line number should be made bold
103
86
 
104
- If this option is `true`, the kramdown parser processes the content of
105
- span HTML tags as text containing span-level elements.
87
+ Default: 10
88
+ Used by: HTML converter
106
89
 
107
- Default: true
108
- Used by: kramdown parser
90
+
91
+ .TP
92
+ .B \-\-line-width ARG
93
+
94
+ Defines the line width to be used when outputting a document
95
+
96
+ Default: 72
97
+ Used by: kramdown converter
109
98
 
110
99
 
111
100
  .TP
@@ -126,76 +115,112 @@ Used by: kramdown parser
126
115
 
127
116
 
128
117
  .TP
129
- .B \-\-footnote-nr ARG
118
+ .B \-\-coderay-css ARG
130
119
 
131
- The number of the first footnote
120
+ Defines how the highlighted code gets styled
132
121
 
133
- This option can be used to specify the number that is used for the first
134
- footnote.
122
+ Possible values are :class (CSS classes are applied to the code
123
+ elements, one must supply the needed CSS file) or :style (default CSS
124
+ styles are directly applied to the code elements).
135
125
 
136
- Default: 1
126
+ Default: style
137
127
  Used by: HTML converter
138
128
 
139
129
 
140
130
  .TP
141
- .B \-\-coderay-wrap ARG
131
+ .B \-\-latex-headers ARG
142
132
 
143
- Defines how the highlighted code should be wrapped
133
+ Defines the LaTeX commands for different header levels
144
134
 
145
- The possible values are :span, :div or nil.
135
+ The commands for the header levels one to six can be specified by
136
+ separating them with commas.
146
137
 
147
- Default: :div
148
- Used by: HTML converter
138
+ Default: section,subsection,subsubsection,paragraph,subparagraph,subsubparagraph
139
+ Used by: Latex converter
149
140
 
150
141
 
151
142
  .TP
152
- .B \-\-coderay-line-numbers ARG
143
+ .B \-\-footnote-nr ARG
153
144
 
154
- Defines how and if line numbers should be shown
145
+ The number of the first footnote
155
146
 
156
- The possible values are :table, :inline, :list or nil. If this option is
157
- nil, no line numbers are shown.
147
+ This option can be used to specify the number that is used for the first
148
+ footnote.
158
149
 
159
- Default: :inline
150
+ Default: 1
160
151
  Used by: HTML converter
161
152
 
162
153
 
163
154
  .TP
164
- .B \-\-coderay-line-number-start ARG
155
+ .B \-\-template ARG
165
156
 
166
- The start value for the line numbers
157
+ The name of an ERB template file that should be used to wrap the output
167
158
 
168
- Default: 1
169
- Used by: HTML converter
159
+ This is used to wrap the output in an environment so that the output can
160
+ be used as a stand-alone document. For example, an HTML template would
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.
164
+
165
+ When resolving the template file, the given template name is used first.
166
+ If such a file is not found, the converter extension is appended. If the
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).
170
+
171
+ kramdown provides a default template named 'document' for each converter.
172
+
173
+ Default: ''
174
+ Used by: all converters
170
175
 
171
176
 
172
177
  .TP
173
- .B \-\-coderay-tab-width ARG
178
+ .B \-\-coderay-default-lang ARG
174
179
 
175
- The tab width used in highlighted code
180
+ Sets the default language for highlighting.
181
+
182
+ If no language is set for a code block, the default language is used
183
+ instead. The value has to be one of the languages supported by coderay
184
+ or nil if no default language should be used.
176
185
 
186
+ Default: nil
177
187
  Used by: HTML converter
178
188
 
179
189
 
180
190
  .TP
181
- .B \-\-coderay-bold-every ARG
191
+ .B \-\-coderay-line-numbers ARG
182
192
 
183
- Defines how often a line number should be made bold
193
+ Defines how and if line numbers should be shown
184
194
 
185
- Default: 10
195
+ The possible values are :table, :inline or nil. If this option is
196
+ nil, no line numbers are shown.
197
+
198
+ Default: :inline
186
199
  Used by: HTML converter
187
200
 
188
201
 
189
202
  .TP
190
- .B \-\-coderay-css ARG
203
+ .B \-\-smart-quotes ARG
191
204
 
192
- Defines how the highlighted code gets styled
205
+ Defines the HTML entity names or code points for smart quote output
193
206
 
194
- Possible values are :class (CSS classes are applied to the code
195
- elements, one must supply the needed CSS file) or :style (default CSS
196
- styles are directly applied to the code elements).
207
+ The entities identified by entity name or code point that should be
208
+ used for, in order, a left single quote, a right single quote, a left
209
+ double and a right double quote are specified by separating them with
210
+ commas.
197
211
 
198
- Default: style
212
+ Default: lsquo,rsquo,ldquo,rdquo
213
+ Used by: HTML/Latex converter
214
+
215
+
216
+ .TP
217
+ .B \-\-coderay-wrap ARG
218
+
219
+ Defines how the highlighted code should be wrapped
220
+
221
+ The possible values are :span, :div or nil.
222
+
223
+ Default: :div
199
224
  Used by: HTML converter
200
225
 
201
226
 
@@ -215,53 +240,66 @@ Used by: HTML converter, kramdown converter
215
240
 
216
241
 
217
242
  .TP
218
- .B \-\-toc-levels ARG
243
+ .B \-\-auto-id-prefix ARG
219
244
 
220
- Defines the levels that are used for the table of contents
245
+ Prefix used for automatically generated heaer IDs
221
246
 
222
- The individual levels can be specified by separating them with commas
223
- (e.g. 1,2,3) or by using the range syntax (e.g. 1..3). Only the
224
- specified levels are used for the table of contents.
247
+ This option can be used to set a prefix for the automatically generated
248
+ header IDs so that there is no conflict when rendering multiple kramdown
249
+ documents into one output file separately. The prefix should only
250
+ contain characters that are valid in an ID!
225
251
 
226
- Default: 1..6
252
+ Default: ''
227
253
  Used by: HTML/Latex converter
228
254
 
229
255
 
230
256
  .TP
231
- .B \-\-line-width ARG
257
+ .B \-\-[no\-]remove-block-html-tags
232
258
 
233
- Defines the line width to be used when outputting a document
259
+ Remove block HTML tags
234
260
 
235
- Default: 72
236
- Used by: kramdown converter
261
+ If this option is `true`, the RemoveHtmlTags converter removes
262
+ block HTML tags.
237
263
 
264
+ Default: true
265
+ Used by: RemoveHtmlTags converter
238
266
 
239
- .TP
240
- .B \-\-latex-headers ARG
241
267
 
242
- Defines the LaTeX commands for different header levels
268
+ .TP
269
+ .B \-\-coderay-line-number-start ARG
243
270
 
244
- The commands for the header levels one to six can be specified by
245
- separating them with commas.
271
+ The start value for the line numbers
246
272
 
247
- Default: section,subsection,subsubsection,paragraph,subparagraph,subsubparagraph
248
- Used by: Latex converter
273
+ Default: 1
274
+ Used by: HTML converter
249
275
 
250
276
 
251
277
  .TP
252
- .B \-\-smart-quotes ARG
278
+ .B \-\-[no\-]auto-ids
253
279
 
254
- Defines the HTML entity names or code points for smart quote output
280
+ Use automatic header ID generation
255
281
 
256
- The entities identified by entity name or code point that should be
257
- used for, in order, a left single quote, a right single quote, a left
258
- double and a right double quote are specified by separating them with
259
- commas.
282
+ If this option is `true`, ID values for all headers are automatically
283
+ generated if no ID is explicitly specified.
260
284
 
261
- Default: lsquo,rsquo,ldquo,rdquo
285
+ Default: true
262
286
  Used by: HTML/Latex converter
263
287
 
264
288
 
289
+ .TP
290
+ .B \-\-[no\-]parse-block-html
291
+
292
+ Process kramdown syntax in block HTML tags
293
+
294
+ If this option is `true`, the kramdown parser processes the content of
295
+ block HTML tags as text containing block-level elements. Since this is
296
+ not wanted normally, the default is `false`. It is normally better to
297
+ selectively enable kramdown processing via the markdown attribute.
298
+
299
+ Default: false
300
+ Used by: kramdown parser
301
+
302
+
265
303
  .SH EXIT STATUS
266
304
  The exit status is 0 if no error happened. Otherwise it is 1.
267
305
  .SH SEE ALSO
@@ -166,7 +166,7 @@ class TestFiles < Test::Unit::TestCase
166
166
  Dir[File.dirname(__FILE__) + '/testcases/**/*.text'].each do |text_file|
167
167
  opts_file = text_file.sub(/\.text$/, '.options')
168
168
  options = File.exist?(opts_file) ? YAML::load(File.read(opts_file)) : {:auto_ids => false, :footnote_nr => 1}
169
- (Kramdown::Converter.constants.map {|c| c.to_sym} - [:Base]).each do |conv_class|
169
+ (Kramdown::Converter.constants.map {|c| c.to_sym} - [:Base, :RemoveHtmlTags]).each do |conv_class|
170
170
  define_method("test_whether_#{conv_class}_modifies_tree_with_file_#{text_file.tr('.', '_')}") do
171
171
  doc = Kramdown::Document.new(File.read(text_file), options)
172
172
  options_before = Marshal.load(Marshal.dump(doc.options))
@@ -0,0 +1,6 @@
1
+ <div><span class="CodeRay">x = <span class="constant">Class</span>.new
2
+ </span>
3
+ </div>
4
+ <div><span class="CodeRay"><span class="tag">&lt;a&gt;</span>href<span class="tag">&lt;/a&gt;</span>
5
+ </span>
6
+ </div>
@@ -0,0 +1,5 @@
1
+ :coderay_default_lang: ruby
2
+ :coderay_wrap: span
3
+ :coderay_line_numbers: ~
4
+ :coderay_css: class
5
+
@@ -0,0 +1,4 @@
1
+ x = Class.new
2
+ ^
3
+ <a>href</a>
4
+ {: lang="html"}
@@ -1,33 +1,14 @@
1
- <ul id="markdown-toc">
2
- <li><a href="#header-level-1">Header level 1</a> <ul>
3
- <li><a href="#header-level-2">Header level 2</a> <ul>
4
- <li><a href="#header-level-3">Header level 3</a> <ul>
5
- <li><a href="#header-level-4">Header level 4</a></li>
6
- </ul>
7
- </li>
8
- </ul>
9
- </li>
10
- </ul>
11
- </li>
12
- <li><a href="#other-header-level-1">Other header level 1</a> <ul>
13
- <li><a href="#other-header-level-2">Other header level 2</a> <ul>
14
- <li><a href="#other-header-level-3">Other header level 3</a></li>
15
- </ul>
16
- </li>
17
- </ul>
18
- </li>
19
- </ul>
20
1
 
21
- <h1 id="header-level-1">Header level 1</h1>
2
+ <h1>Header level 1</h1>
22
3
 
23
- <h2 id="header-level-2">Header level 2</h2>
4
+ <h2>Header level 2</h2>
24
5
 
25
- <h3 id="header-level-3">Header level 3</h3>
6
+ <h3>Header level 3</h3>
26
7
 
27
- <h4 id="header-level-4">Header level 4</h4>
8
+ <h4>Header level 4</h4>
28
9
 
29
- <h1 id="other-header-level-1">Other header level 1</h1>
10
+ <h1>Other header level 1</h1>
30
11
 
31
- <h2 id="other-header-level-2">Other header level 2</h2>
12
+ <h2>Other header level 2</h2>
32
13
 
33
- <h3 id="other-header-level-3">Other header level 3</h3>
14
+ <h3>Other header level 3</h3>
@@ -1 +1,2 @@
1
1
  :toc_levels: 2..3
2
+ :auto_ids: true
@@ -0,0 +1,13 @@
1
+ <ul id="markdown-toc">
2
+ <li><a href="#header1-level-1">Header level 1</a></li>
3
+ </ul>
4
+
5
+ <h1 id="header1-level-1">Header<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> level 1</h1>
6
+
7
+ <div class="footnotes">
8
+ <ol>
9
+ <li id="fn:1">
10
+ <p>Some footnote content here<a href="#fnref:1" rel="reference">&#8617;</a></p>
11
+ </li>
12
+ </ol>
13
+ </div>
@@ -0,0 +1,6 @@
1
+ * Here comes the table of content
2
+ {:toc}
3
+
4
+ # Header[^1] level 1
5
+
6
+ [^1]: Some footnote content here
metadata CHANGED
@@ -1,39 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: kramdown
3
- version: !ruby/object:Gem::Version
4
- version: 0.13.6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 37
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 13
9
+ - 7
10
+ version: 0.13.7
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Thomas Leitner
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-05-09 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-06-03 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: coderay
16
- requirement: &20421140 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
25
+ requirements:
19
26
  - - ~>
20
- - !ruby/object:Gem::Version
27
+ - !ruby/object:Gem::Version
28
+ hash: 23
29
+ segments:
30
+ - 1
31
+ - 0
32
+ - 0
21
33
  version: 1.0.0
22
34
  type: :development
23
- prerelease: false
24
- version_requirements: *20421140
25
- description: ! 'kramdown is yet-another-markdown-parser but fast, pure Ruby,
26
-
35
+ version_requirements: *id001
36
+ description: |
37
+ kramdown is yet-another-markdown-parser but fast, pure Ruby,
27
38
  using a strict syntax definition and supporting several common extensions.
28
39
 
29
- '
30
40
  email: t_leitner@gmx.at
31
- executables:
41
+ executables:
32
42
  - kramdown
33
43
  extensions: []
34
- extra_rdoc_files:
44
+
45
+ extra_rdoc_files:
35
46
  - README
36
- files:
47
+ files:
37
48
  - Rakefile
38
49
  - setup.rb
39
50
  - COPYING
@@ -89,6 +100,7 @@ files:
89
100
  - lib/kramdown/element.rb
90
101
  - lib/kramdown/converter/base.rb
91
102
  - lib/kramdown/converter/latex.rb
103
+ - lib/kramdown/converter/remove_html_tags.rb
92
104
  - lib/kramdown/converter/html.rb
93
105
  - lib/kramdown/converter/kramdown.rb
94
106
  - lib/kramdown/converter/toc.rb
@@ -417,16 +429,20 @@ files:
417
429
  - test/testcases/block/05_blockquote/with_code_blocks.text
418
430
  - test/testcases/block/05_blockquote/nested.html
419
431
  - test/testcases/block/05_blockquote/with_code_blocks.html
420
- - test/testcases/block/16_toc/no_toc.options
421
432
  - test/testcases/block/16_toc/no_toc.text
433
+ - test/testcases/block/16_toc/toc_with_footnotes.options
422
434
  - test/testcases/block/16_toc/no_toc.html
423
435
  - test/testcases/block/16_toc/toc_levels.html
424
436
  - test/testcases/block/16_toc/toc_levels.text
437
+ - test/testcases/block/16_toc/toc_with_footnotes.html
438
+ - test/testcases/block/16_toc/toc_with_footnotes.text
425
439
  - test/testcases/block/16_toc/toc_levels.options
426
440
  - test/testcases/block/01_blank_line/spaces.html
427
441
  - test/testcases/block/01_blank_line/tabs.text
428
442
  - test/testcases/block/01_blank_line/spaces.text
429
443
  - test/testcases/block/01_blank_line/tabs.html
444
+ - test/testcases/block/06_codeblock/highlighting.html
445
+ - test/testcases/block/06_codeblock/highlighting.options
430
446
  - test/testcases/block/06_codeblock/whitespace.text
431
447
  - test/testcases/block/06_codeblock/with_eob_marker.text
432
448
  - test/testcases/block/06_codeblock/tilde_syntax.html
@@ -443,6 +459,7 @@ files:
443
459
  - test/testcases/block/06_codeblock/no_newline_at_end_1.html
444
460
  - test/testcases/block/06_codeblock/error.html
445
461
  - test/testcases/block/06_codeblock/lazy.text
462
+ - test/testcases/block/06_codeblock/highlighting.text
446
463
  - test/testcases/block/06_codeblock/whitespace.html
447
464
  - test/testcases/block/06_codeblock/no_newline_at_end.html
448
465
  - test/testcases/block/06_codeblock/error.text
@@ -451,28 +468,37 @@ files:
451
468
  - test/test_files.rb
452
469
  homepage: http://kramdown.rubyforge.org
453
470
  licenses: []
471
+
454
472
  post_install_message:
455
- rdoc_options:
473
+ rdoc_options:
456
474
  - --main
457
475
  - README
458
- require_paths:
476
+ require_paths:
459
477
  - lib
460
- required_ruby_version: !ruby/object:Gem::Requirement
478
+ required_ruby_version: !ruby/object:Gem::Requirement
461
479
  none: false
462
- requirements:
463
- - - ! '>='
464
- - !ruby/object:Gem::Version
465
- version: '0'
466
- required_rubygems_version: !ruby/object:Gem::Requirement
480
+ requirements:
481
+ - - ">="
482
+ - !ruby/object:Gem::Version
483
+ hash: 3
484
+ segments:
485
+ - 0
486
+ version: "0"
487
+ required_rubygems_version: !ruby/object:Gem::Requirement
467
488
  none: false
468
- requirements:
469
- - - ! '>='
470
- - !ruby/object:Gem::Version
471
- version: '0'
489
+ requirements:
490
+ - - ">="
491
+ - !ruby/object:Gem::Version
492
+ hash: 3
493
+ segments:
494
+ - 0
495
+ version: "0"
472
496
  requirements: []
497
+
473
498
  rubyforge_project: kramdown
474
- rubygems_version: 1.8.10
499
+ rubygems_version: 1.8.24
475
500
  signing_key:
476
501
  specification_version: 3
477
502
  summary: kramdown is a fast, pure-Ruby Markdown-superset converter.
478
503
  test_files: []
504
+