Compare commits
No commits in common. "edd4e01c8d7b530593ebbf19f6c963c87abfac37" and "f5009d09bb948999a948564c876c92acb0a6d5fc" have entirely different histories.
edd4e01c8d
...
f5009d09bb
12 changed files with 11 additions and 78 deletions
|
|
@ -16,10 +16,8 @@
|
||||||
const NUM = '\\d+(?:\\.\\d+)?';
|
const NUM = '\\d+(?:\\.\\d+)?';
|
||||||
const FRAC = '\\d+\\s*/\\s*\\d+';
|
const FRAC = '\\d+\\s*/\\s*\\d+';
|
||||||
const MIXED = '\\d+\\s+\\d+\\s*/\\s*\\d+';
|
const MIXED = '\\d+\\s+\\d+\\s*/\\s*\\d+';
|
||||||
const UNICODE_FRAC = '[\u00BC-\u00BE\u2150-\u215E]';
|
|
||||||
const MIXED_UNI = `\\d+\\s*${UNICODE_FRAC}`;
|
|
||||||
const APPROX_PREFIX = '~\\s*';
|
const APPROX_PREFIX = '~\\s*';
|
||||||
const SINGLE_AMOUNT = `(?:${APPROX_PREFIX})?(?:${MIXED}|${FRAC}|${MIXED_UNI}|${UNICODE_FRAC}|${NUM})`;
|
const SINGLE_AMOUNT = `(?:${APPROX_PREFIX})?(?:${MIXED}|${FRAC}|${NUM})`;
|
||||||
const RANGE_SEP = '\\s*(?:-|to)\\s*';
|
const RANGE_SEP = '\\s*(?:-|to)\\s*';
|
||||||
const AMOUNT = `(?:${SINGLE_AMOUNT}${RANGE_SEP}${SINGLE_AMOUNT}|${SINGLE_AMOUNT})`;
|
const AMOUNT = `(?:${SINGLE_AMOUNT}${RANGE_SEP}${SINGLE_AMOUNT}|${SINGLE_AMOUNT})`;
|
||||||
|
|
||||||
|
|
@ -41,27 +39,6 @@ const DIM_UNIT = '(?:inch(?:es)?|in\\.?|cm|mm)';
|
||||||
* @param {string} str — e.g. "200", "1.5", "1/2", "1 1/2", "~250"
|
* @param {string} str — e.g. "200", "1.5", "1/2", "1 1/2", "~250"
|
||||||
* @returns {{ value: number, approximate: boolean }}
|
* @returns {{ value: number, approximate: boolean }}
|
||||||
*/
|
*/
|
||||||
const UNICODE_FRAC_MAP = {
|
|
||||||
'\u00BC': 0.25, // ¼
|
|
||||||
'\u00BD': 0.5, // ½
|
|
||||||
'\u00BE': 0.75, // ¾
|
|
||||||
'\u2150': 1/7, // ⅐
|
|
||||||
'\u2151': 1/9, // ⅑
|
|
||||||
'\u2152': 1/10, // ⅒
|
|
||||||
'\u2153': 1/3, // ⅓
|
|
||||||
'\u2154': 2/3, // ⅔
|
|
||||||
'\u2155': 0.2, // ⅕
|
|
||||||
'\u2156': 0.4, // ⅖
|
|
||||||
'\u2157': 0.6, // ⅗
|
|
||||||
'\u2158': 0.8, // ⅘
|
|
||||||
'\u2159': 1/6, // ⅙
|
|
||||||
'\u215A': 5/6, // ⅚
|
|
||||||
'\u215B': 0.125, // ⅛
|
|
||||||
'\u215C': 0.375, // ⅜
|
|
||||||
'\u215D': 0.625, // ⅝
|
|
||||||
'\u215E': 0.875, // ⅞
|
|
||||||
};
|
|
||||||
|
|
||||||
function parseSingleAmount(str) {
|
function parseSingleAmount(str) {
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
const approximate = str.startsWith('~');
|
const approximate = str.startsWith('~');
|
||||||
|
|
@ -69,20 +46,6 @@ function parseSingleAmount(str) {
|
||||||
str = str.replace(/^~\s*/, '');
|
str = str.replace(/^~\s*/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unicode mixed number: "1½", "1 ½"
|
|
||||||
const uniMixedMatch = str.match(/^(\d+)\s*([\u00BC-\u00BE\u2150-\u215E])$/);
|
|
||||||
if (uniMixedMatch) {
|
|
||||||
const whole = parseInt(uniMixedMatch[1], 10);
|
|
||||||
const frac = UNICODE_FRAC_MAP[uniMixedMatch[2]] || 0;
|
|
||||||
return { value: whole + frac, approximate };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Standalone Unicode fraction: "½", "¾"
|
|
||||||
const uniFracMatch = str.match(/^([\u00BC-\u00BE\u2150-\u215E])$/);
|
|
||||||
if (uniFracMatch) {
|
|
||||||
return { value: UNICODE_FRAC_MAP[uniFracMatch[1]] || 0, approximate };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mixed number: "1 1/2"
|
// Mixed number: "1 1/2"
|
||||||
const mixedMatch = str.match(/^(\d+)\s+(\d+)\s*\/\s*(\d+)$/);
|
const mixedMatch = str.match(/^(\d+)\s+(\d+)\s*\/\s*(\d+)$/);
|
||||||
if (mixedMatch) {
|
if (mixedMatch) {
|
||||||
|
|
@ -336,33 +299,6 @@ function findDimensions(text) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Standalone AMOUNT + dimension unit (e.g. "1 inch", "0.5-1cm")
|
|
||||||
const standaloneDimRe = new RegExp(
|
|
||||||
`(${AMOUNT})\\s*(${DIM_UNIT})\\b`,
|
|
||||||
'gi'
|
|
||||||
);
|
|
||||||
|
|
||||||
while ((m = standaloneDimRe.exec(text)) !== null) {
|
|
||||||
// Skip if overlapping with an NxN match already found
|
|
||||||
const alreadyMatched = results.some(
|
|
||||||
r => m.index >= r.index && m.index < r.index + r.match.length
|
|
||||||
);
|
|
||||||
if (alreadyMatched) continue;
|
|
||||||
|
|
||||||
const amount = parseAmount(m[1]);
|
|
||||||
const unit = normalizeUnit(m[2]);
|
|
||||||
|
|
||||||
results.push({
|
|
||||||
match: m[0],
|
|
||||||
index: m.index,
|
|
||||||
type: 'dimension',
|
|
||||||
amount,
|
|
||||||
unit,
|
|
||||||
approximate: typeof amount.approximate === 'boolean' ? amount.approximate : false,
|
|
||||||
alt: null,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ makes: 1 martini glass
|
||||||
- [ ] ice
|
- [ ] ice
|
||||||
## Tools
|
## Tools
|
||||||
- shaker
|
- shaker
|
||||||
- martini glass 1
|
- martini glass
|
||||||
## Steps
|
## Steps
|
||||||
- pour all ingredients in the shaker
|
- pour all ingredients in the shaker
|
||||||
- shake well[^1]
|
- shake well[^1]
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ makes: 1 martini glass
|
||||||
- Bar spoon
|
- Bar spoon
|
||||||
- Strainer
|
- Strainer
|
||||||
- Jigger
|
- Jigger
|
||||||
- Martini glass 1
|
- Martini glass
|
||||||
## Steps
|
## Steps
|
||||||
- Chill martini glass (with ice water or in freezer)
|
- Chill martini glass (with ice water or in freezer)
|
||||||
- Add vodka, triple sec, dry vermouth, cranberry juice, and cranberry bitters to mixing glass
|
- Add vodka, triple sec, dry vermouth, cranberry juice, and cranberry bitters to mixing glass
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ makes: 1 highball glass
|
||||||
- [ ] ginger beer 120 g
|
- [ ] ginger beer 120 g
|
||||||
- [ ] ice
|
- [ ] ice
|
||||||
## Tools
|
## Tools
|
||||||
- highball 1
|
- highball
|
||||||
## Steps
|
## Steps
|
||||||
- add rum, ginger beer, and ice to glass
|
- add rum, ginger beer, and ice to glass
|
||||||
- serve
|
- serve
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ makes: 1 martini glass
|
||||||
- [ ] ice
|
- [ ] ice
|
||||||
## Tools
|
## Tools
|
||||||
- shaker
|
- shaker
|
||||||
- martini glass 1
|
- martini glass
|
||||||
## Steps
|
## Steps
|
||||||
- put all ingredients in shaker
|
- put all ingredients in shaker
|
||||||
- shake well
|
- shake well
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ makes: 1 martini glass
|
||||||
- [ ] ice
|
- [ ] ice
|
||||||
## Tools
|
## Tools
|
||||||
- shaker
|
- shaker
|
||||||
- martini glass 1
|
- martini glass
|
||||||
## Steps
|
## Steps
|
||||||
- pour all ingredients into the shaker
|
- pour all ingredients into the shaker
|
||||||
- shake well[^1]
|
- shake well[^1]
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@ makes: 1 highball glass
|
||||||
- [ ] simple syrup 20g
|
- [ ] simple syrup 20g
|
||||||
- [ ] coca-cola 90g
|
- [ ] coca-cola 90g
|
||||||
- [ ] ice
|
- [ ] ice
|
||||||
## Tools
|
|
||||||
- highball 1
|
|
||||||
- stir stick
|
|
||||||
## Steps
|
## Steps
|
||||||
- pour all ingredients over ice
|
- pour all ingredients over ice
|
||||||
- stir[^1]
|
- stir[^1]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ makes: 1 copper mug
|
||||||
- [ ] ginger beer 220g
|
- [ ] ginger beer 220g
|
||||||
- [ ] ice
|
- [ ] ice
|
||||||
## Tools
|
## Tools
|
||||||
- mule glass 1
|
- mule glasses
|
||||||
- stir stick
|
- stir stick
|
||||||
## Steps
|
## Steps
|
||||||
- add all ingredients to glass and stir before serving
|
- add all ingredients to glass and stir before serving
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ makes: 1 martini glass
|
||||||
- [ ] ice
|
- [ ] ice
|
||||||
## Tools
|
## Tools
|
||||||
- cocktail shaker
|
- cocktail shaker
|
||||||
- martini glass 1
|
- martini glass
|
||||||
## Steps
|
## Steps
|
||||||
- add all ingredients to shaker
|
- add all ingredients to shaker
|
||||||
- shake well
|
- shake well
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ makes: 1 9x13 pan or 4 large rectangular pyrex containers
|
||||||
## Tools
|
## Tools
|
||||||
- pan
|
- pan
|
||||||
- mixing bowl
|
- mixing bowl
|
||||||
- 9 x 13 inch glass baking dish 1 / 8x6x2 inch pyrex dishes 4
|
- 9 x 13 inch glass baking dish/4 8x6x2 inch pyrex dishes
|
||||||
## Steps
|
## Steps
|
||||||
- preheat oven to 350 °F
|
- preheat oven to 350 °F
|
||||||
- dice onion
|
- dice onion
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ makes: 1 highball glass
|
||||||
- [ ] grenadine 15 g
|
- [ ] grenadine 15 g
|
||||||
- [ ] ice
|
- [ ] ice
|
||||||
## Tools
|
## Tools
|
||||||
- lowball 1
|
- lowball
|
||||||
- stir stick
|
- stir stick
|
||||||
## Steps
|
## Steps
|
||||||
- pour tequila and orange juice into the glass
|
- pour tequila and orange juice into the glass
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ makes: 1 mug
|
||||||
- [ ] spiced rum 25g
|
- [ ] spiced rum 25g
|
||||||
- [ ] milk 240g
|
- [ ] milk 240g
|
||||||
## Tools
|
## Tools
|
||||||
- mug 1
|
- mug
|
||||||
## Steps
|
## Steps
|
||||||
- warm up cup of milk
|
- warm up cup of milk
|
||||||
- mix in tom and jerry mix
|
- mix in tom and jerry mix
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue