motion-markdown-it 8.4.1.1 → 9.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +43 -2
- data/lib/motion-markdown-it/common/entities.rb +3 -0
- data/lib/motion-markdown-it/common/simpleidn.rb +8 -9
- data/lib/motion-markdown-it/common/utils.rb +48 -8
- data/lib/motion-markdown-it/helpers/parse_link_destination.rb +5 -5
- data/lib/motion-markdown-it/helpers/parse_link_label.rb +1 -1
- data/lib/motion-markdown-it/helpers/parse_link_title.rb +3 -3
- data/lib/motion-markdown-it/parser_core.rb +3 -3
- data/lib/motion-markdown-it/ruler.rb +3 -3
- data/lib/motion-markdown-it/rules_block/blockquote.rb +8 -8
- data/lib/motion-markdown-it/rules_block/fence.rb +5 -3
- data/lib/motion-markdown-it/rules_block/heading.rb +4 -4
- data/lib/motion-markdown-it/rules_block/hr.rb +2 -2
- data/lib/motion-markdown-it/rules_block/html_block.rb +2 -1
- data/lib/motion-markdown-it/rules_block/lheading.rb +2 -1
- data/lib/motion-markdown-it/rules_block/list.rb +36 -12
- data/lib/motion-markdown-it/rules_block/reference.rb +13 -13
- data/lib/motion-markdown-it/rules_block/state_block.rb +13 -11
- data/lib/motion-markdown-it/rules_block/table.rb +8 -8
- data/lib/motion-markdown-it/rules_core/linkify.rb +1 -1
- data/lib/motion-markdown-it/rules_core/normalize.rb +2 -2
- data/lib/motion-markdown-it/rules_core/replacements.rb +1 -1
- data/lib/motion-markdown-it/rules_core/smartquotes.rb +5 -5
- data/lib/motion-markdown-it/rules_inline/autolink.rb +3 -2
- data/lib/motion-markdown-it/rules_inline/backticks.rb +8 -5
- data/lib/motion-markdown-it/rules_inline/balance_pairs.rb +13 -3
- data/lib/motion-markdown-it/rules_inline/emphasis.rb +1 -1
- data/lib/motion-markdown-it/rules_inline/entity.rb +6 -6
- data/lib/motion-markdown-it/rules_inline/escape.rb +3 -3
- data/lib/motion-markdown-it/rules_inline/html_inline.rb +5 -5
- data/lib/motion-markdown-it/rules_inline/image.rb +8 -8
- data/lib/motion-markdown-it/rules_inline/link.rb +7 -7
- data/lib/motion-markdown-it/rules_inline/newline.rb +4 -4
- data/lib/motion-markdown-it/rules_inline/state_inline.rb +7 -7
- data/lib/motion-markdown-it/rules_inline/strikethrough.rb +1 -1
- data/lib/motion-markdown-it/rules_inline/text.rb +2 -1
- data/lib/motion-markdown-it/rules_inline/text_collapse.rb +10 -2
- data/lib/motion-markdown-it/version.rb +1 -3
- data/lib/motion-markdown-it.rb +0 -1
- data/spec/spec_helper.rb +2 -1
- metadata +11 -13
- data/lib/motion-markdown-it/common/string.rb +0 -14
@@ -45,9 +45,9 @@ module MarkdownIt
|
|
45
45
|
pushPending unless @pending.empty?
|
46
46
|
|
47
47
|
token = Token.new(type, tag, nesting);
|
48
|
-
@level -= 1 if nesting < 0
|
48
|
+
@level -= 1 if nesting < 0 # closing tag
|
49
49
|
token.level = @level
|
50
|
-
@level += 1 if nesting > 0
|
50
|
+
@level += 1 if nesting > 0 # opening tag
|
51
51
|
|
52
52
|
@pendingLevel = @level
|
53
53
|
@tokens.push(token)
|
@@ -65,19 +65,19 @@ module MarkdownIt
|
|
65
65
|
left_flanking = true
|
66
66
|
right_flanking = true
|
67
67
|
max = @posMax
|
68
|
-
marker = @src
|
68
|
+
marker = charCodeAt(@src, start)
|
69
69
|
|
70
70
|
# treat beginning of the line as a whitespace
|
71
|
-
lastChar = start > 0 ? @src
|
71
|
+
lastChar = start > 0 ? charCodeAt(@src, start - 1) : 0x20
|
72
72
|
|
73
|
-
while (pos < max && @src
|
73
|
+
while (pos < max && charCodeAt(@src, pos) == marker)
|
74
74
|
pos += 1
|
75
75
|
end
|
76
76
|
|
77
77
|
count = pos - start
|
78
78
|
|
79
79
|
# treat end of the line as a whitespace
|
80
|
-
nextChar = pos < max ? @src
|
80
|
+
nextChar = pos < max ? charCodeAt(@src, pos) : 0x20
|
81
81
|
|
82
82
|
isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(fromCodePoint(lastChar))
|
83
83
|
isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(fromCodePoint(nextChar))
|
@@ -113,4 +113,4 @@ module MarkdownIt
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
116
|
-
end
|
116
|
+
end
|
@@ -9,7 +9,7 @@ module MarkdownIt
|
|
9
9
|
#------------------------------------------------------------------------------
|
10
10
|
def self.tokenize(state, silent)
|
11
11
|
start = state.pos
|
12
|
-
marker = state.src
|
12
|
+
marker = charCodeAt(state.src, start)
|
13
13
|
|
14
14
|
return false if silent
|
15
15
|
|
@@ -4,6 +4,7 @@
|
|
4
4
|
module MarkdownIt
|
5
5
|
module RulesInline
|
6
6
|
class Text
|
7
|
+
extend Common::Utils
|
7
8
|
|
8
9
|
# Rule to skip pure text
|
9
10
|
# '{}$%@~+=:' reserved for extentions
|
@@ -48,7 +49,7 @@ module MarkdownIt
|
|
48
49
|
def self.text(state, silent)
|
49
50
|
pos = state.pos
|
50
51
|
|
51
|
-
while pos < state.posMax && !self.isTerminatorChar(state.src
|
52
|
+
while pos < state.posMax && !self.isTerminatorChar(charCodeAt(state.src, pos))
|
52
53
|
pos += 1
|
53
54
|
end
|
54
55
|
|
@@ -1,4 +1,10 @@
|
|
1
|
+
# Clean up tokens after emphasis and strikethrough postprocessing:
|
1
2
|
# Merge adjacent text nodes into one, and re-calculate all token levels
|
3
|
+
#
|
4
|
+
# This is necessary because initially emphasis delimiter markers (*, _, ~)
|
5
|
+
# are treated as their own separate text tokens. Then emphasis rule either
|
6
|
+
# leaves them as text (needed to merge with adjacent text) or turns them
|
7
|
+
# into opening/closing tags (which messes up levels inside).
|
2
8
|
#------------------------------------------------------------------------------
|
3
9
|
module MarkdownIt
|
4
10
|
module RulesInline
|
@@ -12,9 +18,11 @@ module MarkdownIt
|
|
12
18
|
|
13
19
|
last = curr = 0
|
14
20
|
while curr < max
|
15
|
-
# re-calculate levels
|
16
|
-
|
21
|
+
# re-calculate levels after emphasis/strikethrough turns some text nodes
|
22
|
+
# into opening/closing tags
|
23
|
+
level -= 1 if tokens[curr].nesting < 0 # closing tag
|
17
24
|
tokens[curr].level = level
|
25
|
+
level += 1 if tokens[curr].nesting > 0 # opening tag
|
18
26
|
|
19
27
|
if tokens[curr].type == 'text' &&
|
20
28
|
curr + 1 < max &&
|
data/lib/motion-markdown-it.rb
CHANGED
@@ -24,7 +24,6 @@ else
|
|
24
24
|
require 'motion-markdown-it/common/utils'
|
25
25
|
require 'motion-markdown-it/common/html_blocks'
|
26
26
|
require 'motion-markdown-it/common/html_re'
|
27
|
-
require 'motion-markdown-it/common/string'
|
28
27
|
require 'motion-markdown-it/common/simpleidn'
|
29
28
|
require 'motion-markdown-it/helpers/parse_link_destination'
|
30
29
|
require 'motion-markdown-it/helpers/parse_link_label'
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-markdown-it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 9.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Walker
|
8
8
|
- Vitaly Puzrin
|
9
9
|
- Alex Kocharin
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mdurl-rb
|
@@ -46,28 +46,28 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '4.0'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '4.0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
58
|
+
name: motion-expect
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '2.0'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '
|
70
|
+
version: '2.0'
|
71
71
|
description: Ruby/RubyMotion version of markdown-it
|
72
72
|
email: github@digitalmoksha.com
|
73
73
|
executables: []
|
@@ -80,7 +80,6 @@ files:
|
|
80
80
|
- lib/motion-markdown-it/common/html_blocks.rb
|
81
81
|
- lib/motion-markdown-it/common/html_re.rb
|
82
82
|
- lib/motion-markdown-it/common/simpleidn.rb
|
83
|
-
- lib/motion-markdown-it/common/string.rb
|
84
83
|
- lib/motion-markdown-it/common/utils.rb
|
85
84
|
- lib/motion-markdown-it/helpers/helper_wrapper.rb
|
86
85
|
- lib/motion-markdown-it/helpers/parse_link_destination.rb
|
@@ -142,7 +141,7 @@ homepage: https://github.com/digitalmoksha/motion-markdown-it
|
|
142
141
|
licenses:
|
143
142
|
- MIT
|
144
143
|
metadata: {}
|
145
|
-
post_install_message:
|
144
|
+
post_install_message:
|
146
145
|
rdoc_options: []
|
147
146
|
require_paths:
|
148
147
|
- lib
|
@@ -157,9 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
156
|
- !ruby/object:Gem::Version
|
158
157
|
version: '0'
|
159
158
|
requirements: []
|
160
|
-
|
161
|
-
|
162
|
-
signing_key:
|
159
|
+
rubygems_version: 3.3.23
|
160
|
+
signing_key:
|
163
161
|
specification_version: 4
|
164
162
|
summary: Ruby version markdown-it
|
165
163
|
test_files:
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
|
3
|
-
# grab the remainder of the string starting at 'start'
|
4
|
-
#------------------------------------------------------------------------------
|
5
|
-
def slice_to_end(start)
|
6
|
-
self.slice(start...self.length)
|
7
|
-
end
|
8
|
-
|
9
|
-
# port of Javascript function charCodeAt
|
10
|
-
#------------------------------------------------------------------------------
|
11
|
-
def charCodeAt(ch)
|
12
|
-
self[ch].ord unless self[ch].nil?
|
13
|
-
end
|
14
|
-
end
|