diff --git a/packages/migrate/test/fixtures/multiple-templates/snapshot-expected.marko b/packages/migrate/test/fixtures/multiple-templates/snapshot-expected.marko index ff7478b2..a582efc0 100644 --- a/packages/migrate/test/fixtures/multiple-templates/snapshot-expected.marko +++ b/packages/migrate/test/fixtures/multiple-templates/snapshot-expected.marko @@ -2,6 +2,7 @@ $ var x = 1; $ x++; + -- ${x} diff --git a/packages/migrate/test/fixtures/single-template/snapshot-expected.marko b/packages/migrate/test/fixtures/single-template/snapshot-expected.marko index 4da9e689..c8e223e7 100644 --- a/packages/migrate/test/fixtures/single-template/snapshot-expected.marko +++ b/packages/migrate/test/fixtures/single-template/snapshot-expected.marko @@ -2,4 +2,5 @@ $ var x = 1; $ x++; + -- ${x} diff --git a/packages/prettyprint/src/printNodes.js b/packages/prettyprint/src/printNodes.js index 335f411e..e7fa469a 100644 --- a/packages/prettyprint/src/printNodes.js +++ b/packages/prettyprint/src/printNodes.js @@ -132,9 +132,22 @@ module.exports = function printNodes(nodes, printContext, inputWriter) { } // Insert line break between certain top-level tags - if (breakAfterTags[prevChild.tagName]) { + if ( + breakAfterTags[prevChild.tagName] && + child.tagName != prevChild.tagName + ) { writer.write(printContext.eol); } + + //Insert line break group of scriptlets + if ( + child.type === "Text" && + child.nextSibling && + (!prevChild.tag && + prevChild.type === "Scriptlet" && + child.nextSibling.type !== "Scriptlet") + ) + writer.write(printContext.eol); } printers.printNode(child, printContext, childWriter); diff --git a/packages/prettyprint/test/autotest/js-block/expected.marko b/packages/prettyprint/test/autotest/js-block/expected.marko index 9fbadf20..f40b81e0 100644 --- a/packages/prettyprint/test/autotest/js-block/expected.marko +++ b/packages/prettyprint/test/autotest/js-block/expected.marko @@ -2,10 +2,12 @@ $ { var name = "Frank"; console.log(`Hello ${name}!`); } +
~~~~~~~ $ { var name = "Frank"; console.log(`Hello ${name}!`); } -div + +div \ No newline at end of file diff --git a/packages/prettyprint/test/autotest/js-line/expected.marko b/packages/prettyprint/test/autotest/js-line/expected.marko index 25ebc409..50577828 100644 --- a/packages/prettyprint/test/autotest/js-line/expected.marko +++ b/packages/prettyprint/test/autotest/js-line/expected.marko @@ -1,5 +1,7 @@ $ console.log("Hello World!"); +
~~~~~~~ $ console.log("Hello World!"); -div + +div \ No newline at end of file diff --git a/packages/prettyprint/test/autotest/static-vars/expected.marko b/packages/prettyprint/test/autotest/static-vars/expected.marko new file mode 100644 index 00000000..07a9d740 --- /dev/null +++ b/packages/prettyprint/test/autotest/static-vars/expected.marko @@ -0,0 +1,27 @@ +static var a = 1; +static var b = 2; +static var c = 1; + +import { foo } from './bar' +import { blah } from './foo' +import { haha } from './blah' + +$ var k = 1; +$ var l = 2; +$ var m = 3; + +
+~~~~~~~ +static var a = 1; +static var b = 2; +static var c = 1; + +import { foo } from './bar' +import { blah } from './foo' +import { haha } from './blah' + +$ var k = 1; +$ var l = 2; +$ var m = 3; + +div \ No newline at end of file diff --git a/packages/prettyprint/test/autotest/static-vars/template.marko b/packages/prettyprint/test/autotest/static-vars/template.marko new file mode 100644 index 00000000..745ee2e6 --- /dev/null +++ b/packages/prettyprint/test/autotest/static-vars/template.marko @@ -0,0 +1,10 @@ +static var a = 1; +static var b = 2; +static var c = 1; +import { foo } from './bar' +import { blah } from './foo' +import { haha } from './blah' +$ var k = 1; +$ var l = 2; +$ var m = 3; +
\ No newline at end of file