From ba2463f2f505aa581b2e157cd996a40d6139e2f4 Mon Sep 17 00:00:00 2001
From: Alex Kocharin
Date: Wed, 22 Oct 2014 21:32:53 +0400
Subject: [PATCH] Remove dead code in em/del
---
lib/rules_inline/emphasis.js | 19 ++-----------------
lib/rules_inline/strikethrough.js | 7 +------
test/fixtures/remarkable/regression.txt | 11 +++++++++++
3 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/lib/rules_inline/emphasis.js b/lib/rules_inline/emphasis.js
index efaed9d..1259ab7 100644
--- a/lib/rules_inline/emphasis.js
+++ b/lib/rules_inline/emphasis.js
@@ -52,14 +52,12 @@ module.exports = function emphasis(state, silent) {
var startCount,
count,
found,
- ok,
oldCount,
newCount,
stack,
res,
max = state.posMax,
start = state.pos,
- haveLiteralAsterisk,
marker = state.src.charCodeAt(start);
if (marker !== 0x5F/* _ */ && marker !== 0x2A /* * */) { return false; }
@@ -83,7 +81,7 @@ module.exports = function emphasis(state, silent) {
stack = [ startCount ];
while (state.pos < max) {
- if (state.src.charCodeAt(state.pos) === marker && !haveLiteralAsterisk) {
+ if (state.src.charCodeAt(state.pos) === marker) {
res = scanDelims(state, state.pos);
count = res.delims;
if (res.can_close) {
@@ -112,22 +110,9 @@ module.exports = function emphasis(state, silent) {
state.pos += count;
continue;
}
-
- if (res.can_open) {
- stack.push(count);
- state.pos += count;
- continue;
- }
}
- ok = state.parser.skipToken(state);
-
- if (ok) {
- haveLiteralAsterisk = false;
- } else {
- haveLiteralAsterisk = state.src.charCodeAt(state.pos) === marker;
- state.pos++;
- }
+ if (!state.parser.skipToken(state)) { state.pos++; }
}
if (!found) {
diff --git a/lib/rules_inline/strikethrough.js b/lib/rules_inline/strikethrough.js
index e58b131..aa745a0 100644
--- a/lib/rules_inline/strikethrough.js
+++ b/lib/rules_inline/strikethrough.js
@@ -4,7 +4,6 @@
module.exports = function strikethrough(state, silent) {
var found,
- ok,
pos,
max = state.posMax,
start = state.pos,
@@ -54,11 +53,7 @@ module.exports = function strikethrough(state, silent) {
}
}
- ok = state.parser.skipToken(state);
-
- if (!ok) {
- state.pos++;
- }
+ if (!state.parser.skipToken(state)) { state.pos++; }
}
if (!found) {
diff --git a/test/fixtures/remarkable/regression.txt b/test/fixtures/remarkable/regression.txt
index 9cce42c..a1c696b 100644
--- a/test/fixtures/remarkable/regression.txt
+++ b/test/fixtures/remarkable/regression.txt
@@ -60,3 +60,14 @@ test~~
test
~~
.
+
+Link priority, not covered by stmd tests:
+
+.
+[**link]()**
+
+**[link**]()
+.
+**link**
+**link**
+.