diff --git a/docs/source/Recipes/Breads/Pastry_RoughPuff.rst b/docs/source/Recipes/Breads/Pastry_RoughPuff.rst index a3dc75c..8669ef5 100644 --- a/docs/source/Recipes/Breads/Pastry_RoughPuff.rst +++ b/docs/source/Recipes/Breads/Pastry_RoughPuff.rst @@ -4,15 +4,17 @@ Rough Puff Pastry ================= +.. multiply:: + .. makes:: - 2 pie crusts or a top and a bottom. + :amnt:`2` pie crusts or :amnt:`1` top and bottom. .. ingredients:: - - 150 g water, cold from the fridge, plus some extra in a different container - - 300 g butter, cut in 1.5cm cubes, just about defrosted - - 450 g AP flour, also fridge temperature - - 5 g salt + - :amnt:`150 g` water, cold from the fridge, plus some extra in a different container + - :amnt:`300 g` butter, cut in 1.5cm cubes, just about defrosted + - :amnt:`450 g` AP flour, also fridge temperature + - :amnt:`5 g` salt .. tools:: @@ -27,7 +29,7 @@ Rough Puff Pastry Squeeze the butter cubes between your fingers to flatten them down. If they are too solid, wait a little bit and try again... - Drizzle the 150 g of water over the mixture and gently incorporate with your fingers, do not knead. + Drizzle the :amnt:`150 g` of water over the mixture and gently incorporate with your fingers, do not knead. Once incorporated, invert the bowl onto the working surface. It should be very shaggy and dry, with lots of dry flour hanging around. Gather the "dough" into a rough square and start rolling. The goal is to flatten the butter even more into very thin sheets. Use the bench scraper to fold the "dough" onto itself (it is still expected for it to not fully hold together here) diff --git a/docs/source/_static/script.js b/docs/source/_static/script.js new file mode 100644 index 0000000..7d36f8a --- /dev/null +++ b/docs/source/_static/script.js @@ -0,0 +1,64 @@ +function storeAndParseOriginal(section, match, parseFunction) { + if (!section.dataset.original) { + section.dataset.original = parseFunction(match); // Store the original value + } + return section.dataset.original +} +function multiplyAndFormatResult(val, multiplier) { + const result = val * multiplier; + return Number.isInteger(result) ? result : result.toFixed(2); +} + +document.addEventListener('DOMContentLoaded', () => { + const multiplyButton = document.getElementById('multiply-btn'); + const resetButton = document.getElementById('reset-btn'); + + multiplyButton.addEventListener('click', () => { + const multiplier = parseFloat(document.getElementById('multiplier').value); + if (isNaN(multiplier)) { + alert('Please enter a valid multiplier'); + return; + } + + const amounts = document.querySelectorAll('.amnt'); // Select all elements with the class 'amnt' + amounts.forEach((section) => { + let text = section.innerHTML; + if (!section.dataset.originalText) { + section.dataset.originalText = text; // Store the original text + } + // Handle mixed fractions + if (/\b\d+\s+\d+\/\d+/.test(text)) { + text = text.replace(/\b(\d+)\s+(\d+)\/(\d+)/g, (_, whole, num, den) => { + const result = storeAndParseOriginal(section, {whole, num, den}, (val) => parseFloat(val.whole) + val.num / val.den); + return multiplyAndFormatResult(result, multiplier); + }); + } + // Handle fractions + else if (/\b\d+\/\d+/.test(text)) { + text = text.replace(/\b(\d+)\/(\d+)/g, (_, num, den) => { + const result = storeAndParseOriginal(section, {num, den}, (val) => val.num / val.den); + return multiplyAndFormatResult(result, multiplier); + }); + } + // Handle whole numbers and decimals + else if (/\b\d+(\.\d+)?/.test(text)) { + text = text.replace(/\b\d+(\.\d+)?/g, (match) => { + const result = storeAndParseOriginal(section, match, (val) => parseFloat(val)); + return multiplyAndFormatResult(result, multiplier) + }); + } + // Update the HTML with the modified text + section.innerHTML = text; + }); + }); + + resetButton.addEventListener('click', () => { + const amounts = document.querySelectorAll('.amnt'); // Select all elements with the class 'amnt' + amounts.forEach((section) => { + if (section.dataset.originalText) { + section.innerHTML = section.dataset.originalText; + return section.dataset.original; + } + }); + }); +}); \ No newline at end of file diff --git a/docs/source/_static/styles.css b/docs/source/_static/styles.css index e2d05f1..a51faf3 100644 --- a/docs/source/_static/styles.css +++ b/docs/source/_static/styles.css @@ -110,3 +110,76 @@ footer a{ background-color: white !important; font-weight: normal !important; } + +.button { + align-items: center; + appearance: none; + background-color: #fff; + border: 1px solid #dbdbdb; + border-radius: .375em; + box-shadow: none; + box-sizing: border-box; + color: #363636; + cursor: pointer; + display: inline-flex; + justify-content: center; + padding: calc(.5em - 1px) 1em; + position: relative; + text-align: center; + user-select: none; + -webkit-user-select: none; + touch-action: manipulation; + vertical-align: center; + white-space: nowrap; +} + +.button:active { + border-color: #4a4a4a; + outline: 0; +} + +.button:focus { + border-color: #485fc7; + outline: 0; +} + +.button:hover { + border-color: #b5b5b5; +} + +.button:focus:not(:active) { + box-shadow: rgba(72, 95, 199, .25) 0 0 0 .125em; +} + +input[type=number] { + appearance: none; + background-color: #fff; + border: 1px solid #dbdbdb; + border-radius: .375em; + box-shadow: none; + padding:5px; + -webkit-border-radius: 5px; + border-radius: 5px; + width: 4em; + max-width: 8em; + vertical-align: center; +} + +input[type=number]:focus { + border-color: #485fc7; + outline: 0; +} + +input[type=number]:focus { + border-color: #4a4a4a; + outline: 0; +} + +input[type=submit] { + padding:5px 15px; + background:#ccc; + border:0 none; + cursor:pointer; + -webkit-border-radius: 5px; + border-radius: 5px; +} diff --git a/docs/source/_templates/layout.html b/docs/source/_templates/layout.html new file mode 100644 index 0000000..ea08c86 --- /dev/null +++ b/docs/source/_templates/layout.html @@ -0,0 +1,10 @@ +{% extends "!layout.html" %} +