motion-kramdown 0.6.0 → 1.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +6 -2
- data/lib/kramdown.rb +1 -1
- data/lib/kramdown/converter.rb +10 -11
- data/lib/kramdown/converter/base.rb +19 -12
- data/lib/kramdown/converter/hash_ast.rb +38 -0
- data/lib/kramdown/converter/html.rb +71 -39
- data/lib/kramdown/converter/kramdown.rb +19 -10
- data/lib/kramdown/converter/latex.rb +28 -10
- data/lib/kramdown/converter/man.rb +303 -0
- data/lib/kramdown/converter/math_engine/itex2mml.rb +2 -2
- data/lib/kramdown/converter/math_engine/mathjax.rb +13 -3
- data/lib/kramdown/converter/math_engine/mathjaxnode.rb +56 -0
- data/lib/kramdown/converter/math_engine/ritex.rb +2 -2
- data/lib/kramdown/converter/math_engine/sskatex.rb +97 -0
- data/lib/kramdown/converter/pdf.rb +6 -6
- data/lib/kramdown/converter/remove_html_tags.rb +5 -3
- data/lib/kramdown/converter/syntax_highlighter.rb +5 -2
- data/lib/kramdown/converter/syntax_highlighter/coderay.rb +8 -5
- data/lib/kramdown/converter/syntax_highlighter/minted.rb +35 -0
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +48 -10
- data/lib/kramdown/converter/toc.rb +2 -2
- data/lib/kramdown/document.rb +16 -19
- data/lib/kramdown/element.rb +5 -1
- data/lib/kramdown/error.rb +1 -1
- data/lib/kramdown/options.rb +103 -7
- data/lib/kramdown/parser.rb +1 -1
- data/lib/kramdown/parser/base.rb +12 -18
- data/lib/kramdown/parser/gfm.rb +142 -11
- data/lib/kramdown/parser/html.rb +28 -18
- data/lib/kramdown/parser/kramdown.rb +45 -36
- data/lib/kramdown/parser/kramdown/abbreviation.rb +1 -1
- data/lib/kramdown/parser/kramdown/autolink.rb +2 -8
- data/lib/kramdown/parser/kramdown/blank_line.rb +2 -2
- data/lib/kramdown/parser/kramdown/block_boundary.rb +4 -4
- data/lib/kramdown/parser/kramdown/blockquote.rb +4 -4
- data/lib/kramdown/parser/kramdown/codeblock.rb +11 -8
- 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 +6 -3
- data/lib/kramdown/parser/kramdown/footnote.rb +4 -5
- data/lib/kramdown/parser/kramdown/header.rb +2 -2
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
- data/lib/kramdown/parser/kramdown/html.rb +8 -8
- data/lib/kramdown/parser/kramdown/html_entity.rb +2 -2
- data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
- data/lib/kramdown/parser/kramdown/link.rb +5 -4
- data/lib/kramdown/parser/kramdown/list.rb +17 -10
- data/lib/kramdown/parser/kramdown/math.rb +2 -2
- data/lib/kramdown/parser/kramdown/paragraph.rb +19 -8
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +3 -3
- data/lib/kramdown/parser/kramdown/table.rb +10 -12
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
- data/lib/kramdown/parser/markdown.rb +2 -2
- data/lib/kramdown/utils.rb +2 -1
- data/lib/kramdown/utils/configurable.rb +2 -2
- data/lib/kramdown/utils/entities.rb +1 -1
- data/lib/kramdown/utils/html.rb +2 -2
- data/lib/kramdown/utils/lru_cache.rb +40 -0
- data/lib/kramdown/utils/ordered_hash.rb +2 -71
- data/lib/kramdown/utils/string_scanner.rb +2 -2
- data/lib/kramdown/utils/unidecoder.rb +2 -2
- data/lib/kramdown/version.rb +2 -2
- data/lib/rubymotion/require_override.rb +9 -0
- data/lib/rubymotion/version.rb +1 -1
- data/spec/{helpers → motion-kramdown/_helpers}/it_behaves_like.rb +0 -0
- data/spec/{helpers → motion-kramdown/_helpers}/option_file.rb +2 -2
- data/spec/{helpers → motion-kramdown/_helpers}/tidy.rb +0 -0
- data/spec/motion-kramdown/bench_mark.rb +37 -0
- data/spec/{document_tree.rb → motion-kramdown/document_tree.rb} +11 -1
- data/spec/{gfm_to_html.rb → motion-kramdown/gfm_to_html.rb} +51 -18
- data/spec/{html_to_html.rb → motion-kramdown/html_to_html.rb} +27 -9
- data/spec/{html_to_kramdown_to_html.rb → motion-kramdown/html_to_kramdown_to_html.rb} +35 -16
- data/spec/motion-kramdown/kramdown_to_xxx.rb +75 -0
- data/spec/{test_location.rb → motion-kramdown/test_location.rb} +0 -0
- data/spec/{test_string_scanner_kramdown.rb → motion-kramdown/test_string_scanner_kramdown.rb} +0 -0
- data/spec/motion-kramdown/text_manpage.rb +11 -0
- data/spec/{text_to_kramdown_to_html.rb → motion-kramdown/text_to_kramdown_to_html.rb} +30 -19
- data/spec/{text_to_latex.rb → motion-kramdown/text_to_latex.rb} +0 -0
- data/spec/{helpers/spec_options.rb → spec_helper.rb} +13 -2
- metadata +54 -33
- data/lib/kramdown/compatibility.rb +0 -36
- data/spec/bench_mark.rb +0 -43
- data/spec/kramdown_to_xxx.rb +0 -42
data/lib/kramdown/parser/html.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
require 'rexml/parsers/baseparser'
|
11
|
+
require 'strscan'
|
12
|
+
require 'kramdown/utils'
|
13
|
+
require 'kramdown/parser'
|
14
14
|
|
15
15
|
module Kramdown
|
16
16
|
|
@@ -35,8 +35,8 @@ module Kramdown
|
|
35
35
|
HTML_ENTITY_RE = /&([\w:][\-\w\.:]*);|&#(\d+);|&\#x([0-9a-fA-F]+);/
|
36
36
|
|
37
37
|
HTML_CONTENT_MODEL_BLOCK = %w{address applet article aside blockquote body
|
38
|
-
dd details div dl fieldset figure figcaption footer form header hgroup iframe li
|
39
|
-
|
38
|
+
dd details div dl fieldset figure figcaption footer form header hgroup iframe li main
|
39
|
+
map menu nav noscript object section summary td}
|
40
40
|
HTML_CONTENT_MODEL_SPAN = %w{a abbr acronym b bdo big button cite caption del dfn dt em
|
41
41
|
h1 h2 h3 h4 h5 h6 i ins label legend optgroup p q rb rbc
|
42
42
|
rp rt rtc ruby select small span strong sub sup th tt}
|
@@ -53,12 +53,18 @@ module Kramdown
|
|
53
53
|
# span HTML) and don't appear therefore!
|
54
54
|
# script, textarea
|
55
55
|
HTML_SPAN_ELEMENTS = %w{a abbr acronym b big bdo br button cite code del dfn em i img input
|
56
|
-
ins kbd label option q rb rbc rp rt rtc ruby samp select small span
|
56
|
+
ins kbd label mark option q rb rbc rp rt rtc ruby samp select small span
|
57
57
|
strong sub sup tt u var}
|
58
58
|
HTML_BLOCK_ELEMENTS = %w{address article aside applet body blockquote caption col colgroup dd div dl dt fieldset
|
59
59
|
figcaption footer form h1 h2 h3 h4 h5 h6 header hgroup hr html head iframe legend menu
|
60
|
-
li map nav ol optgroup p pre section summary table tbody td th thead tfoot tr ul}
|
60
|
+
li main map nav ol optgroup p pre section summary table tbody td th thead tfoot tr ul}
|
61
61
|
HTML_ELEMENTS_WITHOUT_BODY = %w{area base br col command embed hr img input keygen link meta param source track wbr}
|
62
|
+
|
63
|
+
HTML_ELEMENT = Hash.new(false)
|
64
|
+
(HTML_SPAN_ELEMENTS + HTML_BLOCK_ELEMENTS + HTML_ELEMENTS_WITHOUT_BODY +
|
65
|
+
HTML_CONTENT_MODEL.keys).each do |a|
|
66
|
+
HTML_ELEMENT[a] = true
|
67
|
+
end
|
62
68
|
end
|
63
69
|
|
64
70
|
|
@@ -77,16 +83,16 @@ module Kramdown
|
|
77
83
|
# element is already closed, ie. contains no body; the third parameter specifies whether the
|
78
84
|
# body - and the end tag - need to be handled in case closed=false).
|
79
85
|
def handle_html_start_tag(line = nil) # :yields: el, closed, handle_body
|
80
|
-
name = @src[1]
|
86
|
+
name = @src[1]
|
87
|
+
name.downcase! if HTML_ELEMENT[name.downcase]
|
81
88
|
closed = !@src[4].nil?
|
82
|
-
attrs = parse_html_attributes(@src[2], line)
|
89
|
+
attrs = parse_html_attributes(@src[2], line, HTML_ELEMENT[name])
|
83
90
|
|
84
91
|
el = Element.new(:html_element, name, attrs, :category => :block)
|
85
92
|
el.options[:location] = line if line
|
86
93
|
@tree.children << el
|
87
94
|
|
88
95
|
if !closed && HTML_ELEMENTS_WITHOUT_BODY.include?(el.value)
|
89
|
-
warning("The HTML tag '#{el.value}' on line #{line} cannot have any content - auto-closing it")
|
90
96
|
closed = true
|
91
97
|
end
|
92
98
|
if name == 'script' || name == 'style'
|
@@ -100,10 +106,13 @@ module Kramdown
|
|
100
106
|
# Parses the given string for HTML attributes and returns the resulting hash.
|
101
107
|
#
|
102
108
|
# If the optional +line+ parameter is supplied, it is used in warning messages.
|
103
|
-
|
109
|
+
#
|
110
|
+
# If the optional +in_html_tag+ parameter is set to +false+, attributes are not modified to
|
111
|
+
# contain only lowercase letters.
|
112
|
+
def parse_html_attributes(str, line = nil, in_html_tag = true)
|
104
113
|
attrs = Utils::OrderedHash.new
|
105
114
|
str.scan(HTML_ATTRIBUTE_RE).each do |attr, sep, val|
|
106
|
-
attr.downcase!
|
115
|
+
attr.downcase! if in_html_tag
|
107
116
|
if attrs.has_key?(attr)
|
108
117
|
warning("Duplicate HTML attribute '#{attr}' on line #{line || '?'} - overwriting previous one")
|
109
118
|
end
|
@@ -150,16 +159,17 @@ module Kramdown
|
|
150
159
|
elsif result = @src.scan(HTML_INSTRUCTION_RE)
|
151
160
|
@tree.children << Element.new(:xml_pi, result, nil, :category => :block, :location => line)
|
152
161
|
elsif @src.scan(HTML_TAG_RE)
|
153
|
-
if method(:handle_html_start_tag).arity
|
162
|
+
if method(:handle_html_start_tag).arity.abs >= 1
|
154
163
|
handle_html_start_tag(line, &block)
|
155
164
|
else
|
156
165
|
handle_html_start_tag(&block) # DEPRECATED: method needs to accept line number in 2.0
|
157
166
|
end
|
158
167
|
elsif @src.scan(HTML_TAG_CLOSE_RE)
|
159
|
-
if @tree.value == @src[1].downcase
|
168
|
+
if @tree.value == (HTML_ELEMENT[@tree.value] ? @src[1].downcase : @src[1])
|
160
169
|
done = true
|
161
170
|
else
|
162
|
-
|
171
|
+
add_text(@src.matched, @tree, :text)
|
172
|
+
warning("Found invalidly used HTML closing tag for '#{@src[1]}' on line #{line} - ignoring it")
|
163
173
|
end
|
164
174
|
else
|
165
175
|
add_text(@src.getch, @tree, :text)
|
@@ -422,7 +432,7 @@ module Kramdown
|
|
422
432
|
else
|
423
433
|
set_basics(el, :codeblock)
|
424
434
|
if el.children.size == 1 && el.children.first.value == 'code'
|
425
|
-
value = (el.children.first.attr['class'] || '').scan(/\blanguage-\
|
435
|
+
value = (el.children.first.attr['class'] || '').scan(/\blanguage-\S+/).first
|
426
436
|
el.attr['class'] = "#{value} #{el.attr['class']}".rstrip if value
|
427
437
|
end
|
428
438
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 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
|
-
|
11
|
-
|
12
|
-
|
10
|
+
require 'strscan'
|
11
|
+
require 'stringio'
|
12
|
+
require 'kramdown/parser'
|
13
13
|
|
14
14
|
#TODO: use [[:alpha:]] in all regexp to allow parsing of international values in 1.9.1
|
15
15
|
#NOTE: use @src.pre_match only before other check/match?/... operations, otherwise the content is changed
|
@@ -90,7 +90,15 @@ module Kramdown
|
|
90
90
|
update_tree(@root)
|
91
91
|
correct_abbreviations_attributes
|
92
92
|
replace_abbreviations(@root)
|
93
|
-
@footnotes.each
|
93
|
+
@footnotes.each do |name,data|
|
94
|
+
update_tree(data[:content])
|
95
|
+
replace_abbreviations(data[:content])
|
96
|
+
end
|
97
|
+
@footnotes.each do |name, data|
|
98
|
+
next if data.key?(:marker)
|
99
|
+
line = data[:content].options[:location]
|
100
|
+
warning("Footnote definition for '#{name}' on line #{line} is unreferenced - ignoring")
|
101
|
+
end
|
94
102
|
end
|
95
103
|
|
96
104
|
#######
|
@@ -178,7 +186,11 @@ module Kramdown
|
|
178
186
|
last_blank = nil
|
179
187
|
update_tree(child)
|
180
188
|
update_attr_with_ial(child.attr, child.options[:ial]) if child.options[:ial]
|
181
|
-
|
189
|
+
# DEPRECATED: option auto_id_stripping will be removed in 2.0 because then this will be
|
190
|
+
# the default behaviour
|
191
|
+
if child.type == :dt || (child.type == :header && @options[:auto_id_stripping])
|
192
|
+
update_raw_text(child)
|
193
|
+
end
|
182
194
|
child
|
183
195
|
end
|
184
196
|
end.flatten!
|
@@ -267,11 +279,8 @@ module Kramdown
|
|
267
279
|
end
|
268
280
|
end
|
269
281
|
|
270
|
-
# Update the raw
|
271
|
-
def
|
272
|
-
# DEPRECATED: option auto_id_stripping will be removed in 2.0 because then this will be the
|
273
|
-
# default behaviour
|
274
|
-
return unless @options[:auto_id_stripping]
|
282
|
+
# Update the raw text for automatic ID generation.
|
283
|
+
def update_raw_text(item)
|
275
284
|
raw_text = ''
|
276
285
|
|
277
286
|
append_text = lambda do |child|
|
@@ -282,8 +291,8 @@ module Kramdown
|
|
282
291
|
end
|
283
292
|
end
|
284
293
|
|
285
|
-
append_text.call(
|
286
|
-
|
294
|
+
append_text.call(item)
|
295
|
+
item.options[:raw_text] = raw_text
|
287
296
|
end
|
288
297
|
|
289
298
|
# Create a new block-level element, taking care of applying a preceding block IAL if it
|
@@ -331,29 +340,29 @@ module Kramdown
|
|
331
340
|
# Regexp for matching the optional space (zero or up to three spaces)
|
332
341
|
OPT_SPACE = / {0,3}/
|
333
342
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
343
|
+
require 'kramdown/parser/kramdown/blank_line'
|
344
|
+
require 'kramdown/parser/kramdown/eob'
|
345
|
+
require 'kramdown/parser/kramdown/paragraph'
|
346
|
+
require 'kramdown/parser/kramdown/header'
|
347
|
+
require 'kramdown/parser/kramdown/blockquote'
|
348
|
+
require 'kramdown/parser/kramdown/table'
|
349
|
+
require 'kramdown/parser/kramdown/codeblock'
|
350
|
+
require 'kramdown/parser/kramdown/horizontal_rule'
|
351
|
+
require 'kramdown/parser/kramdown/list'
|
352
|
+
require 'kramdown/parser/kramdown/link'
|
353
|
+
require 'kramdown/parser/kramdown/extensions'
|
354
|
+
require 'kramdown/parser/kramdown/footnote'
|
355
|
+
require 'kramdown/parser/kramdown/html'
|
356
|
+
require 'kramdown/parser/kramdown/escaped_chars'
|
357
|
+
require 'kramdown/parser/kramdown/html_entity'
|
358
|
+
require 'kramdown/parser/kramdown/line_break'
|
359
|
+
require 'kramdown/parser/kramdown/typographic_symbol'
|
360
|
+
require 'kramdown/parser/kramdown/autolink'
|
361
|
+
require 'kramdown/parser/kramdown/codespan'
|
362
|
+
require 'kramdown/parser/kramdown/emphasis'
|
363
|
+
require 'kramdown/parser/kramdown/smart_quotes'
|
364
|
+
require 'kramdown/parser/kramdown/math'
|
365
|
+
require 'kramdown/parser/kramdown/abbreviation'
|
357
366
|
|
358
367
|
end
|
359
368
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -11,13 +11,7 @@ module Kramdown
|
|
11
11
|
module Parser
|
12
12
|
class Kramdown
|
13
13
|
|
14
|
-
|
15
|
-
ACHARS = '\w\x80-\xFF'
|
16
|
-
elsif RUBY_VERSION < '1.9.0'
|
17
|
-
ACHARS = '\w'
|
18
|
-
else
|
19
|
-
ACHARS = '[[:alnum:]]'
|
20
|
-
end
|
14
|
+
ACHARS = '[[:alnum:]]_'
|
21
15
|
AUTOLINK_START_STR = "<((mailto|https?|ftps?):.+?|[-.#{ACHARS}]+@[-#{ACHARS}]+(?:\.[-#{ACHARS}]+)*\.[a-z]+)>"
|
22
16
|
AUTOLINK_START = /#{AUTOLINK_START_STR}/u
|
23
17
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -11,7 +11,7 @@ module Kramdown
|
|
11
11
|
module Parser
|
12
12
|
class Kramdown
|
13
13
|
|
14
|
-
BLANK_LINE = /(
|
14
|
+
BLANK_LINE = /(?>^\s*\n)+/m # RM Oniguruma -> ICU
|
15
15
|
|
16
16
|
# Parse the blank line at the current postition.
|
17
17
|
def parse_blank_line
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 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
|
-
|
11
|
-
|
12
|
-
|
10
|
+
require 'kramdown/parser/kramdown/extensions'
|
11
|
+
require 'kramdown/parser/kramdown/blank_line'
|
12
|
+
require 'kramdown/parser/kramdown/eob'
|
13
13
|
|
14
14
|
module Kramdown
|
15
15
|
module Parser
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 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
|
-
|
11
|
-
|
12
|
-
|
10
|
+
require 'kramdown/parser/kramdown/blank_line'
|
11
|
+
require 'kramdown/parser/kramdown/extensions'
|
12
|
+
require 'kramdown/parser/kramdown/eob'
|
13
13
|
|
14
14
|
module Kramdown
|
15
15
|
module Parser
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
require 'kramdown/parser/kramdown/blank_line'
|
11
|
+
require 'kramdown/parser/kramdown/extensions'
|
12
|
+
require 'kramdown/parser/kramdown/eob'
|
13
|
+
require 'kramdown/parser/kramdown/paragraph'
|
14
14
|
|
15
15
|
module Kramdown
|
16
16
|
module Parser
|
@@ -33,16 +33,19 @@ module Kramdown
|
|
33
33
|
|
34
34
|
|
35
35
|
FENCED_CODEBLOCK_START = /^~{3,}/
|
36
|
-
FENCED_CODEBLOCK_MATCH = /^((~){3,})\s*?(\
|
36
|
+
FENCED_CODEBLOCK_MATCH = /^((~){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^\1\2*\s*?\n/m
|
37
37
|
|
38
38
|
# Parse the fenced codeblock at the current location.
|
39
39
|
def parse_codeblock_fenced
|
40
40
|
if @src.check(self.class::FENCED_CODEBLOCK_MATCH)
|
41
41
|
start_line_number = @src.current_line_number
|
42
42
|
@src.pos += @src.matched_size
|
43
|
-
el = new_block_el(:codeblock, @src[
|
43
|
+
el = new_block_el(:codeblock, @src[5], nil, :location => start_line_number)
|
44
44
|
lang = @src[3].to_s.strip
|
45
|
-
|
45
|
+
unless lang.empty?
|
46
|
+
el.options[:lang] = lang
|
47
|
+
el.attr['class'] = "language-#{@src[4]}"
|
48
|
+
end
|
46
49
|
@tree.children << el
|
47
50
|
true
|
48
51
|
else
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -22,7 +22,7 @@ module Kramdown
|
|
22
22
|
element = (result.length == 2 ? :strong : :em)
|
23
23
|
type = result[0..0]
|
24
24
|
|
25
|
-
if (type == '_' && @src.pre_match =~ /[[:
|
25
|
+
if (type == '_' && @src.pre_match =~ /[[:alpha:]-]\z/) || @src.check(/\s/) ||
|
26
26
|
@tree.type == element || @stack.any? {|el, _| el.type == element}
|
27
27
|
add_text(result)
|
28
28
|
return
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -128,8 +128,11 @@ module Kramdown
|
|
128
128
|
ALD_ID_CHARS = /[\w-]/
|
129
129
|
ALD_ANY_CHARS = /\\\}|[^\}]/
|
130
130
|
ALD_ID_NAME = /\w#{ALD_ID_CHARS}*/
|
131
|
-
|
132
|
-
|
131
|
+
ALD_CLASS_NAME = /[^\s\.#]+/
|
132
|
+
# RM I don't know why the original has an extra `\2` in it, but a test no
|
133
|
+
# longer passes with. Removed, and all specs pass
|
134
|
+
ALD_TYPE_KEY_VALUE_PAIR = /(#{ALD_ID_NAME})=("|')((?:\\\}|\\\2|[^\}])*?)\2/ # RM
|
135
|
+
ALD_TYPE_CLASS_NAME = /\.(#{ALD_CLASS_NAME})/
|
133
136
|
ALD_TYPE_ID_NAME = /#([A-Za-z][\w:-]*)/
|
134
137
|
ALD_TYPE_ID_OR_CLASS = /#{ALD_TYPE_ID_NAME}|#{ALD_TYPE_CLASS_NAME}/
|
135
138
|
ALD_TYPE_ID_OR_CLASS_MULTI = /((?:#{ALD_TYPE_ID_NAME}|#{ALD_TYPE_CLASS_NAME})+)/
|