Skip to content

Commit

Permalink
fix(pug): failed to parse multi-line attribute value containing doubl…
Browse files Browse the repository at this point in the history
…e quotes

close vuejs/language-tools#2413
  • Loading branch information
johnsoncodehk committed Apr 22, 2023
1 parent b392da4 commit e6ac648
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/pug/src/baseParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ export function baseParse(pugCode: string) {
if (typeof attrToken.val === 'string' && attrText.indexOf('=') >= 0) {
let valText = attrToken.val;
if (valText.startsWith('`') && valText.endsWith('`')) {
valText = `"${valText.slice(1, -1)}"`;
if (valText.indexOf('"') === -1) {
valText = `"${valText.slice(1, -1)}"`;
}
else {
valText = `'${valText.slice(1, -1)}'`;
}
}
valText = valText.replace(/ \\\n/g, '//\n');
text += attrText.substring(0, attrText.lastIndexOf(attrToken.val)) + valText;
Expand Down

0 comments on commit e6ac648

Please sign in to comment.