Add filters for toMarkdown to paste data to compose-box.

This fixes bugs with pasting headings and italic styling.

Fixes #7485.
This commit is contained in:
Garvit
2017-11-28 15:43:33 +05:30
committed by Tim Abbott
parent cb8f2cf484
commit b9826e9067
2 changed files with 26 additions and 1 deletions

View File

@@ -141,7 +141,24 @@ function copy_handler() {
}
exports.paste_handler_converter = function (paste_html) {
var markdown_html = toMarkdown(paste_html);
var converters = {
converters: [
{
filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
replacement: function (content) {
return content;
},
},
{
filter: ['em', 'i'],
replacement: function (content) {
return '*' + content + '*';
},
},
],
};
var markdown_html = toMarkdown(paste_html, converters);
// Now that we've done the main conversion, we want to remove
// any HTML tags that weren't converted to markdown-style