Skip to content

Commit

Permalink
wip - make multiline formatting more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmengo committed Feb 25, 2025
1 parent 6dcdfc3 commit a8298f2
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/prettier-plugin-liquid/src/printer/print/liquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,12 @@ export function printLiquidDocExample(
const parts: Doc[] = ['@example'];

const content = node.content.value;
if (content) {
if (content.includes('\n')) {
parts.push(hardline);
}
parts.push(content.trim());
if (content.trimEnd().includes('\n')) {
parts.push(hardline);
} else {
parts.push(' ');
}
parts.push(content.trim());

return parts;
}
Expand All @@ -582,14 +582,20 @@ export function printLiquidDocDescription(
): Doc {
const node = path.getValue();
const parts: Doc[] = [];
const content = node.content.value;

if (!node.isImplicit) {
parts.push('@description ');
if (node.isImplicit) {
parts.push(content.trim());
return parts;
}

if (node.content?.value) {
parts.push(node.content.value);
parts.push('@description ');
if (content.trimEnd().includes('\n')) {
parts.push(hardline);
} else {
parts.push(' ');
}
parts.push(content.trim());

return parts;
}
Expand Down

0 comments on commit a8298f2

Please sign in to comment.