kramdown 1.5.0 → 1.6.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.
- checksums.yaml +4 -4
- data/CONTRIBUTERS +3 -1
- data/README.md +6 -6
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/kramdown +1 -1
- data/doc/default.template +2 -2
- data/doc/index.page +21 -7
- data/doc/options.page +42 -3
- data/doc/sidebar.template +0 -7
- data/doc/sitemap.sitemap +5 -0
- data/doc/syntax.page +31 -3
- data/doc/virtual +3 -0
- data/lib/kramdown.rb +1 -1
- data/lib/kramdown/compatibility.rb +1 -1
- data/lib/kramdown/converter.rb +1 -1
- data/lib/kramdown/converter/base.rb +2 -1
- data/lib/kramdown/converter/html.rb +10 -5
- data/lib/kramdown/converter/kramdown.rb +13 -7
- data/lib/kramdown/converter/latex.rb +2 -1
- data/lib/kramdown/converter/math_engine/itex2mml.rb +1 -1
- data/lib/kramdown/converter/math_engine/mathjax.rb +18 -3
- data/lib/kramdown/converter/math_engine/ritex.rb +1 -1
- data/lib/kramdown/converter/pdf.rb +3 -2
- data/lib/kramdown/converter/remove_html_tags.rb +3 -1
- data/lib/kramdown/converter/syntax_highlighter.rb +53 -0
- data/lib/kramdown/converter/syntax_highlighter/coderay.rb +1 -1
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +2 -2
- data/lib/kramdown/converter/toc.rb +2 -2
- data/lib/kramdown/document.rb +5 -5
- data/lib/kramdown/element.rb +4 -1
- data/lib/kramdown/error.rb +1 -1
- data/lib/kramdown/options.rb +4 -3
- data/lib/kramdown/parser.rb +1 -1
- data/lib/kramdown/parser/base.rb +8 -4
- data/lib/kramdown/parser/gfm.rb +9 -1
- data/lib/kramdown/parser/html.rb +18 -3
- data/lib/kramdown/parser/kramdown.rb +8 -5
- data/lib/kramdown/parser/kramdown/abbreviation.rb +10 -2
- data/lib/kramdown/parser/kramdown/autolink.rb +1 -1
- data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
- data/lib/kramdown/parser/kramdown/block_boundary.rb +1 -1
- data/lib/kramdown/parser/kramdown/blockquote.rb +1 -1
- data/lib/kramdown/parser/kramdown/codeblock.rb +1 -1
- data/lib/kramdown/parser/kramdown/codespan.rb +1 -1
- data/lib/kramdown/parser/kramdown/emphasis.rb +2 -2
- data/lib/kramdown/parser/kramdown/eob.rb +1 -1
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
- data/lib/kramdown/parser/kramdown/extensions.rb +8 -7
- data/lib/kramdown/parser/kramdown/footnote.rb +11 -4
- data/lib/kramdown/parser/kramdown/header.rb +1 -1
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
- data/lib/kramdown/parser/kramdown/html.rb +7 -4
- data/lib/kramdown/parser/kramdown/html_entity.rb +1 -1
- data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
- data/lib/kramdown/parser/kramdown/link.rb +8 -5
- data/lib/kramdown/parser/kramdown/list.rb +12 -7
- data/lib/kramdown/parser/kramdown/math.rb +3 -3
- data/lib/kramdown/parser/kramdown/paragraph.rb +3 -3
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
- data/lib/kramdown/parser/kramdown/table.rb +1 -1
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
- data/lib/kramdown/parser/markdown.rb +2 -2
- data/lib/kramdown/utils.rb +1 -1
- data/lib/kramdown/utils/configurable.rb +1 -1
- data/lib/kramdown/utils/entities.rb +1 -1
- data/lib/kramdown/utils/html.rb +3 -1
- data/lib/kramdown/utils/ordered_hash.rb +1 -1
- data/lib/kramdown/utils/string_scanner.rb +8 -0
- data/lib/kramdown/utils/unidecoder.rb +1 -1
- data/lib/kramdown/version.rb +2 -2
- data/man/man1/kramdown.1 +1 -1
- data/test/run_tests.rb +1 -1
- data/test/test_files.rb +48 -17
- data/test/test_location.rb +8 -0
- data/test/test_string_scanner_kramdown.rb +8 -0
- data/test/testcases/block/04_header/atx_header.html +1 -1
- data/test/testcases/block/06_codeblock/highlighting-rouge.html +2 -2
- data/test/testcases/block/09_html/html_after_block.html +7 -0
- data/test/testcases/block/09_html/html_after_block.text +5 -0
- data/test/testcases/block/11_ial/simple.html +3 -1
- data/test/testcases/block/11_ial/simple.text +5 -1
- data/test/testcases/block/15_math/gh_128.html +1 -1
- data/test/testcases/block/15_math/mathjax_preview.html +4 -0
- data/test/testcases/block/15_math/mathjax_preview.options +2 -0
- data/test/testcases/block/15_math/mathjax_preview.text +5 -0
- data/test/testcases/block/15_math/mathjax_preview_simple.html +4 -0
- data/test/testcases/block/15_math/mathjax_preview_simple.options +2 -0
- data/test/testcases/block/15_math/mathjax_preview_simple.text +5 -0
- data/test/testcases/block/15_math/normal.html +1 -1
- data/test/testcases/block/16_toc/toc_exclude.html +7 -7
- data/test/testcases/block/16_toc/toc_levels.html +4 -4
- data/test/testcases/block/16_toc/toc_with_footnotes.html +1 -1
- data/test/testcases/span/01_link/empty_title.htmlinput +3 -0
- data/test/testcases/span/01_link/empty_title.text +7 -0
- data/test/testcases/span/01_link/link_defs_with_ial.html +4 -0
- data/test/testcases/span/01_link/link_defs_with_ial.text +16 -0
- data/test/testcases/span/02_emphasis/normal.html +2 -0
- data/test/testcases/span/02_emphasis/normal.text +2 -0
- data/test/testcases/span/04_footnote/markers.text +1 -0
- data/test/testcases/span/abbreviations/abbrev.html +3 -1
- data/test/testcases/span/abbreviations/abbrev.text +7 -0
- data/test/testcases/span/line_breaks/normal.html +2 -2
- data/test/testcases/span/line_breaks/normal.latex +2 -2
- metadata +20 -6
@@ -1,13 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
10
|
require 'set'
|
11
|
+
require 'kramdown/converter'
|
11
12
|
|
12
13
|
module Kramdown
|
13
14
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -20,11 +20,26 @@ module Kramdown::Converter::MathEngine
|
|
20
20
|
text = (el.value =~ /<|&/ ? "% <![CDATA[\n#{el.value} %]]>" : el.value)
|
21
21
|
text.gsub!(/<\/?script>?/, '')
|
22
22
|
|
23
|
+
preview = preview_string(converter, el, opts)
|
24
|
+
|
23
25
|
attr = {:type => "math/tex#{type == :block ? '; mode=display' : ''}"}
|
24
26
|
if type == :block
|
25
|
-
converter.format_as_block_html('script', attr, text, opts[:indent])
|
27
|
+
preview << converter.format_as_block_html('script', attr, text, opts[:indent])
|
28
|
+
else
|
29
|
+
preview << converter.format_as_span_html('script', attr, text)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.preview_string(converter, el, opts)
|
34
|
+
preview = converter.options[:math_engine_opts][:preview]
|
35
|
+
return '' unless preview
|
36
|
+
|
37
|
+
preview = (preview == true ? converter.escape_html(el.value) : preview.to_s)
|
38
|
+
|
39
|
+
if el.options[:category] == :block
|
40
|
+
converter.format_as_block_html('div', {'class' => 'MathJax_Preview'}, preview, opts[:indent])
|
26
41
|
else
|
27
|
-
converter.format_as_span_html('
|
42
|
+
converter.format_as_span_html('span', {'class' => 'MathJax_Preview'}, preview)
|
28
43
|
end
|
29
44
|
end
|
30
45
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -9,7 +9,8 @@
|
|
9
9
|
|
10
10
|
require 'prawn'
|
11
11
|
require 'prawn/table'
|
12
|
-
require 'kramdown/
|
12
|
+
require 'kramdown/converter'
|
13
|
+
require 'kramdown/utils'
|
13
14
|
require 'open-uri'
|
14
15
|
|
15
16
|
module Kramdown
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
|
+
require 'kramdown/converter'
|
11
|
+
|
10
12
|
module Kramdown
|
11
13
|
|
12
14
|
module Converter
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Converter
|
12
|
+
|
13
|
+
# == Container for Syntax Highlighters
|
14
|
+
#
|
15
|
+
# This module serves as container for the syntax highlighters that can be used together with
|
16
|
+
# kramdown.
|
17
|
+
#
|
18
|
+
# A syntax highlighter should not store any data itself but should use the provided converter
|
19
|
+
# object to do so (See Kramdown::Converter::Base#data).
|
20
|
+
#
|
21
|
+
# == Implementing a Syntax Highlighter
|
22
|
+
#
|
23
|
+
# Implementing a new syntax highlighter is easy because it is just an object that needs to
|
24
|
+
# respond to #call.
|
25
|
+
#
|
26
|
+
# The method #call needs to take the following arguments:
|
27
|
+
#
|
28
|
+
# converter:: This argument contains the converter object that calls the syntax highlighter. It
|
29
|
+
# can be used, for example, to store data in Kramdown::Converter::Base#data for one
|
30
|
+
# conversion run.
|
31
|
+
#
|
32
|
+
# text:: The raw text that should be highlighted.
|
33
|
+
#
|
34
|
+
# lang:: The language that the text should be highlighted for (e.g. ruby, python, ...).
|
35
|
+
#
|
36
|
+
# type:: The type of text, either :span for span-level code or :block for a codeblock.
|
37
|
+
#
|
38
|
+
# opts:: A Hash with options that may be passed from the converter.
|
39
|
+
#
|
40
|
+
# The return value of the method should be the highlighted text, suitable for the given
|
41
|
+
# converter (e.g. HTML for the HTML converter).
|
42
|
+
#
|
43
|
+
# == Special Implementation Details
|
44
|
+
#
|
45
|
+
# HTML converter:: If the syntax highlighter is used with a HTML converter, it should return
|
46
|
+
# :block type text correctly wrapped (i.e. normally inside a pre-tag, but may
|
47
|
+
# also be a table-tag or just a div-tag) but :span type text *without* a
|
48
|
+
# code-tag!
|
49
|
+
module SyntaxHighlighter
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -28,7 +28,7 @@ module Kramdown::Converter::SyntaxHighlighter
|
|
28
28
|
|
29
29
|
opts[:wrap] = false if type == :span
|
30
30
|
|
31
|
-
formatter = ::Rouge::Formatters::HTML.new(opts)
|
31
|
+
formatter = (opts.delete(:formatter) || ::Rouge::Formatters::HTML).new(opts)
|
32
32
|
formatter.format(lexer.lex(text))
|
33
33
|
end
|
34
34
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
|
-
require '
|
10
|
+
require 'kramdown/converter'
|
11
11
|
|
12
12
|
module Kramdown
|
13
13
|
|
data/lib/kramdown/document.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
# = kramdown
|
10
10
|
#
|
11
|
-
# kramdown is
|
11
|
+
# kramdown is fast, pure Ruby Markdown superset converter, using a strict syntax definition and
|
12
12
|
# supporting several common extensions.
|
13
13
|
#
|
14
14
|
# The kramdown library is mainly written to support the kramdown-to-HTML conversion chain. However,
|
15
15
|
# due to its flexibility it supports other input and output formats as well. Here is a list of the
|
16
16
|
# supported formats:
|
17
17
|
#
|
18
|
-
# * input formats: kramdown (a Markdown superset), Markdown, HTML
|
19
|
-
# * output formats: HTML, kramdown, LaTeX (and therefore PDF)
|
18
|
+
# * input formats: kramdown (a Markdown superset), Markdown, GFM, HTML
|
19
|
+
# * output formats: HTML, kramdown, LaTeX (and therefore PDF), PDF via Prawn
|
20
20
|
#
|
21
21
|
# All the documentation on the available input and output formats is available at
|
22
22
|
# http://kramdown.gettalong.org.
|
23
23
|
#
|
24
24
|
# == Usage
|
25
25
|
#
|
26
|
-
# kramdown has a
|
26
|
+
# kramdown has a simple API, so using kramdown is as easy as
|
27
27
|
#
|
28
28
|
# require 'kramdown'
|
29
29
|
#
|
data/lib/kramdown/element.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -37,6 +37,9 @@ module Kramdown
|
|
37
37
|
# :abbrev_defs:: This key may be used to store the mapping of abbreviation to abbreviation
|
38
38
|
# definition.
|
39
39
|
#
|
40
|
+
# :abbrev_attr:: This key may be used to store the mapping of abbreviation to abbreviation
|
41
|
+
# attributes.
|
42
|
+
#
|
40
43
|
# :options:: This key may be used to store options that were set during parsing of the document.
|
41
44
|
#
|
42
45
|
#
|
data/lib/kramdown/error.rb
CHANGED
data/lib/kramdown/options.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -418,7 +418,8 @@ specified levels are used for the table of contents.
|
|
418
418
|
Default: 1..6
|
419
419
|
Used by: HTML/Latex converter
|
420
420
|
EOF
|
421
|
-
|
421
|
+
case val
|
422
|
+
when String
|
422
423
|
if val =~ /^(\d)\.\.(\d)$/
|
423
424
|
val = Range.new($1.to_i, $2.to_i).to_a
|
424
425
|
elsif val =~ /^\d(?:,\d)*$/
|
@@ -426,7 +427,7 @@ EOF
|
|
426
427
|
else
|
427
428
|
raise Kramdown::Error, "Invalid syntax for option toc_levels"
|
428
429
|
end
|
429
|
-
|
430
|
+
when Array, Range
|
430
431
|
val = val.map {|s| s.to_i}.uniq
|
431
432
|
else
|
432
433
|
raise Kramdown::Error, "Invalid type #{val.class} for option toc_levels"
|
data/lib/kramdown/parser.rb
CHANGED
data/lib/kramdown/parser/base.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
|
-
require 'kramdown/utils
|
10
|
+
require 'kramdown/utils'
|
11
|
+
require 'kramdown/parser'
|
11
12
|
|
12
13
|
module Kramdown
|
13
14
|
|
@@ -51,7 +52,8 @@ module Kramdown
|
|
51
52
|
def initialize(source, options)
|
52
53
|
@source = source
|
53
54
|
@options = Kramdown::Options.merge(options)
|
54
|
-
@root = Element.new(:root, nil, nil, :encoding => (source.encoding rescue nil), :location => 1
|
55
|
+
@root = Element.new(:root, nil, nil, :encoding => (source.encoding rescue nil), :location => 1,
|
56
|
+
:options => {}, :abbrev_defs => {}, :abbrev_attr => {})
|
55
57
|
@warnings = []
|
56
58
|
@text_type = :text
|
57
59
|
end
|
@@ -88,7 +90,9 @@ module Kramdown
|
|
88
90
|
# +\n+ and makes sure +source+ ends with a new line character).
|
89
91
|
def adapt_source(source)
|
90
92
|
if source.respond_to?(:encode)
|
91
|
-
|
93
|
+
if !source.valid_encoding?
|
94
|
+
raise "The source text contains invalid characters for the used encoding #{source.encoding}"
|
95
|
+
end
|
92
96
|
source = source.encode('UTF-8')
|
93
97
|
end
|
94
98
|
source.gsub(/\r\n?/, "\n").chomp + "\n"
|
data/lib/kramdown/parser/gfm.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
2
9
|
|
3
|
-
|
10
|
+
|
11
|
+
require 'kramdown/parser'
|
4
12
|
|
5
13
|
module Kramdown
|
6
14
|
module Parser
|
data/lib/kramdown/parser/html.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -10,6 +10,7 @@
|
|
10
10
|
require 'rexml/parsers/baseparser'
|
11
11
|
require 'strscan'
|
12
12
|
require 'kramdown/utils'
|
13
|
+
require 'kramdown/parser'
|
13
14
|
|
14
15
|
module Kramdown
|
15
16
|
|
@@ -78,8 +79,7 @@ module Kramdown
|
|
78
79
|
def handle_html_start_tag(line = nil) # :yields: el, closed, handle_body
|
79
80
|
name = @src[1].downcase
|
80
81
|
closed = !@src[4].nil?
|
81
|
-
attrs =
|
82
|
-
@src[2].scan(HTML_ATTRIBUTE_RE).each {|attr,sep,val| attrs[attr.downcase] = val || ""}
|
82
|
+
attrs = parse_html_attributes(@src[2], line)
|
83
83
|
|
84
84
|
el = Element.new(:html_element, name, attrs, :category => :block)
|
85
85
|
el.options[:location] = line if line
|
@@ -97,6 +97,21 @@ module Kramdown
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
# Parses the given string for HTML attributes and returns the resulting hash.
|
101
|
+
#
|
102
|
+
# If the optional +line+ parameter is supplied, it is used in warning messages.
|
103
|
+
def parse_html_attributes(str, line = nil)
|
104
|
+
attrs = Utils::OrderedHash.new
|
105
|
+
str.scan(HTML_ATTRIBUTE_RE).each do |attr, sep, val|
|
106
|
+
attr.downcase!
|
107
|
+
if attrs.has_key?(attr)
|
108
|
+
warning("Duplicate HTML attribute '#{attr}' on line #{line || '?'} - overwriting previous one")
|
109
|
+
end
|
110
|
+
attrs[attr] = val || ""
|
111
|
+
end
|
112
|
+
attrs
|
113
|
+
end
|
114
|
+
|
100
115
|
# Handle the raw HTML tag at the current position.
|
101
116
|
def handle_raw_html_tag(name)
|
102
117
|
curpos = @src.pos
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
require 'strscan'
|
11
11
|
require 'stringio'
|
12
|
+
require 'kramdown/parser'
|
12
13
|
|
13
14
|
#TODO: use [[:alpha:]] in all regexp to allow parsing of international values in 1.9.1
|
14
15
|
#NOTE: use @src.pre_match only before other check/match?/... operations, otherwise the content is changed
|
@@ -66,7 +67,6 @@ module Kramdown
|
|
66
67
|
|
67
68
|
reset_env
|
68
69
|
|
69
|
-
@root.options[:abbrev_defs] = {}
|
70
70
|
@alds = {}
|
71
71
|
@footnotes = {}
|
72
72
|
@link_defs = {}
|
@@ -88,6 +88,7 @@ module Kramdown
|
|
88
88
|
configure_parser
|
89
89
|
parse_blocks(@root, adapt_source(source))
|
90
90
|
update_tree(@root)
|
91
|
+
correct_abbreviations_attributes
|
91
92
|
replace_abbreviations(@root)
|
92
93
|
@footnotes.each {|name,data| update_tree(data[:content])}
|
93
94
|
end
|
@@ -134,7 +135,6 @@ module Kramdown
|
|
134
135
|
|
135
136
|
status = catch(:stop_block_parsing) do
|
136
137
|
while !@src.eos?
|
137
|
-
block_ial_set = @block_ial
|
138
138
|
@block_parsers.any? do |name|
|
139
139
|
if @src.check(@parsers[name].start_re)
|
140
140
|
send(@parsers[name].method)
|
@@ -145,7 +145,6 @@ module Kramdown
|
|
145
145
|
warning('Warning: this should not occur - no block parser handled the line')
|
146
146
|
add_text(@src.scan(/.*\n/))
|
147
147
|
end
|
148
|
-
@block_ial = nil if block_ial_set
|
149
148
|
end
|
150
149
|
end
|
151
150
|
|
@@ -165,6 +164,7 @@ module Kramdown
|
|
165
164
|
parse_spans(child)
|
166
165
|
child.children
|
167
166
|
elsif child.type == :eob
|
167
|
+
update_attr_with_ial(child.attr, child.options[:ial]) if child.options[:ial]
|
168
168
|
[]
|
169
169
|
elsif child.type == :blank
|
170
170
|
if last_blank
|
@@ -290,7 +290,10 @@ module Kramdown
|
|
290
290
|
# exists. This method should always be used for creating a block-level element!
|
291
291
|
def new_block_el(*args)
|
292
292
|
el = Element.new(*args)
|
293
|
-
|
293
|
+
if @block_ial
|
294
|
+
el.options[:ial] = @block_ial
|
295
|
+
@block_ial = nil
|
296
|
+
end
|
294
297
|
el
|
295
298
|
end
|
296
299
|
|