From 5b54cf566de3e38d5d2c7d43b9d667aa0ff6d483 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 2 Sep 2019 16:23:56 +0200 Subject: [PATCH] deserialize headers from html back to markdown --- src/editor/deserialize.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/editor/deserialize.js b/src/editor/deserialize.js index d59e4ca123..08c66f592a 100644 --- a/src/editor/deserialize.js +++ b/src/editor/deserialize.js @@ -71,8 +71,20 @@ function parseCodeBlock(n, partCreator) { return parts; } +function parseHeader(el, partCreator) { + const depth = parseInt(el.nodeName.substr(1), 10); + return partCreator.plain("#".repeat(depth) + " "); +} + function parseElement(n, partCreator, state) { switch (n.nodeName) { + case "H1": + case "H2": + case "H3": + case "H4": + case "H5": + case "H6": + return parseHeader(n, partCreator); case "A": return parseLink(n, partCreator); case "BR":