diff --git a/src/language-markdown/printer-markdown.js b/src/language-markdown/printer-markdown.js index 856bbcd8e..27043431f 100644 --- a/src/language-markdown/printer-markdown.js +++ b/src/language-markdown/printer-markdown.js @@ -705,9 +705,20 @@ function shouldPrePrintDoubleHardline(node, data) { const isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next"; + const isBlockHtmlWithoutBlankLineBetweenPrevHtml = + node.type === "html" && + data.prevNode && + data.prevNode.type === "html" && + data.prevNode.position.end.line + 1 === node.position.start.line; + return ( isPrevNodeLooseListItem || - !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore) + !( + isSiblingNode || + isInTightListItem || + isPrevNodePrettierIgnore || + isBlockHtmlWithoutBlankLineBetweenPrevHtml + ) ); } diff --git a/tests/markdown_html/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_html/__snapshots__/jsfmt.spec.js.snap index 9b031dee3..ae384f68d 100644 --- a/tests/markdown_html/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_html/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`blank-line-between-htmls.md 1`] = ` + +

labelify

+ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +

labelify

+ + +`; + exports[`multiline.md 1`] = ` 1. Some test text, the goal is to have the html table below nested within this number. When formating on save Prettier will continue to add an indent each time pushing the table further and further out of sync. diff --git a/tests/markdown_html/blank-line-between-htmls.md b/tests/markdown_html/blank-line-between-htmls.md new file mode 100644 index 000000000..5b7acd3ea --- /dev/null +++ b/tests/markdown_html/blank-line-between-htmls.md @@ -0,0 +1,3 @@ + +

labelify

+ diff --git a/tests/markdown_ignore/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_ignore/__snapshots__/jsfmt.spec.js.snap index 935c8d015..0665c3c04 100644 --- a/tests/markdown_ignore/__snapshots__/jsfmt.spec.js.snap +++ b/tests/markdown_ignore/__snapshots__/jsfmt.spec.js.snap @@ -63,7 +63,6 @@ exports[`top-level-range.md 1`] = ` > -> > > > | some | table | @@ -72,7 +71,6 @@ exports[`top-level-range.md 1`] = ` > | 2 | b | > > -> > `;