From d79f210aba670aab650b51f4ba0882e37949c330 Mon Sep 17 00:00:00 2001
From: Tony Brix
Date: Sat, 14 Nov 2020 20:03:39 -0600
Subject: [PATCH] fix: no strikethrough on different number of tildes (#1821)
Possible Breaking Change: When using the inline.del rule the text is provided in capture group 2 instead of 1.
---
src/Tokenizer.js | 2 +-
src/rules.js | 4 ++--
test/specs/new/del_strikethrough.html | 16 ++++++++++++++++
test/specs/new/del_strikethrough.md | 16 ++++++++++++++++
4 files changed, 35 insertions(+), 3 deletions(-)
create mode 100644 test/specs/new/del_strikethrough.html
create mode 100644 test/specs/new/del_strikethrough.md
diff --git a/src/Tokenizer.js b/src/Tokenizer.js
index 71b1916eda..e7d71fe027 100644
--- a/src/Tokenizer.js
+++ b/src/Tokenizer.js
@@ -585,7 +585,7 @@ module.exports = class Tokenizer {
return {
type: 'del',
raw: cap[0],
- text: cap[1]
+ text: cap[2]
};
}
}
diff --git a/src/rules.js b/src/rules.js
index 8b0aa722fc..13356df367 100644
--- a/src/rules.js
+++ b/src/rules.js
@@ -318,8 +318,8 @@ inline.gfm = merge({}, inline.normal, {
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
- del: /^~+(?=\S)([\s\S]*?\S)~+/,
- text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\test
+
+~~test~
+
+~test~~
+
+test
+
+test
+test
+
+~~test
+
+test~~
+
+
diff --git a/test/specs/new/del_strikethrough.md b/test/specs/new/del_strikethrough.md
new file mode 100644
index 0000000000..f3d5bca081
--- /dev/null
+++ b/test/specs/new/del_strikethrough.md
@@ -0,0 +1,16 @@
+~~test~~
+
+~~test~
+
+~test~~
+
+~test~
+
+~~test
+test~~
+
+~~test
+
+test~~
+
+~~~test~~~