diff --git a/app/assets/javascripts/discourse/lib/to-markdown.js.es6 b/app/assets/javascripts/discourse/lib/to-markdown.js.es6 index 560c065730..9b08fee72f 100644 --- a/app/assets/javascripts/discourse/lib/to-markdown.js.es6 +++ b/app/assets/javascripts/discourse/lib/to-markdown.js.es6 @@ -109,6 +109,12 @@ export class Tag { } decorate(text) { + const parent = this.element.parent; + + if (this.name === "p" && parent && parent.name === "li") { // fix for google docs + this.gap = ""; + } + return `${this.gap}${this.prefix}${text}${this.suffix}${this.gap}`; } }; @@ -400,6 +406,12 @@ export class Tag { return class extends Tag.block(name) { decorate(text) { let smallGap = ""; + const parent = this.element.parent; + + if (parent && parent.name === "ul") { + this.gap = ""; + this.suffix = "\n"; + } if (this.element.filterParentNames(["li"]).length) { this.gap = ""; diff --git a/test/javascripts/lib/to-markdown-test.js.es6 b/test/javascripts/lib/to-markdown-test.js.es6 index 0ab96fa43a..57a437a4a5 100644 --- a/test/javascripts/lib/to-markdown-test.js.es6 +++ b/test/javascripts/lib/to-markdown-test.js.es6 @@ -70,7 +70,7 @@ QUnit.test("converts heading tags", assert => { }); QUnit.test("converts ul list tag", assert => { - const html = ` + let html = `
Bullets at level 1
Bullets at level 1
Bullets at level 2
Bullets at level 2
Bullets at level 3
Bullets at level 2
Bullets at level 1