motion-kramdown 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -7
- 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 +12 -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 +17 -5
- 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/lib/rubymotion/version.rb +1 -1
- data/spec/bench_mark.rb +43 -30
- data/spec/document_tree.rb +12 -2
- data/spec/gfm_to_html.rb +4 -1
- data/spec/html_to_html.rb +27 -9
- data/spec/html_to_kramdown_to_html.rb +4 -1
- data/spec/kramdown_to_xxx.rb +3 -1
- data/spec/text_to_kramdown_to_html.rb +4 -0
- data/spec/text_to_latex.rb +1 -1
- metadata +5 -4
@@ -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
|
#++
|
@@ -23,7 +23,10 @@ module Kramdown
|
|
23
23
|
TRAILING_WHITESPACE = /[ \t]*\n/
|
24
24
|
|
25
25
|
def handle_kramdown_html_tag(el, closed, handle_body)
|
26
|
-
|
26
|
+
if @block_ial
|
27
|
+
el.options[:ial] = @block_ial
|
28
|
+
@block_ial = nil
|
29
|
+
end
|
27
30
|
|
28
31
|
content_model = if @tree.type != :html_element || @tree.options[:content_model] != :raw
|
29
32
|
(@options[:parse_block_html] ? HTML_CONTENT_MODEL[el.value] : :raw)
|
@@ -117,8 +120,8 @@ module Kramdown
|
|
117
120
|
return
|
118
121
|
end
|
119
122
|
|
120
|
-
attrs =
|
121
|
-
|
123
|
+
attrs = parse_html_attributes(@src[2], line)
|
124
|
+
attrs.each {|name, value| value.gsub!(/\n+/, ' ')}
|
122
125
|
|
123
126
|
do_parsing = (HTML_CONTENT_MODEL[tag_name] == :raw || @tree.options[:content_model] == :raw ? false : @options[:parse_span_html])
|
124
127
|
if val = HTML_MARKDOWN_ATTR_MAP[attrs.delete('markdown')]
|
@@ -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
|
#++
|
@@ -25,8 +25,8 @@ module Kramdown
|
|
25
25
|
@src.pos += @src.matched_size
|
26
26
|
link_id, link_url, link_title = normalize_link_id(@src[1]), @src[2] || @src[3], @src[5]
|
27
27
|
warning("Duplicate link ID '#{link_id}' on line #{@src.current_line_number} - overwriting") if @link_defs[link_id]
|
28
|
-
@
|
29
|
-
@tree.children
|
28
|
+
@tree.children << new_block_el(:eob, :link_def)
|
29
|
+
@link_defs[link_id] = [link_url, link_title, @tree.children.last]
|
30
30
|
true
|
31
31
|
end
|
32
32
|
define_parser(:link_definition, LINK_DEFINITION_START)
|
@@ -34,7 +34,9 @@ module Kramdown
|
|
34
34
|
|
35
35
|
# This helper methods adds the approriate attributes to the element +el+ of type +a+ or +img+
|
36
36
|
# and the element itself to the @tree.
|
37
|
-
def add_link(el, href, title, alt_text = nil)
|
37
|
+
def add_link(el, href, title, alt_text = nil, ial = nil)
|
38
|
+
el.options[:ial] = ial
|
39
|
+
update_attr_with_ial(el.attr, ial) if ial
|
38
40
|
if el.type == :a
|
39
41
|
el.attr['href'] = href
|
40
42
|
else
|
@@ -86,7 +88,8 @@ module Kramdown
|
|
86
88
|
if @src.scan(LINK_INLINE_ID_RE) || !@src.check(/\(/)
|
87
89
|
link_id = normalize_link_id(@src[1] || alt_text)
|
88
90
|
if @link_defs.has_key?(link_id)
|
89
|
-
add_link(el, @link_defs[link_id]
|
91
|
+
add_link(el, @link_defs[link_id][0], @link_defs[link_id][1], alt_text,
|
92
|
+
@link_defs[link_id][2] && @link_defs[link_id][2].options[:ial])
|
90
93
|
else
|
91
94
|
warning("No link definition for link ID '#{link_id}' found on line #{start_line_number}")
|
92
95
|
@src.revert_pos(saved_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
|
#++
|
@@ -19,6 +19,14 @@ module Kramdown
|
|
19
19
|
LIST_ITEM_IAL = /^\s*(?:\{:(?!(?:#{ALD_ID_NAME})?:|\/)(#{ALD_ANY_CHARS}+)\})\s*/
|
20
20
|
LIST_ITEM_IAL_CHECK = /^#{LIST_ITEM_IAL}?\s*\n/
|
21
21
|
|
22
|
+
PARSE_FIRST_LIST_LINE_REGEXP_CACHE = Hash.new do |h, indentation|
|
23
|
+
indent_re = /^ {#{indentation}}/
|
24
|
+
content_re = /^(?:(?:\t| {4}){#{indentation / 4}} {#{indentation % 4}}|(?:\t| {4}){#{indentation / 4 + 1}}).*\S.*\n/
|
25
|
+
lazy_re = /(?!^ {0,#{[indentation, 3].min}}(?:#{IAL_BLOCK}|#{LAZY_END_HTML_STOP}|#{LAZY_END_HTML_START})).*\S.*\n/
|
26
|
+
|
27
|
+
h[indentation] = [content_re, lazy_re, indent_re]
|
28
|
+
end
|
29
|
+
|
22
30
|
# Used for parsing the first line of a list item or a definition, i.e. the line with list item
|
23
31
|
# marker or the definition marker.
|
24
32
|
def parse_first_list_line(indentation, content)
|
@@ -27,13 +35,16 @@ module Kramdown
|
|
27
35
|
else
|
28
36
|
while content =~ /^ *\t/
|
29
37
|
temp = content.scan(/^ */).first.length + indentation
|
30
|
-
|
31
|
-
content = content.sub(/^( *)(\t+)/) {$1 << " "*(4 - (temp % 4) + ($2.length - 1)*4)}
|
38
|
+
content.sub!(/^( *)(\t+)/) {$1 << " "*(4 - (temp % 4) + ($2.length - 1)*4)}
|
32
39
|
end
|
33
|
-
indentation += content
|
40
|
+
indentation += content[/^ */].length
|
34
41
|
end
|
35
42
|
content = content.sub(/^\s*/, '')
|
36
43
|
|
44
|
+
# [content, indentation, *PARSE_FIRST_LIST_LINE_REGEXP_CACHE[indentation]] # RM use caching code below
|
45
|
+
|
46
|
+
# RM This cache is still faster than the one added abouve (because it's recreated
|
47
|
+
# for every new instance)
|
37
48
|
unless (indent_re = StringScanner.get_regex("^ {#{indentation}}")) # RM
|
38
49
|
indent_re = /^ {#{indentation}}/
|
39
50
|
StringScanner.cache_regex("^ {#{indentation}}", indent_re) # RM
|
@@ -47,6 +58,7 @@ module Kramdown
|
|
47
58
|
StringScanner.cache_regex("(?!^ {0,#{[indentation, 3].min}}(?:#{IAL_BLOCK}|#{LAZY_END_HTML_STOP}|#{LAZY_END_HTML_START})).*\S.*\n", lazy_re) # RM
|
48
59
|
end # RM
|
49
60
|
[content, indentation, content_re, lazy_re, indent_re]
|
61
|
+
|
50
62
|
end
|
51
63
|
|
52
64
|
|
@@ -94,7 +106,7 @@ module Kramdown
|
|
94
106
|
last_is_blank = false
|
95
107
|
item.value = [item.value]
|
96
108
|
elsif (result = @src.scan(content_re)) || (!last_is_blank && (result = @src.scan(lazy_re)))
|
97
|
-
result.sub!(/^(\t+)/) { " "*
|
109
|
+
result.sub!(/^(\t+)/) { " " * 4 * $1.length }
|
98
110
|
result.sub!(indent_re, '')
|
99
111
|
if !nested_list_found && result =~ LIST_START
|
100
112
|
item.value << ''
|
@@ -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
|
#++
|
@@ -27,7 +27,7 @@ module Kramdown
|
|
27
27
|
|
28
28
|
saved_pos = @src.save_pos
|
29
29
|
@src.pos += @src.matched_size
|
30
|
-
data = @src[2]
|
30
|
+
data = @src[2].strip
|
31
31
|
if before_block_boundary?
|
32
32
|
@tree.children << new_block_el(:math, data, nil, :category => :block, :location => start_line_number)
|
33
33
|
true
|
@@ -45,7 +45,7 @@ module Kramdown
|
|
45
45
|
def parse_inline_math
|
46
46
|
start_line_number = @src.current_line_number
|
47
47
|
@src.pos += @src.matched_size
|
48
|
-
@tree.children << Element.new(:math, @src[1], nil, :category => :span, :location => start_line_number)
|
48
|
+
@tree.children << Element.new(:math, @src[1].strip, nil, :category => :span, :location => start_line_number)
|
49
49
|
end
|
50
50
|
define_parser(:inline_math, INLINE_MATH_START, '\$')
|
51
51
|
|
@@ -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
|
#++
|
@@ -18,7 +18,7 @@ module Kramdown
|
|
18
18
|
class Kramdown
|
19
19
|
|
20
20
|
LAZY_END_HTML_SPAN_ELEMENTS = Kramdown::Parser::Html::HTML_SPAN_ELEMENTS + %w{script} # RM
|
21
|
-
LAZY_END_HTML_START = /<(?>(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR})
|
21
|
+
LAZY_END_HTML_START = /<(?>(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR})/
|
22
22
|
LAZY_END_HTML_STOP = /<\/(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR}\s*>/m
|
23
23
|
|
24
24
|
OPT_SPACE_LAZY_END_HTML_START = /^#{OPT_SPACE}#{LAZY_END_HTML_START}/m # RM Oniguruma -> ICU
|
@@ -37,7 +37,7 @@ module Kramdown
|
|
37
37
|
while !@src.match?(self.class::PARAGRAPH_END)
|
38
38
|
result << @src.scan(PARAGRAPH_MATCH)
|
39
39
|
end
|
40
|
-
result.
|
40
|
+
result.rstrip!
|
41
41
|
if @tree.children.last && @tree.children.last.type == :p
|
42
42
|
@tree.children.last.children.first.value << "\n" << result
|
43
43
|
else
|
@@ -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
|
-
# RM require 'kramdown/parser
|
10
|
+
# RM require 'kramdown/parser'
|
11
11
|
|
12
12
|
module Kramdown
|
13
13
|
|
data/lib/kramdown/utils.rb
CHANGED
data/lib/kramdown/utils/html.rb
CHANGED
@@ -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
|
+
# RM require 'rexml/parsers/baseparser'
|
11
|
+
|
10
12
|
module Kramdown
|
11
13
|
|
12
14
|
module Utils
|
data/lib/kramdown/version.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,6 @@
|
|
10
10
|
module Kramdown
|
11
11
|
|
12
12
|
# The kramdown version.
|
13
|
-
VERSION = '1.
|
13
|
+
VERSION = '1.6.0'
|
14
14
|
|
15
15
|
end
|
data/lib/rubymotion/version.rb
CHANGED
data/spec/bench_mark.rb
CHANGED
@@ -1,30 +1,43 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
1
|
+
# Hoedown flags
|
2
|
+
# ------------------------------------------------------------------------------
|
3
|
+
FLAGS = HOEDOWN_EXT_TABLES | HOEDOWN_EXT_FENCED_CODE | HOEDOWN_EXT_FOOTNOTES |
|
4
|
+
HOEDOWN_EXT_AUTOLINK | HOEDOWN_EXT_STRIKETHROUGH | HOEDOWN_EXT_HIGHLIGHT |
|
5
|
+
HOEDOWN_EXT_SUPERSCRIPT | HOEDOWN_EXT_MATH | HOEDOWN_EXT_NO_INTRA_EMPHASIS
|
6
|
+
|
7
|
+
runs = 10
|
8
|
+
files = ['mdsyntax.text', 'mdbasics.text']
|
9
|
+
benchmark_dir = File.join(File.dirname(__FILE__), '../benchmark')
|
10
|
+
|
11
|
+
puts
|
12
|
+
puts "Running tests on #{Time.now.strftime("%Y-%m-%d")} under #{RUBY_DESCRIPTION}"
|
13
|
+
|
14
|
+
files.each do |file|
|
15
|
+
data = File.read(File.join(benchmark_dir, file))
|
16
|
+
puts
|
17
|
+
puts "==> Test using file #{file} and #{runs} runs"
|
18
|
+
|
19
|
+
# results = Benchmark.bmbm do |b|
|
20
|
+
results = Benchmark.bm do |b|
|
21
|
+
b.report("kramdown #{Kramdown::VERSION}") { runs.times { Kramdown::Document.new(data).to_html } }
|
22
|
+
b.report(" hoedown 3.0.1") do
|
23
|
+
runs.times do
|
24
|
+
document = HoedownDocument.new
|
25
|
+
document.initWithHtmlRendererWithFlags(FLAGS)
|
26
|
+
html = document.renderMarkdownString(data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# puts
|
32
|
+
# puts "Real time of X divided by real time of kramdown"
|
33
|
+
# kd = results.shift.real
|
34
|
+
# %w[hoedown].each do |name|
|
35
|
+
# puts name.ljust(19) << (results.shift.real/kd).round(4).to_s
|
36
|
+
# end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "Benchmark Test" do
|
40
|
+
it "benchmarks with mdsyntax.text and mdbasics.text" do
|
41
|
+
expect(true).to eq true
|
42
|
+
end
|
43
|
+
end
|