diff --git a/prestart.js b/prestart.js index 14e2b9b..77b8367 100644 --- a/prestart.js +++ b/prestart.js @@ -126,6 +126,31 @@ function convertRecipeMarkdown(inputDir, outputDir) { console.error(err); return; } + + var ingredientTableRegex = new RegExp(`^(.*?)\\|(.*?)(\\|.*?\\|.*?)\n`, `gm`); + var ingredientDashCheck = new RegExp("^\-+$"); + ingredientTableMatcher = ingredientTableRegex.exec(data); + while (ingredientTableMatcher != null) { + meas = ingredientTableMatcher[1]; + let unit = ingredientTableMatcher[2].toLowerCase().trim(); + if (unit != "unit" && unit && !ingredientDashCheck.test(unit)) { + meas += unit + " "; + } + data = data.replace(ingredientTableMatcher[0], `${meas}${ingredientTableMatcher[3]}\n`); + ingredientTableMatcher = ingredientTableRegex.exec(data); + } + ingredientTableRegex = new RegExp(`^(.*?)\\|(.*?)(\\|.*?\\|.*?)\n`, `gm`); + ingredientTableMatcher = ingredientTableRegex.exec(data); + while (ingredientTableMatcher != null) { + meas = ingredientTableMatcher[1]; + let unit = ingredientTableMatcher[2].toLowerCase().trim(); + if (unit != "unit" && unit && !ingredientDashCheck.test(unit)) { + meas += unit + " "; + } + data = data.replace(ingredientTableMatcher[0], `${meas}${ingredientTableMatcher[3]}\n`); + ingredientTableMatcher = ingredientTableRegex.exec(data); + } + let tokens = md.parse(data) let sections = [] diff --git a/recipes/bananaBread.md b/recipes/bananaBread.md index cf1672c..5b1edb2 100644 --- a/recipes/bananaBread.md +++ b/recipes/bananaBread.md @@ -4,19 +4,19 @@ ## Ingredients -Measure | Weight | Ingredient ---------|--------|----------- -1/4 c | | Cinnamon-Sugar -3 c | | Sugar -3 | | Egg -6 | | Mashed Ripe Banana -3/4 c | | Butter -16 oz | | Sour Cream -2 tsp | | Vanilla -2 tsp | | Cinnamon -1/2 tsp | | Salt -3 tsp | | Baking Soda -4 1/2 c | | Flour +Measure | Unit | Weight | Ingredient +--------|------|--------|----------- +1/4 | c | | Cinnamon-Sugar +3 | c | | Sugar +3 | | | Eggs +6 | | | Banana +3/4 | c | | Butter +16 | oz | | Sour Cream +2 | tsp | | Vanilla +2 | tsp | | Cinnamon +1/2 | tsp | | Salt +3 | tsp | | Baking Soda +4 1/2 | c | | Flour ## Instructions diff --git a/recipes/chocolateChipCookies.md b/recipes/chocolateChipCookies.md index 8b87024..ff165ec 100644 --- a/recipes/chocolateChipCookies.md +++ b/recipes/chocolateChipCookies.md @@ -8,20 +8,20 @@ ## Ingredients -Measure | Weight | Ingredient ---------|--------|----------- -1c | | Unsalted Butter -1 1/4c | 290g | Brown Sugar -1/4c | 60g | Sugar -1 | | Egg -1 | | Egg Yolk -2 tbsp | | Whole Milk -1 1/2 tsp | | Vanilla -2 3/4c | 370g | Flour -1 tsp | 7g | Baking Soda -1 tsp | 7g | Salt -1/4 tsp | 1g | Cinnamon -2c | | Chocolate Chip +Measure | Unit | Weight | Ingredient +--------|------|--------|----------- +1 | c | | Unsalted Butter +1 1/4 | c | 290g | Brown Sugar +1/4 | c | 60g | Sugar +1 | | | Egg +1 | | | Egg Yolk +2 | tbsp | | Whole Milk +1 1/2 | tsp | | Vanilla +2 3/4 | c | 370g | Flour +1 | tsp | 7g | Baking Soda +1 | tsp | 7g | Salt +1/4 | tsp | 1g | Cinnamon +2 | c | | Chocolate Chip ## Instructions diff --git a/recipes/cinnamonRolls.md b/recipes/cinnamonRolls.md index 1c283a9..502617f 100644 --- a/recipes/cinnamonRolls.md +++ b/recipes/cinnamonRolls.md @@ -6,22 +6,22 @@ ## Ingredients -Measure | Weight | Ingredient ---------|--------|----------- -4 3/4 c | | Flour -1 1/2 tsp | | Salt -1/3 c | | Sugar -1/3 c | | Oil -2 | | Beaten Eggs -1 1/4c | | Warm water (110F) -2 tbsp | | Yeast -4 tbsp | | Melted Butter -1/2 c | | Cinnamon Sugar +Measure | Unit | Weight | Ingredient +--------|------|--------|----------- +4 3/4 | c | | Flour +1 1/2 | tsp | | Salt +1/3 | c | | Sugar +1/3 | c | | Oil +2 | | | Eggs +1 1/4 | c | | Warm water (110F) +2 | tbsp | | Yeast +4 | tbsp | | Melted Butter +1/2 | c | | Cinnamon Sugar ## Instructions -1. Mix sugar, water and yeast. Let bloom 5m. Add oil, egg, salt, 2c flour. Mix well +1. Mix sugar, water and yeast. Let bloom 5m. Beat Eggs. Add oil, egg, salt, 2c flour. Mix well 2. Add the rest of the flour until you have a stiff dough. Hand knead 5min. Let rise 15m 3. Roll out into rectangular shape on floured surface. Brush with butter, sprinkle with cinnamon sugar 4. Roll up dough and cut in 1-1/2” slices. Place in rectangular pan and press. diff --git a/recipes/drunkBananas.md b/recipes/drunkBananas.md index 13bfddc..a96f0e8 100644 --- a/recipes/drunkBananas.md +++ b/recipes/drunkBananas.md @@ -4,14 +4,14 @@ ## Ingredients -Measure | Weight | Ingredient ---------|--------|----------- -3 | | Bananas -1/3 c | | Brandy or Rum -Dash | | Cinnamon -1/2 c | | Butter -1 c | | Brown Sugar -1 tsp | | Vanilla +Measure | Unit | Weight | Ingredient +--------|------|--------|----------- +3 | | | Bananas +1/3 | c | | Brandy or Rum +Dash | | | Cinnamon +1/2 | c | | Butter +1 | c | | Brown Sugar +1 | tsp | | Vanilla ## Instructions diff --git a/recipes/monkeyBread.md b/recipes/monkeyBread.md index 5a3fc2b..36a89a2 100644 --- a/recipes/monkeyBread.md +++ b/recipes/monkeyBread.md @@ -4,15 +4,15 @@ ## Ingredients -Measure | Weight | Ingredient ---------|--------|----------- -4 | | Biscuit Cans -2/3 c | | Sugar -1 1/2 tsp | | Cinnamon -**Sauce**| | -1 1/8 c | | Butter -1 1/2 c | | Sugar -1 1/2 tsp | | Cinnamon +Measure | Unit | Weight | Ingredient +--------|------|--------|----------- +4 | | | Biscuit Cans +2/3 | c | | Sugar +1 1/2 | tsp | | Cinnamon +**Sauce** | | | +1 1/8 | c | | Butter +1 1/2 | c | | Sugar +1 1/2 | tsp | | Cinnamon ## Instructions diff --git a/recipes/pizzaDough.md b/recipes/pizzaDough.md index eacb693..ce5435d 100644 --- a/recipes/pizzaDough.md +++ b/recipes/pizzaDough.md @@ -4,14 +4,14 @@ ## Ingredients -Measure | Weight | Ingredient ---------|--------|----------- -2 1/2c | | Flour -1 tsp | 7g | Salt -1 tsp | | Sugar -2 tbsp | | Olive Oil -1 c | | Warm Water (110F) -2 1/3 tsp | | Yeast +Measure | Unit | Weight | Ingredient +--------|------|--------|----------- +2 1/2 | c | | Flour +1 | tsp | 7g | Salt +1 | tsp | | Sugar +2 | tbsp | | Olive Oil +1 | c | | Warm Water (110F) +2 1/3 | tsp | | Yeast ## Instructions diff --git a/recipes/waffles.md b/recipes/waffles.md index bdaccf9..03fe00f 100644 --- a/recipes/waffles.md +++ b/recipes/waffles.md @@ -4,16 +4,16 @@ ## Ingredients -Measure | Weight | Ingredient ---------|--------|----------- -1 3/4 c | | Flour -1/2 tsp | | Salt -3 tsp | | Baking Powder -1/2 c | | Instant Dry Milk -2 | | Eggs -1/2 c | | Oil -1 3/4 c | | Water -Dash | | Cinnamon +Measure | Unit | Weight | Ingredient +--------|------|--------|----------- +1 3/4 | c | | Flour +1/2 | tsp | | Salt +3 | tsp | | Baking Powder +1/2 | c | | Instant Dry Milk +2 | | | Eggs +1/2 | c | | Oil +1 3/4 | c | | Water +Dash | | | Cinnamon ## Instructions