motion-markdown-it 4.1.0.2 → 4.2.2.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 +28 -8
- data/lib/motion-markdown-it/index.rb +11 -7
- data/lib/motion-markdown-it/presets/commonmark.rb +4 -1
- data/lib/motion-markdown-it/presets/default.rb +4 -1
- data/lib/motion-markdown-it/presets/zero.rb +4 -1
- data/lib/motion-markdown-it/ruler.rb +1 -1
- data/lib/motion-markdown-it/rules_block/blockquote.rb +3 -1
- data/lib/motion-markdown-it/rules_block/paragraph.rb +3 -0
- data/lib/motion-markdown-it/rules_block/reference.rb +11 -3
- data/lib/motion-markdown-it/rules_block/state_block.rb +1 -1
- data/lib/motion-markdown-it/rules_block/table.rb +19 -7
- data/lib/motion-markdown-it/rules_core/replacements.rb +0 -2
- data/lib/motion-markdown-it/rules_core/smartquotes.rb +19 -7
- data/lib/motion-markdown-it/rules_inline/emphasis.rb +15 -18
- data/lib/motion-markdown-it/version.rb +1 -1
- data/spec/motion-markdown-it/bench_mark_spec.rb +1 -1
- data/spec/motion-markdown-it/misc_spec.rb +31 -4
- data/spec/motion-markdown-it/utils_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c25f046cd230dec30329ee31997f8d1c4820e888
|
4
|
+
data.tar.gz: 989cfb0a87fd1efbbc4f332e63aff23e4a1c3349
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08c3e0baeb9071852ea680700f33222ece16cec1a8edc5e33c1b8c56cc2c8efb1442a439e8c4ca1838bdec1adb47e21072f50c1eb4496c0172d4da39c5337ff2
|
7
|
+
data.tar.gz: a3a58cdd184efba1d5820d5a8b10e75efa8205f5d938e0f9b87c709320fb8f71c9a899999eecd203004b98fb6f309250746e245da1cfba49c2996af1d15eb375
|
data/README.md
CHANGED
@@ -4,14 +4,17 @@
|
|
4
4
|
|
5
5
|
Ruby/RubyMotion version of Markdown-it (CommonMark compliant and extendable)
|
6
6
|
|
7
|
-
This gem is a port of the [markdown-it Javascript package](https://github.com/markdown-it/markdown-it) by Vitaly Puzrin and Alex Kocharin. Currently synced with markdown-it 4.
|
7
|
+
This gem is a port of the [markdown-it Javascript package](https://github.com/markdown-it/markdown-it) by Vitaly Puzrin and Alex Kocharin. Currently synced with markdown-it 4.2.2
|
8
8
|
|
9
9
|
__[Javascript Live demo](https://markdown-it.github.io)__
|
10
10
|
|
11
|
-
|
11
|
+
Follows the __[CommonMark spec](http://spec.commonmark.org/)__ + adds syntax extensions & sugar (URL autolinking, typographer).
|
12
12
|
- Configurable syntax. You can add new rules and even replace existing ones.
|
13
|
-
-
|
13
|
+
- [Safe](https://github.com/markdown-it/markdown-it/tree/master/docs/security.md) by default.
|
14
14
|
- Community-written plugins
|
15
|
+
- Community-written plugins
|
16
|
+
* [Ruby/RubyMotion](https://github.com/digitalmoksha/motion-markdown-it-plugins)
|
17
|
+
* [original javascript plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin) and [other packages](https://www.npmjs.org/browse/keyword/markdown-it) on npm.
|
15
18
|
|
16
19
|
## Benefit
|
17
20
|
|
@@ -25,6 +28,7 @@ Performance is still an issue. While it performs reasonably well with small to
|
|
25
28
|
|
26
29
|
- [Install](#install)
|
27
30
|
- [Usage examples](#usage-examples)
|
31
|
+
- [Plugins](#plugins)
|
28
32
|
- [References / Thanks](#references--thanks)
|
29
33
|
- [License](#license)
|
30
34
|
|
@@ -101,7 +105,10 @@ parser = MarkdownIt::Parser.new({
|
|
101
105
|
typographer: false,
|
102
106
|
|
103
107
|
# Double + single quotes replacement pairs, when typographer enabled,
|
104
|
-
# and smartquotes on.
|
108
|
+
# and smartquotes on. Could be either a String or an Array.
|
109
|
+
#
|
110
|
+
# For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
111
|
+
# and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
105
112
|
quotes: '“”‘’',
|
106
113
|
|
107
114
|
# Highlighter function. Should return escaped HTML,
|
@@ -110,6 +117,19 @@ parser = MarkdownIt::Parser.new({
|
|
110
117
|
})
|
111
118
|
```
|
112
119
|
|
120
|
+
## Plugins
|
121
|
+
|
122
|
+
Plugins can be used to extend the syntax and functionality. A [sample set of plugins](https://github.com/digitalmoksha/motion-markdown-it-plugins) has been created based on those already created for the javascript version. Included are:
|
123
|
+
|
124
|
+
* [Abbreviations](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/abbr)
|
125
|
+
* [Checkbox/Tasklists](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/checkbox_replace)
|
126
|
+
* [Containers](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/container)
|
127
|
+
* [Definition Lists](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/deflist)
|
128
|
+
* [Insert](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/ins)
|
129
|
+
* [Mark](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/mark)
|
130
|
+
* [Subscript](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/sub)
|
131
|
+
* [Superscript](https://github.com/digitalmoksha/motion-markdown-it-plugins/tree/master/lib/motion-markdown-it-plugins/sup)
|
132
|
+
|
113
133
|
<!--
|
114
134
|
### Plugins load
|
115
135
|
|
@@ -179,7 +199,7 @@ Via plugins:
|
|
179
199
|
### Manage rules
|
180
200
|
|
181
201
|
By default all rules are enabled, but can be restricted by options. On plugin
|
182
|
-
load all
|
202
|
+
load all its rules are enabled automatically.
|
183
203
|
|
184
204
|
```js
|
185
205
|
// Activate/deactivate rules, with curring
|
@@ -197,9 +217,9 @@ md = require('markdown-it')('full', {
|
|
197
217
|
```
|
198
218
|
|
199
219
|
|
200
|
-
## Benchmark
|
220
|
+
## Benchmark (for Javascript version)
|
201
221
|
|
202
|
-
Here is result of readme parse at MB Pro Retina 2013 (2.4 GHz):
|
222
|
+
Here is the result of readme parse at MB Pro Retina 2013 (2.4 GHz):
|
203
223
|
|
204
224
|
```bash
|
205
225
|
$ benchmark/benchmark.js readme
|
@@ -217,7 +237,7 @@ __Note.__ CommonMark version runs with [simplified link normalizers](https://git
|
|
217
237
|
for more "honest" compare. Difference is ~ 1.5x.
|
218
238
|
|
219
239
|
As you can see, `markdown-it` doesn't pay with speed for it's flexibility.
|
220
|
-
Slowdown of "full" version caused by additional features
|
240
|
+
Slowdown of "full" version caused by additional features not available in
|
221
241
|
other implementations.
|
222
242
|
|
223
243
|
-->
|
@@ -8,8 +8,9 @@ CONFIG = {
|
|
8
8
|
}
|
9
9
|
|
10
10
|
#------------------------------------------------------------------------------
|
11
|
-
# This validator
|
12
|
-
#
|
11
|
+
# This validator can prohibit more than really needed to prevent XSS. It's a
|
12
|
+
# tradeoff to keep code simple and to be secure by default.
|
13
|
+
#
|
13
14
|
# If you need different setup - override validator method as you wish. Or
|
14
15
|
# replace it with dummy function and use external sanitizer.
|
15
16
|
|
@@ -151,9 +152,10 @@ module MarkdownIt
|
|
151
152
|
# - __typographer__ - `false`. Set `true` to enable [some language-neutral
|
152
153
|
# replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
|
153
154
|
# quotes beautification (smartquotes).
|
154
|
-
# - __quotes__ - `“”‘’`,
|
155
|
-
# typographer enabled and smartquotes on.
|
156
|
-
# '
|
155
|
+
# - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
|
156
|
+
# pairs, when typographer enabled and smartquotes on. For example, you can
|
157
|
+
# use `'«»„“'` for Russian, `'„“‚‘'` for German, and
|
158
|
+
# `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
|
157
159
|
# - __highlight__ - `nil`. Highlighter function for fenced code blocks.
|
158
160
|
# Highlighter `function (str, lang)` should return escaped HTML. It can also
|
159
161
|
# return nil if the source was not changed and should be escaped externaly.
|
@@ -257,8 +259,10 @@ module MarkdownIt
|
|
257
259
|
# MarkdownIt#validateLink(url) -> Boolean
|
258
260
|
#
|
259
261
|
# Link validation function. CommonMark allows too much in links. By default
|
260
|
-
# we disable `javascript
|
261
|
-
#
|
262
|
+
# we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
|
263
|
+
# except some embedded image types.
|
264
|
+
#
|
265
|
+
# You can change this behaviour:
|
262
266
|
#
|
263
267
|
# ```javascript
|
264
268
|
# var md = require('markdown-it')();
|
@@ -16,7 +16,10 @@ module MarkdownIt
|
|
16
16
|
typographer: false,
|
17
17
|
|
18
18
|
# Double + single quotes replacement pairs, when typographer enabled,
|
19
|
-
# and smartquotes on.
|
19
|
+
# and smartquotes on. Could be either a String or an Array.
|
20
|
+
#
|
21
|
+
# For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
22
|
+
# and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
20
23
|
quotes: "\u201c\u201d\u2018\u2019", # “”‘’
|
21
24
|
|
22
25
|
# Highlighter function. Should return escaped HTML,
|
@@ -16,7 +16,10 @@ module MarkdownIt
|
|
16
16
|
typographer: false,
|
17
17
|
|
18
18
|
# Double + single quotes replacement pairs, when typographer enabled,
|
19
|
-
# and smartquotes on.
|
19
|
+
# and smartquotes on. Could be either a String or an Array.
|
20
|
+
#
|
21
|
+
# For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
22
|
+
# and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
20
23
|
quotes: "\u201c\u201d\u2018\u2019", # “”‘’
|
21
24
|
|
22
25
|
# Highlighter function. Should return escaped HTML,
|
@@ -17,7 +17,10 @@ module MarkdownIt
|
|
17
17
|
typographer: false,
|
18
18
|
|
19
19
|
# Double + single quotes replacement pairs, when typographer enabled,
|
20
|
-
# and smartquotes on.
|
20
|
+
# and smartquotes on. Could be either a String or an Array.
|
21
|
+
#
|
22
|
+
# For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
23
|
+
# and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
21
24
|
quotes: "\u201c\u201d\u2018\u2019", # “”‘’
|
22
25
|
|
23
26
|
# Highlighter function. Should return escaped HTML,
|
@@ -209,7 +209,7 @@ module MarkdownIt
|
|
209
209
|
# * ```javascript
|
210
210
|
# * var md = require('markdown-it')();
|
211
211
|
# *
|
212
|
-
# * md.core.ruler.push('
|
212
|
+
# * md.core.ruler.push('my_rule', function replace(state) {
|
213
213
|
# * //...
|
214
214
|
# * });
|
215
215
|
# * ```
|
@@ -55,6 +55,8 @@ module MarkdownIt
|
|
55
55
|
# ```
|
56
56
|
nextLine = startLine + 1
|
57
57
|
while nextLine < endLine
|
58
|
+
break if state.tShift[nextLine] < oldIndent
|
59
|
+
|
58
60
|
pos = state.bMarks[nextLine] + state.tShift[nextLine]
|
59
61
|
max = state.eMarks[nextLine]
|
60
62
|
|
@@ -104,7 +106,7 @@ module MarkdownIt
|
|
104
106
|
#
|
105
107
|
# Any negative number will do the job here, but it's better for it
|
106
108
|
# to be large enough to make any bugs obvious.
|
107
|
-
state.tShift[nextLine] = -
|
109
|
+
state.tShift[nextLine] = -1
|
108
110
|
nextLine += 1
|
109
111
|
end
|
110
112
|
|
@@ -17,6 +17,9 @@ module MarkdownIt
|
|
17
17
|
# it's considered a lazy continuation regardless of what's there
|
18
18
|
(nextLine += 1) && next if (state.tShift[nextLine] - state.blkIndent > 3)
|
19
19
|
|
20
|
+
# quirk for blockquotes, this line should already be checked by that rule
|
21
|
+
(nextLine += 1) && next if state.tShift[nextLine] < 0
|
22
|
+
|
20
23
|
# Some tags can terminate paragraph without empty line.
|
21
24
|
terminate = false
|
22
25
|
0.upto(terminatorRules.length - 1) do |i|
|
@@ -33,10 +33,12 @@ module MarkdownIt
|
|
33
33
|
terminatorRules = state.md.block.ruler.getRules('reference')
|
34
34
|
|
35
35
|
while nextLine < endLine && !state.isEmpty(nextLine)
|
36
|
-
nextLine += 1
|
37
36
|
# this would be a code block normally, but after paragraph
|
38
37
|
# it's considered a lazy continuation regardless of what's there
|
39
|
-
next if (state.tShift[nextLine] - state.blkIndent > 3)
|
38
|
+
(nextLine += 1) && next if (state.tShift[nextLine] - state.blkIndent > 3)
|
39
|
+
|
40
|
+
# quirk for blockquotes, this line should already be checked by that rule
|
41
|
+
(nextLine += 1) && next if state.tShift[nextLine] < 0
|
40
42
|
|
41
43
|
# Some tags can terminate paragraph without empty line.
|
42
44
|
terminate = false
|
@@ -47,6 +49,7 @@ module MarkdownIt
|
|
47
49
|
end
|
48
50
|
end
|
49
51
|
break if (terminate)
|
52
|
+
nextLine += 1
|
50
53
|
end
|
51
54
|
|
52
55
|
str = state.getLines(startLine, nextLine, state.blkIndent, false).strip
|
@@ -140,11 +143,16 @@ module MarkdownIt
|
|
140
143
|
return false
|
141
144
|
end
|
142
145
|
|
146
|
+
label = normalizeReference(str.slice(1...labelEnd))
|
147
|
+
if label == ''
|
148
|
+
# CommonMark 0.20 disallows empty labels
|
149
|
+
return false
|
150
|
+
end
|
151
|
+
|
143
152
|
# Reference can not terminate anything. This check is for safety only.
|
144
153
|
# istanbul ignore if
|
145
154
|
return true if (silent)
|
146
155
|
|
147
|
-
label = normalizeReference(str.slice(1...labelEnd))
|
148
156
|
if (state.env[:references].nil?)
|
149
157
|
state.env[:references] = {}
|
150
158
|
end
|
@@ -150,7 +150,7 @@ module MarkdownIt
|
|
150
150
|
# Opt: don't use push queue for single line
|
151
151
|
if (line + 1) == line_end
|
152
152
|
first = @bMarks[line] + [@tShift[line], indent].min
|
153
|
-
last
|
153
|
+
last = @eMarks[line_end - 1] + (keepLastLF ? 1 : 0)
|
154
154
|
return @src.slice(first...last)
|
155
155
|
end
|
156
156
|
|
@@ -14,15 +14,21 @@ module MarkdownIt
|
|
14
14
|
|
15
15
|
#------------------------------------------------------------------------------
|
16
16
|
def self.escapedSplit(str)
|
17
|
-
result
|
18
|
-
pos
|
19
|
-
max
|
20
|
-
escapes
|
21
|
-
lastPos
|
22
|
-
|
17
|
+
result = []
|
18
|
+
pos = 0
|
19
|
+
max = str.length
|
20
|
+
escapes = 0
|
21
|
+
lastPos = 0
|
22
|
+
backTicked = false
|
23
|
+
lastBackTick = 0
|
24
|
+
|
25
|
+
ch = str.charCodeAt(pos)
|
23
26
|
|
24
27
|
while (pos < max)
|
25
|
-
if (ch ==
|
28
|
+
if (ch == 0x60 && (escapes % 2 == 0)) # `
|
29
|
+
backTicked = !backTicked
|
30
|
+
lastBackTick = pos
|
31
|
+
elsif (ch == 0x7c && (escapes % 2 == 0) && !backTicked) # '|'
|
26
32
|
result.push(str[lastPos...pos])
|
27
33
|
lastPos = pos + 1
|
28
34
|
elsif (ch == 0x5c) # '\'
|
@@ -32,6 +38,12 @@ module MarkdownIt
|
|
32
38
|
end
|
33
39
|
|
34
40
|
pos += 1
|
41
|
+
# If there was an un-closed backtick, go back to just after
|
42
|
+
# the last backtick, but as if it was a normal character
|
43
|
+
if (pos == max && backTicked)
|
44
|
+
backTicked = false
|
45
|
+
pos = lastBackTick + 1
|
46
|
+
end
|
35
47
|
ch = str.charCodeAt(pos)
|
36
48
|
end
|
37
49
|
|
@@ -105,15 +105,27 @@ module MarkdownIt
|
|
105
105
|
break if (stack[j][:level] < thisLevel)
|
106
106
|
if (item[:single] == isSingle && stack[j][:level] == thisLevel)
|
107
107
|
item = stack[j]
|
108
|
-
if
|
109
|
-
|
110
|
-
|
108
|
+
if isSingle
|
109
|
+
openQuote = state.md.options[:quotes][2]
|
110
|
+
closeQuote = state.md.options[:quotes][3]
|
111
111
|
else
|
112
|
-
|
113
|
-
|
112
|
+
openQuote = state.md.options[:quotes][0]
|
113
|
+
closeQuote = state.md.options[:quotes][1]
|
114
114
|
end
|
115
|
-
|
116
|
-
|
115
|
+
|
116
|
+
# replace token.content *before* tokens[item.token].content,
|
117
|
+
# because, if they are pointing at the same token, replaceAt
|
118
|
+
# could mess up indices when quote length != 1
|
119
|
+
token.content = replaceAt(token.content, t.begin(0), closeQuote)
|
120
|
+
tokens[item[:token]].content = replaceAt(tokens[item[:token]].content, item[:pos], openQuote)
|
121
|
+
|
122
|
+
pos += closeQuote.length - 1
|
123
|
+
pos += (openQuote.length - 1) if item[:token] == i
|
124
|
+
|
125
|
+
text = token.content
|
126
|
+
max = text.length
|
127
|
+
|
128
|
+
stack = (j < stack.length ? stack.slice(0, j) : stack.fill(nil, stack.length...(j))) # stack.length = j
|
117
129
|
continue_outer_loop = true # continue OUTER;
|
118
130
|
break
|
119
131
|
end
|
@@ -9,11 +9,11 @@ module MarkdownIt
|
|
9
9
|
# "start" should point at a valid marker
|
10
10
|
#------------------------------------------------------------------------------
|
11
11
|
def self.scanDelims(state, start)
|
12
|
-
pos
|
13
|
-
|
14
|
-
|
15
|
-
max
|
16
|
-
marker
|
12
|
+
pos = start
|
13
|
+
left_flanking = true
|
14
|
+
right_flanking = true
|
15
|
+
max = state.posMax
|
16
|
+
marker = state.src.charCodeAt(start)
|
17
17
|
|
18
18
|
# treat beginning of the line as a whitespace
|
19
19
|
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : 0x20
|
@@ -22,10 +22,6 @@ module MarkdownIt
|
|
22
22
|
pos += 1
|
23
23
|
end
|
24
24
|
|
25
|
-
if (pos >= max)
|
26
|
-
can_open = false
|
27
|
-
end
|
28
|
-
|
29
25
|
count = pos - start
|
30
26
|
|
31
27
|
# treat end of the line as a whitespace
|
@@ -38,27 +34,28 @@ module MarkdownIt
|
|
38
34
|
isNextWhiteSpace = isWhiteSpace(nextChar)
|
39
35
|
|
40
36
|
if (isNextWhiteSpace)
|
41
|
-
|
37
|
+
left_flanking = false
|
42
38
|
elsif (isNextPunctChar)
|
43
39
|
if (!(isLastWhiteSpace || isLastPunctChar))
|
44
|
-
|
40
|
+
left_flanking = false
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
44
|
if (isLastWhiteSpace)
|
49
|
-
|
45
|
+
right_flanking = false
|
50
46
|
elsif (isLastPunctChar)
|
51
47
|
if (!(isNextWhiteSpace || isNextPunctChar))
|
52
|
-
|
48
|
+
right_flanking = false
|
53
49
|
end
|
54
50
|
end
|
55
51
|
|
56
52
|
if (marker == 0x5F) # _
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
# "_" inside a word can neither open nor close an emphasis
|
54
|
+
can_open = left_flanking && (!right_flanking || isLastPunctChar)
|
55
|
+
can_close = right_flanking && (!left_flanking || isNextPunctChar)
|
56
|
+
else
|
57
|
+
can_open = left_flanking
|
58
|
+
can_close = right_flanking
|
62
59
|
end
|
63
60
|
|
64
61
|
return { can_open: can_open, can_close: can_close, delims: count }
|
@@ -14,7 +14,7 @@ files.each do |file|
|
|
14
14
|
|
15
15
|
# results = Benchmark.bmbm do |b|
|
16
16
|
results = Benchmark.bm do |b|
|
17
|
-
b.report("motion-markdown-it
|
17
|
+
b.report("motion-markdown-it #{MotionMarkdownIt::VERSION}") do
|
18
18
|
parser = MarkdownIt::Parser.new({ html: true, linkify: true, typographer: true })
|
19
19
|
runs.times { parser.render(data) }
|
20
20
|
end
|
@@ -4,7 +4,7 @@ describe 'API' do
|
|
4
4
|
it 'constructor' do
|
5
5
|
expect {
|
6
6
|
MarkdownIt::Parser.new('bad preset')
|
7
|
-
}.to raise_error
|
7
|
+
}.to raise_error(StandardError)
|
8
8
|
|
9
9
|
# options should override preset
|
10
10
|
md = MarkdownIt::Parser.new(:commonmark, { html: false })
|
@@ -23,7 +23,7 @@ describe 'API' do
|
|
23
23
|
|
24
24
|
expect {
|
25
25
|
md.configure
|
26
|
-
}.to raise_error
|
26
|
+
}.to raise_error(StandardError)
|
27
27
|
end
|
28
28
|
|
29
29
|
class TestPlugin
|
@@ -131,11 +131,11 @@ describe 'API' do
|
|
131
131
|
md = MarkdownIt::Parser.new
|
132
132
|
expect {
|
133
133
|
md.enable([ 'link', 'code', 'invalid' ])
|
134
|
-
}.to raise_error
|
134
|
+
}.to raise_error(StandardError)
|
135
135
|
|
136
136
|
expect {
|
137
137
|
md.disable([ 'link', 'code', 'invalid' ])
|
138
|
-
}.to raise_error
|
138
|
+
}.to raise_error(StandardError)
|
139
139
|
|
140
140
|
expect {
|
141
141
|
md.enable([ 'link', 'code' ])
|
@@ -301,3 +301,30 @@ describe 'maxNesting' do
|
|
301
301
|
end
|
302
302
|
|
303
303
|
end
|
304
|
+
|
305
|
+
#------------------------------------------------------------------------------
|
306
|
+
describe 'smartquotes' do
|
307
|
+
md = MarkdownIt::Parser.new({
|
308
|
+
typographer: true,
|
309
|
+
|
310
|
+
# all strings have different length to make sure
|
311
|
+
# we didn't accidentally count the wrong one
|
312
|
+
quotes: [ '[[[', ']]', '(((((', '))))' ]
|
313
|
+
})
|
314
|
+
|
315
|
+
#------------------------------------------------------------------------------
|
316
|
+
it 'Should support multi-character quotes' do
|
317
|
+
expect(md.render('"foo" \'bar\'')).to eq "<p>[[[foo]] (((((bar))))</p>\n"
|
318
|
+
end
|
319
|
+
|
320
|
+
#------------------------------------------------------------------------------
|
321
|
+
it 'Should support nested multi-character quotes' do
|
322
|
+
expect(md.render('"foo \'bar\' baz"')).to eq "<p>[[[foo (((((bar)))) baz]]</p>\n"
|
323
|
+
end
|
324
|
+
|
325
|
+
#------------------------------------------------------------------------------
|
326
|
+
it 'Should support multi-character quotes in different tags' do
|
327
|
+
expect(md.render('"a *b \'c *d* e\' f* g"')).to eq "<p>[[[a <em>b (((((c <em>d</em> e)))) f</em> g]]</p>\n"
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
@@ -26,7 +26,7 @@ describe 'Utils' do
|
|
26
26
|
expect(assign({ a: 1 }, nil, { b: 2 })).to eq ({ a: 1, b: 2 })
|
27
27
|
expect {
|
28
28
|
assign({}, 123)
|
29
|
-
}.to raise_error
|
29
|
+
}.to raise_error(StandardError)
|
30
30
|
end
|
31
31
|
|
32
32
|
#------------------------------------------------------------------------------
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-markdown-it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Walker
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-06-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mdurl-rb
|