Skip to content

Commit

Permalink
Fixed Issue 20: Variable redefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinPacker committed May 24, 2022
1 parent 0afd4cd commit 31e543f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions mdpre
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ from enum import Enum
import calendar


mdpre_level = "0.6.4"
mdpre_date = "16 May, 2022"
mdpre_level = "0.6.4+"
mdpre_date = "24 May, 2022"
banner = "mdpre Markdown Preprocessor v" + mdpre_level + " (" + mdpre_date + ")"

log = partial(print, file=sys.stderr) # | create log to stderr
Expand Down Expand Up @@ -576,17 +576,30 @@ def parse_include(input_file, vars, ifStack, embedLevel):

elif line.startswith("=def ") is True:
var = parse_def(line[5:-1].lstrip())
vars.append(var)
var_index = find_variable(var[0], vars)
if var_index > -1:
# Replace the variable with its new definition
vars[var_index] = var
else:
# Add the variable as it's new
vars.append(var)

if wantVerbose is True:
varName, varType, varValue = var

if var_index > -1:
redefined =" (redefined)"
else:
redefined =""

input_file2.append(
"<!--mdpre-def:"
+ varName
+ ":"
+ varType
+ ":"
+ varValue
+ redefined
+ "-->"
)

Expand Down

0 comments on commit 31e543f

Please sign in to comment.