Check-in by ben on 2022-11-22 18:14:17
Fix for ingredients sections that come after a plain ingredient
list.
INSERTED DELETED
11 1 mmhtml.awk
12 1 mmrtf.awk
23 2 TOTAL over 2 changed files
Index: mmhtml.awk
==================================================================
--- mmhtml.awk
+++ mmhtml.awk
@@ -247,10 +247,11 @@
}
return retval
}
BEGIN {
+ after_ingredients = 0
at_end = 0
in_gsection = 0
in_heading = 0
in_ingredients = 0
in_instructions = 0
@@ -287,11 +288,11 @@
in_gsection = 1
gsection = substr($0, RLENGTH+1)
gsub(/-+$/, "", gsection)
} else if (/^[[:space:]]*$/) {
in_ingredients = 0
- in_instructions = 1
+ after_ingredients = 1
} else {
gsection = ""
i = gsections[gsection]
ingredient_parse($0)
if (is_continuation == 0) {
@@ -300,10 +301,19 @@
}
amounts[gsection,i] = amount
units[gsection,i] = unit
ingredients[gsection,i] = ingredient
}
+ } else if (after_ingredients) {
+ if (match($0, /^MMMMM-+/)) {
+ after_ingredients = 0
+ in_gsection = 1
+ gsection = substr($0, RLENGTH+1)
+ gsub(/-+$/, "", gsection)
+ } else {
+ after_ingredients = 0
+ in_instructions = 1
} else if (in_gsection) {
if (match($0, /^MMMMM-+/)) {
in_gsection = 1
gsection = substr($0, RLENGTH+1)
gsub(/-+$/, "", gsection)
Index: mmrtf.awk
==================================================================
--- mmrtf.awk
+++ mmrtf.awk
@@ -270,10 +270,11 @@
names["kg"] = "kilogram"
return
}
BEGIN {
+ after_ingredients = 0
at_end = 0
in_gsection = 0
in_heading = 0
in_ingredients = 0
in_instructions = 0
@@ -309,11 +310,11 @@
in_gsection = 1
gsection = substr($0, RLENGTH+1)
gsub(/-+$/, "", gsection)
} else if (/^[[:space:]]*$/) {
in_ingredients = 0
- in_instructions = 1
+ after_ingredients = 1
} else {
gsection = ""
i = gsections[gsection]
ingredient_parse($0)
if (is_continuation == 0) {
@@ -321,10 +322,20 @@
gsections[gsection] = i
}
amounts[gsection,i] = amount
units[gsection,i] = unit
ingredients[gsection,i] = ingredient
+ }
+ } else if (after_ingredients) {
+ if (match($0, /^MMMMM-+/)) {
+ after_ingredients = 0
+ in_gsection = 1
+ gsection = substr($0, RLENGTH+1)
+ gsub(/-+$/, "", gsection)
+ } else {
+ after_ingredients = 0
+ in_instructions = 1
}
} else if (in_gsection) {
if (match($0, /^MMMMM-+/)) {
in_gsection = 1
gsection = substr($0, RLENGTH+1)