separate unit into separate column from measure. they get combined in md generation so no visual change

This commit is contained in:
len0rd 2022-06-22 22:48:11 -04:00
parent fa59d32659
commit e21470b565
8 changed files with 99 additions and 74 deletions

View file

@ -126,6 +126,31 @@ function convertRecipeMarkdown(inputDir, outputDir) {
console.error(err); console.error(err);
return; 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 tokens = md.parse(data)
let sections = [] let sections = []

View file

@ -4,19 +4,19 @@
## Ingredients ## Ingredients
Measure | Weight | Ingredient Measure | Unit | Weight | Ingredient
--------|--------|----------- --------|------|--------|-----------
1/4 c | | Cinnamon-Sugar 1/4 | c | | Cinnamon-Sugar
3 c | | Sugar 3 | c | | Sugar
3 | | Egg 3 | | | Eggs
6 | | Mashed Ripe Banana 6 | | | Banana
3/4 c | | Butter 3/4 | c | | Butter
16 oz | | Sour Cream 16 | oz | | Sour Cream
2 tsp | | Vanilla 2 | tsp | | Vanilla
2 tsp | | Cinnamon 2 | tsp | | Cinnamon
1/2 tsp | | Salt 1/2 | tsp | | Salt
3 tsp | | Baking Soda 3 | tsp | | Baking Soda
4 1/2 c | | Flour 4 1/2 | c | | Flour
## Instructions ## Instructions

View file

@ -8,20 +8,20 @@
## Ingredients ## Ingredients
Measure | Weight | Ingredient Measure | Unit | Weight | Ingredient
--------|--------|----------- --------|------|--------|-----------
1c | | Unsalted Butter 1 | c | | Unsalted Butter
1 1/4c | 290g | Brown Sugar 1 1/4 | c | 290g | Brown Sugar
1/4c | 60g | Sugar 1/4 | c | 60g | Sugar
1 | | Egg 1 | | | Egg
1 | | Egg Yolk 1 | | | Egg Yolk
2 tbsp | | Whole Milk 2 | tbsp | | Whole Milk
1 1/2 tsp | | Vanilla 1 1/2 | tsp | | Vanilla
2 3/4c | 370g | Flour 2 3/4 | c | 370g | Flour
1 tsp | 7g | Baking Soda 1 | tsp | 7g | Baking Soda
1 tsp | 7g | Salt 1 | tsp | 7g | Salt
1/4 tsp | 1g | Cinnamon 1/4 | tsp | 1g | Cinnamon
2c | | Chocolate Chip 2 | c | | Chocolate Chip
## Instructions ## Instructions

View file

@ -6,22 +6,22 @@
## Ingredients ## Ingredients
Measure | Weight | Ingredient Measure | Unit | Weight | Ingredient
--------|--------|----------- --------|------|--------|-----------
4 3/4 c | | Flour 4 3/4 | c | | Flour
1 1/2 tsp | | Salt 1 1/2 | tsp | | Salt
1/3 c | | Sugar 1/3 | c | | Sugar
1/3 c | | Oil 1/3 | c | | Oil
2 | | Beaten Eggs 2 | | | Eggs
1 1/4c | | Warm water (110F) 1 1/4 | c | | Warm water (110F)
2 tbsp | | Yeast 2 | tbsp | | Yeast
4 tbsp | | Melted Butter 4 | tbsp | | Melted Butter
1/2 c | | Cinnamon Sugar 1/2 | c | | Cinnamon Sugar
## Instructions ## 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 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 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. 4. Roll up dough and cut in 1-1/2” slices. Place in rectangular pan and press.

View file

@ -4,14 +4,14 @@
## Ingredients ## Ingredients
Measure | Weight | Ingredient Measure | Unit | Weight | Ingredient
--------|--------|----------- --------|------|--------|-----------
3 | | Bananas 3 | | | Bananas
1/3 c | | Brandy or Rum 1/3 | c | | Brandy or Rum
Dash | | Cinnamon Dash | | | Cinnamon
1/2 c | | Butter 1/2 | c | | Butter
1 c | | Brown Sugar 1 | c | | Brown Sugar
1 tsp | | Vanilla 1 | tsp | | Vanilla
## Instructions ## Instructions

View file

@ -4,15 +4,15 @@
## Ingredients ## Ingredients
Measure | Weight | Ingredient Measure | Unit | Weight | Ingredient
--------|--------|----------- --------|------|--------|-----------
4 | | Biscuit Cans 4 | | | Biscuit Cans
2/3 c | | Sugar 2/3 | c | | Sugar
1 1/2 tsp | | Cinnamon 1 1/2 | tsp | | Cinnamon
**Sauce**| | **Sauce** | | |
1 1/8 c | | Butter 1 1/8 | c | | Butter
1 1/2 c | | Sugar 1 1/2 | c | | Sugar
1 1/2 tsp | | Cinnamon 1 1/2 | tsp | | Cinnamon
## Instructions ## Instructions

View file

@ -4,14 +4,14 @@
## Ingredients ## Ingredients
Measure | Weight | Ingredient Measure | Unit | Weight | Ingredient
--------|--------|----------- --------|------|--------|-----------
2 1/2c | | Flour 2 1/2 | c | | Flour
1 tsp | 7g | Salt 1 | tsp | 7g | Salt
1 tsp | | Sugar 1 | tsp | | Sugar
2 tbsp | | Olive Oil 2 | tbsp | | Olive Oil
1 c | | Warm Water (110F) 1 | c | | Warm Water (110F)
2 1/3 tsp | | Yeast 2 1/3 | tsp | | Yeast
## Instructions ## Instructions

View file

@ -4,16 +4,16 @@
## Ingredients ## Ingredients
Measure | Weight | Ingredient Measure | Unit | Weight | Ingredient
--------|--------|----------- --------|------|--------|-----------
1 3/4 c | | Flour 1 3/4 | c | | Flour
1/2 tsp | | Salt 1/2 | tsp | | Salt
3 tsp | | Baking Powder 3 | tsp | | Baking Powder
1/2 c | | Instant Dry Milk 1/2 | c | | Instant Dry Milk
2 | | Eggs 2 | | | Eggs
1/2 c | | Oil 1/2 | c | | Oil
1 3/4 c | | Water 1 3/4 | c | | Water
Dash | | Cinnamon Dash | | | Cinnamon
## Instructions ## Instructions