Skip to content

Commit 6300a1e

Browse files
committed
feat: refactor variable substitution logic to preserve original markdown string
1 parent 987c5f9 commit 6300a1e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/paradoc/document.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,26 +346,22 @@ def _perform_variable_substitution(self, use_table_var_substitution):
346346
md_file = mdf.path
347347
os.makedirs(mdf.new_file.parent, exist_ok=True)
348348
md_str = mdf.read_original_file()
349+
md_str_original = md_str
349350

350351
for m in mdf.get_variables():
351352
res = m.group(1)
352353
key = res.split("|")[0] if "|" in res else res
353354
list_of_flags = res.split("|")[1:] if "|" in res else None
354355
key_clean = key[2:-2] if key.startswith("__") and key.endswith("__") else key
355356

356-
print(f"DEBUG VAR SUB: Processing key='{key}', key_clean='{key_clean}'")
357-
print(f"DEBUG VAR SUB: Starts with __? {key.startswith('__')}, Ends with __? {key.endswith('__')}")
358-
359357
# Check database first for table keys (keys with __ markers)
360358
if key.startswith("__") and key.endswith("__"):
361-
print(f"DEBUG VAR SUB: Checking database for '{key_clean}'")
362359
# Get full reference including any annotation that follows
363360
full_reference = m.group(0)
364-
print(f"DEBUG VAR SUB: full_reference = '{full_reference}'")
365361

366362
# Look ahead in the string to find annotation pattern
367363
match_end = m.end()
368-
remaining_str = md_str[match_end:]
364+
remaining_str = md_str_original[match_end:]
369365

370366
# Check if there's a {tbl:...} annotation following
371367
if remaining_str.startswith('{tbl:'):

0 commit comments

Comments
 (0)