From 1496d8a7bcc7840d6d71f0e60e22623f6a2ac5e0 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 16 Nov 2020 22:15:05 -0800 Subject: [PATCH] feat: add support for strike and u tags --- lib/converters.js | 4 ++++ test/index.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/converters.js b/lib/converters.js index b85453b..0e8c0e2 100644 --- a/lib/converters.js +++ b/lib/converters.js @@ -30,6 +30,8 @@ let parseTextFormat = text => { let formats = { strong: "**" , italic: "*" + , underline: "_" + , strikethrough: "~~" } return text @@ -37,6 +39,8 @@ let parseTextFormat = text => { .replace(/<\/?bold\>/gi, formats.strong) .replace(/<\/?em\>/gi, formats.italic) .replace(/<\/?italic\>/gi, formats.italic) + .replace(/<\/?u\>/gi, formats.underline) + .replace(/<\/?strike\>/gi, formats.strikethrough) } diff --git a/test/index.js b/test/index.js index 6dfcbac..47074e5 100644 --- a/test/index.js +++ b/test/index.js @@ -121,6 +121,24 @@ tester.describe("json2md", test => { cb(); }); + test.it("should support paragraphs with underline", function(cb) { + test.expect(json2md({ + p: [ + "Two more words", "in this paragraph, right?" + ] + })).toBe("\nTwo _more words_\n\nin this paragraph, _right?_\n"); + cb(); + }); + + test.it("should support paragraphs with strikethrough", function(cb) { + test.expect(json2md({ + p: [ + "Two more words", "in this paragraph, right?" + ] + })).toBe("\nTwo ~~more words~~\n\nin this paragraph, ~~right?~~\n"); + cb(); + }); + // Custom converters test.it("should support custom types", function(cb) { json2md.converters.sayHello = function(input, json2md) {