fix(renderer): show ingredient quantities in print/export html output #20
3 changed files with 18 additions and 14 deletions
5
.changeset/quantities-print-export.md
Normal file
5
.changeset/quantities-print-export.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"@gram-lang/renderer": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
**CLI / Export**: Fixed `gram print` and `gram export --format html` no longer showing ingredient quantities in the shopping list and section ingredient lists.
|
||||||
|
|
@ -479,11 +479,11 @@ const printBackend: RenderBackend = {
|
||||||
for (const group of renderGroups) {
|
for (const group of renderGroups) {
|
||||||
const item = group[0];
|
const item = group[0];
|
||||||
if (isAlternativeGroup(item)) {
|
if (isAlternativeGroup(item)) {
|
||||||
body += ` <li>${item.options.map((o: any) => formatElement(o, "html", context)).join(" <em>or</em> ")}</li>\n`;
|
body += ` <li>${item.options.map((o: any) => formatElement(o, "html", { ...context, formatMode: "shopping-list" })).join(" <em>or</em> ")}</li>\n`;
|
||||||
} else if (isCompositeItem(item)) {
|
} else if (isCompositeItem(item)) {
|
||||||
body += ` <li>${formatElement(item, "html", context)}</li>\n`;
|
body += ` <li>${formatElement(item, "html", { ...context, formatMode: "shopping-list" })}</li>\n`;
|
||||||
for (const u of item.usage ?? []) {
|
for (const u of item.usage ?? []) {
|
||||||
body += ` <li style="padding-left:12pt">${formatElement(u, "html", context)}</li>\n`;
|
body += ` <li style="padding-left:12pt">${formatElement(u, "html", { ...context, formatMode: "shopping-list" })}</li>\n`;
|
||||||
}
|
}
|
||||||
} else if (item.display) {
|
} else if (item.display) {
|
||||||
body += ` <li>${escapeHtml(item.display)}</li>\n`;
|
body += ` <li>${escapeHtml(item.display)}</li>\n`;
|
||||||
|
|
@ -492,7 +492,7 @@ const printBackend: RenderBackend = {
|
||||||
body += ` <strong>${escapeHtml(item.name || item.id)}</strong> <span class="mixed-units-badge">${escapeHtml(t.renderer.mixedUnits)}</span>\n`;
|
body += ` <strong>${escapeHtml(item.name || item.id)}</strong> <span class="mixed-units-badge">${escapeHtml(t.renderer.mixedUnits)}</span>\n`;
|
||||||
body += ` <ul>\n`;
|
body += ` <ul>\n`;
|
||||||
group.forEach((entry) => {
|
group.forEach((entry) => {
|
||||||
body += ` <li>${formatElement(entry, "html", context)}</li>\n`;
|
body += ` <li>${formatElement(entry, "html", { ...context, formatMode: "shopping-list" })}</li>\n`;
|
||||||
});
|
});
|
||||||
body += ` </ul>\n`;
|
body += ` </ul>\n`;
|
||||||
body += ` </li>\n`;
|
body += ` </li>\n`;
|
||||||
|
|
@ -505,7 +505,7 @@ const printBackend: RenderBackend = {
|
||||||
const gross = round1(item.purchasingMass);
|
const gross = round1(item.purchasingMass);
|
||||||
extra = ` <span class="gross-mass">${gross}g ${escapeHtml(t.renderer.gross)}</span>`;
|
extra = ` <span class="gross-mass">${gross}g ${escapeHtml(t.renderer.gross)}</span>`;
|
||||||
}
|
}
|
||||||
body += ` <li>${formatElement(item, "html", context)}${extra}</li>\n`;
|
body += ` <li>${formatElement(item, "html", { ...context, formatMode: "shopping-list" })}${extra}</li>\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
body += `</ul>\n</div>\n\n`;
|
body += `</ul>\n</div>\n\n`;
|
||||||
|
|
@ -557,7 +557,7 @@ const printBackend: RenderBackend = {
|
||||||
if (secItems.length > 0) {
|
if (secItems.length > 0) {
|
||||||
body += ` <div class="section-ingredients"><ul>\n`;
|
body += ` <div class="section-ingredients"><ul>\n`;
|
||||||
for (const ing of secItems) {
|
for (const ing of secItems) {
|
||||||
body += ` <li>${formatElement(ing, "html", context)}</li>\n`;
|
body += ` <li>${formatElement(ing, "html", { ...context, formatMode: "mise-en-place" })}</li>\n`;
|
||||||
}
|
}
|
||||||
body += ` </ul></div>\n`;
|
body += ` </ul></div>\n`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -581,10 +581,10 @@ exports[`renderer output snapshots toPrintHTML output is stable 1`] = `
|
||||||
<div class="shopping-list">
|
<div class="shopping-list">
|
||||||
<h2>Shopping List</h2>
|
<h2>Shopping List</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><span class="ingredient" data-name="flour" data-tooltip="200 g">flour</span></li>
|
<li><span class="ingredient" data-name="flour">flour <span class="quantity">200 g</span></span></li>
|
||||||
<li><span class="ingredient" data-name="sugar" data-tooltip="1 tbsp">sugar</span></li>
|
<li><span class="ingredient" data-name="sugar">sugar <span class="quantity">1 tbsp</span></span></li>
|
||||||
<li><span class="ingredient" data-name="salt">salt</span></li>
|
<li><span class="ingredient" data-name="salt">salt</span></li>
|
||||||
<li><span class="ingredient" data-name="egg" data-tooltip="2">egg</span> <em>or</em> <span class="ingredient" data-name="egg substitute" data-tooltip="2">egg substitute</span></li>
|
<li><span class="ingredient" data-name="egg">egg <span class="quantity">2</span></span> <em>or</em> <span class="ingredient" data-name="egg substitute">egg substitute <span class="quantity">2</span></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -601,11 +601,10 @@ exports[`renderer output snapshots toPrintHTML output is stable 1`] = `
|
||||||
<section>
|
<section>
|
||||||
<h3>Batter</h3>
|
<h3>Batter</h3>
|
||||||
<div class="section-ingredients"><ul>
|
<div class="section-ingredients"><ul>
|
||||||
<li><span class="ingredient" data-name="flour" data-tooltip="200 g">flour</span></li>
|
<li><span class="ingredient" data-name="flour">flour <span class="quantity">200 g</span></span></li>
|
||||||
<li><span class="ingredient" data-name="sugar" data-tooltip="1 tbsp">sugar</span></li>
|
<li><span class="ingredient" data-name="sugar">sugar <span class="quantity">1 tbsp</span></span></li>
|
||||||
<li><span class="ingredient" data-name="salt">salt</span></li>
|
<li><span class="ingredient" data-name="salt">salt</span></li>
|
||||||
<li><span class="ingredient" data-name="egg" data-tooltip="2">egg</span> <span class="ingredient-alt-badge" data-tooltip="Alternatives:
|
<li><span class="alt-group"><span class="ingredient" data-name="egg">egg <span class="quantity">2</span></span> <span class="keyword">or</span> <span class="ingredient" data-name="egg substitute">egg substitute <span class="quantity">2</span></span></span></li>
|
||||||
egg-substitute">(alt)</span></li>
|
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<ol class="steps">
|
<ol class="steps">
|
||||||
<li value="1">
|
<li value="1">
|
||||||
|
|
@ -624,7 +623,7 @@ egg-substitute">(alt)</span> and whisk for <span class="timer" data-tooltip="Act
|
||||||
<section>
|
<section>
|
||||||
<h3>Cooking</h3>
|
<h3>Cooking</h3>
|
||||||
<div class="section-ingredients"><ul>
|
<div class="section-ingredients"><ul>
|
||||||
<li><span class="reference" data-tooltip="Intermediate Ingredient">→ batter</span></li>
|
<li><span class="reference">→ batter</span></li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<ol class="steps">
|
<ol class="steps">
|
||||||
<li value="1">
|
<li value="1">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue