Browse Source

del -> strikethrough

pull/25/head
Vitaly Puzrin 10 years ago
parent
commit
2090fd4998
  1. 2
      lib/parser_inline.js
  2. 8
      lib/renderer.js
  3. 7
      lib/rules_inline/strikethrough.js
  4. 16
      test/fixtures/markdown-it/strikethrough.txt

2
lib/parser_inline.js

@ -17,7 +17,7 @@ var _rules = [
[ 'newline', require('./rules_inline/newline') ],
[ 'escape', require('./rules_inline/escape') ],
[ 'backtick', require('./rules_inline/backtick') ],
[ 'del', require('./rules_inline/del') ],
[ 'strikethrough', require('./rules_inline/strikethrough') ],
[ 'emphasis', require('./rules_inline/emphasis') ],
[ 'link', require('./rules_inline/link') ],
[ 'image', require('./rules_inline/image') ],

8
lib/renderer.js

@ -201,11 +201,11 @@ rules.em_close = function (/* tokens, idx, options, env */) {
};
rules.del_open = function (/* tokens, idx, options, env */) {
return '<del>';
rules.s_open = function (/* tokens, idx, options, env */) {
return '<s>';
};
rules.del_close = function (/* tokens, idx, options, env */) {
return '</del>';
rules.s_close = function (/* tokens, idx, options, env */) {
return '</s>';
};

7
lib/rules_inline/del.js → lib/rules_inline/strikethrough.js

@ -29,7 +29,8 @@ function scanDelims(state, start) {
};
}
module.exports = function(state, silent) {
module.exports = function strikethrough(state, silent) {
var startCount,
count,
tagCount,
@ -91,9 +92,9 @@ module.exports = function(state, silent) {
state.pos = start + 2;
// Earlier we checked !silent, but this implementation does not need it
state.push({ type: 'del_open', level: state.level++ });
state.push({ type: 's_open', level: state.level++ });
state.md.inline.tokenize(state);
state.push({ type: 'del_close', level: --state.level });
state.push({ type: 's_close', level: --state.level });
state.pos = state.posMax + 2;
state.posMax = max;

16
test/fixtures/markdown-it/del.txt → test/fixtures/markdown-it/strikethrough.txt

@ -1,32 +1,32 @@
.
~~Strikeout~~
.
<p><del>Strikeout</del></p>
<p><s>Strikeout</s></p>
.
.
x ~~~~foo~~ bar~~
.
<p>x <del><del>foo</del> bar</del></p>
<p>x <s><s>foo</s> bar</s></p>
.
.
x ~~foo ~~bar~~~~
.
<p>x <del>foo <del>bar</del></del></p>
<p>x <s>foo <s>bar</s></s></p>
.
.
x ~~~~foo~~~~
.
<p>x <del><del>foo</del></del></p>
<p>x <s><s>foo</s></s></p>
.
# Disabled since we moved subsripts to plugins
#.
#x ~~~foo~~~
#.
#<p>x <del><sub>foo</sub></del></p>
#<p>x <s><sub>foo</sub></s></p>
#.
Strikeouts have the same priority as emphases:
@ -37,7 +37,7 @@ Strikeouts have the same priority as emphases:
~~**test~~**
.
<p><strong>~~test</strong>~~</p>
<p><del>**test</del>**</p>
<p><s>**test</s>**</p>
.
Strikeouts have the same priority as emphases with respect to links:
@ -64,13 +64,13 @@ Nested strikeouts:
.
~~foo ~~bar~~ baz~~
.
<p><del>foo <del>bar</del> baz</del></p>
<p><s>foo <s>bar</s> baz</s></p>
.
.
~~f **o ~~o b~~ a** r~~
.
<p><del>f <strong>o <del>o b</del> a</strong> r</del></p>
<p><s>f <strong>o <s>o b</s> a</strong> r</s></p>
.
Should not have a whitespace between text and "~~":
Loading…
Cancel
Save