File tree Expand file tree Collapse file tree 5 files changed +17
-1
lines changed
Expand file tree Collapse file tree 5 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ export default class Parser {
122122 parseQuantity ( groups . mIngredientQuantity ) ??
123123 this . defaultIngredientAmount ,
124124 units : parseUnits ( groups . mIngredientUnits ) ?? this . defaultUnits ,
125+ ...( groups . mIngredientPreparation ? { preparation : groups . mIngredientPreparation } : null ) ,
125126 } ;
126127
127128 if ( this . includeStepNumber ) ingredient . step = stepNumber ;
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ export default class Recipe {
5555 stepStr += '{' ;
5656 if ( item . quantity ) stepStr += item . quantity ;
5757 if ( 'units' in item && item . units ) stepStr += '%' + item . units ;
58+ if ( 'preparation' in item && item . preparation ) stepStr += `(${ item . preparation } )`
5859 stepStr += '}' ;
5960 }
6061 }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export interface Ingredient {
88 name : string ;
99 quantity : string | number ;
1010 units : string ;
11+ preparation ?: string ;
1112 step ?: number ;
1213}
1314
Original file line number Diff line number Diff line change 11const metadata = / ^ > > \s * (?< key > .+ ?) : \s * (?< value > .+ ) / ;
22
3- const multiwordIngredient = / @ (?< mIngredientName > [ ^ @ # ~ [ ] + ?) \{ (?< mIngredientQuantity > [ ^ ] * ?) (?: % (?< mIngredientUnits > [ ^ } ] + ?) ) ? \} / ;
3+ const multiwordIngredient = / @ (?< mIngredientName > [ ^ @ # ~ [ ] + ?) \{ (?< mIngredientQuantity > [ ^ ] * ?) (?: % (?< mIngredientUnits > [ ^ } ] + ?) ) ? \} ( \( (?< mIngredientPreparation > [ ^ ] * ? ) \) ) ? / ;
44const singleWordIngredient = / @ (?< sIngredientName > [ ^ \s \t \p{ Zs} \p{ P} ] + ) / ;
55
66const multiwordCookware = / # (?< mCookwareName > [ ^ @ # ~ [ ] + ?) \{ (?< mCookwareQuantity > .* ?) \} / ;
Original file line number Diff line number Diff line change @@ -198,3 +198,16 @@ tests:
198198 value : " step"
199199 metadata :
200200 " source " : " example.com"
201+
202+ testShortHandPreparation :
203+ source : |
204+ @onion{1}(peeled and finely chopped)
205+ result :
206+ steps :
207+ -
208+ - type : ingredient
209+ quantity : 1
210+ units : " "
211+ name : " onion"
212+ preparation : " peeled and finely chopped"
213+ metadata : []
You can’t perform that action at this time.
0 commit comments