From 362fc740001c3b1942dc837001b9423e61fb6944 Mon Sep 17 00:00:00 2001 From: Ismail Cherri Date: Wed, 13 Dec 2023 16:15:52 +0100 Subject: [PATCH] Add support for bold headings --- lib/rules.js | 8 ++++++++ test/fixtures/bold-in-heading.mrkdwn | 13 +++++++++++++ test/fixtures/strong-in-heading.mrkdwn | 13 +++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 test/fixtures/bold-in-heading.mrkdwn create mode 100644 test/fixtures/strong-in-heading.mrkdwn diff --git a/lib/rules.js b/lib/rules.js index 00b6d8a..2a37e23 100644 --- a/lib/rules.js +++ b/lib/rules.js @@ -20,6 +20,14 @@ module.exports = { replacement: content => `\n*${content}*\n` }, + strongInHeading: { + filter: function (node) { + return ['STRONG', 'B'].includes(node.nodeName) && + ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(node.parentNode.nodeName) + }, + replacement: content => content + }, + taskListItems: { filter: function (node) { return node.type === 'checkbox' && node.parentNode.nodeName === 'LI' diff --git a/test/fixtures/bold-in-heading.mrkdwn b/test/fixtures/bold-in-heading.mrkdwn new file mode 100644 index 0000000..598cc8f --- /dev/null +++ b/test/fixtures/bold-in-heading.mrkdwn @@ -0,0 +1,13 @@ +

heading 1

+

heading 2

+

heading 3

+

heading 4

+
heading 5
+
heading 6
+==== +*heading 1* +*heading 2* +*heading 3* +*heading 4* +*heading 5* +*heading 6* diff --git a/test/fixtures/strong-in-heading.mrkdwn b/test/fixtures/strong-in-heading.mrkdwn new file mode 100644 index 0000000..8041d6f --- /dev/null +++ b/test/fixtures/strong-in-heading.mrkdwn @@ -0,0 +1,13 @@ +

heading 1

+

heading 2

+

heading 3

+

heading 4

+
heading 5
+
heading 6
+==== +*heading 1* +*heading 2* +*heading 3* +*heading 4* +*heading 5* +*heading 6*