Merge pull request #3379 from matrix-org/bwindels/cider-deserialize-headers

Message editing: deserialize headers from html back to markdown
This commit is contained in:
Bruno Windels 2019-09-02 14:58:54 +00:00 committed by GitHub
commit 6a0842d1ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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":