From 5373007301986335e89bc1262bea86e86bf36671 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 21 May 2019 17:34:18 +0200 Subject: [PATCH] initial attempt at converting html back to markdown --- src/editor/deserialize.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/editor/deserialize.js b/src/editor/deserialize.js index d440f9d336..71fe71d68a 100644 --- a/src/editor/deserialize.js +++ b/src/editor/deserialize.js @@ -40,11 +40,25 @@ function parseHtmlMessage(html, room) { switch (prefix) { case "@": return new UserPillPart(resourceId, n.textContent, room.getMember(resourceId)); case "#": return new RoomPillPart(resourceId); - default: return new PlainPart(n.textContent); + default: { + if (href === n.textContent) { + return new PlainPart(n.textContent); + } else { + return new PlainPart(`[${n.textContent}](${href})`); + } + } } } case "BR": return new NewlinePart("\n"); + case "EM": + return new PlainPart(`*${n.textContent}*`); + case "STRONG": + return new PlainPart(`**${n.textContent}**`); + case "PRE": + return new PlainPart(`\`\`\`${n.textContent}\`\`\``); + case "CODE": + return new PlainPart(`\`${n.textContent}\``); default: return new PlainPart(n.textContent); }