@@ -127,7 +127,6 @@ export interface PugPrinterOptions {
127127 readonly pugSemi : boolean ;
128128 readonly bracketSameLine : boolean ;
129129 readonly pugBracketSameLine : boolean ;
130-
131130 readonly pugAttributeSeparator : PugAttributeSeparator ;
132131 readonly pugCommentPreserveSpaces : PugCommentPreserveSpaces ;
133132 readonly pugSortAttributes : PugSortAttributes ;
@@ -144,6 +143,7 @@ export interface PugPrinterOptions {
144143 readonly pugFramework : PugFramework ;
145144 readonly pugExplicitDiv : boolean ;
146145 readonly pugPreserveAttributeBrackets : boolean ;
146+ readonly pugPreserveWhitespace : boolean ;
147147 readonly pugClosingBracketIndentDepth : PugClosingBracketIndentDepth ;
148148}
149149
@@ -1680,7 +1680,7 @@ export class PugPrinter {
16801680 switch ( this . previousToken ?. type ) {
16811681 case 'newline' : {
16821682 result += this . indentString . repeat ( this . indentLevel ) ;
1683- if ( / ^ .+ $ / . test ( val ) ) {
1683+ if ( this . options . pugPreserveWhitespace && / ^ .+ $ / . test ( val ) ) {
16841684 result += '|\n' ;
16851685 result += this . indentString . repeat ( this . indentLevel ) ;
16861686 }
@@ -1699,13 +1699,16 @@ export class PugPrinter {
16991699 case 'indent' :
17001700 case 'outdent' : {
17011701 result += this . computedIndent ;
1702- if ( / ^ .+ $ / . test ( val ) ) {
1702+ if ( this . options . pugPreserveWhitespace && / ^ .+ $ / . test ( val ) ) {
17031703 result += '|\n' ;
17041704 result += this . indentString . repeat ( this . indentLevel ) ;
17051705 }
17061706
17071707 result += '|' ;
1708- if ( / .* \S .* / . test ( token . val ) ) {
1708+ if (
1709+ / .* \S .* / . test ( token . val ) ||
1710+ this . nextToken ?. type === 'start-pug-interpolation'
1711+ ) {
17091712 result += ' ' ;
17101713 }
17111714
@@ -2046,6 +2049,7 @@ export class PugPrinter {
20462049 ) : string {
20472050 let result : string = '' ;
20482051 if (
2052+ this . pipelessText &&
20492053 this . tokens [ this . currentIndex - 2 ] ?. type === 'newline' &&
20502054 this . previousToken ?. type === 'text' &&
20512055 this . previousToken . val . trim ( ) . length === 0
0 commit comments