From e959972105686988f9c46d152f34f658192229fd Mon Sep 17 00:00:00 2001 From: Qrius Date: Thu, 24 Apr 2025 12:02:21 +0200 Subject: Improve smp entrypoint with additional options --- src/smp/builtins.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/smp/builtins.py') diff --git a/src/smp/builtins.py b/src/smp/builtins.py index 30ebbdc..424aa53 100644 --- a/src/smp/builtins.py +++ b/src/smp/builtins.py @@ -197,9 +197,6 @@ def _smp_builtin_template_content(): macro_processor._enter_file_frame(f"[part]{filename}", 0, "") res = macro_processor.process_input(content, file=filename) - if extension == "md": - res = smp_builtin_html_from_markdown(macro_processor, res) - macro_processor._pop_file_frame() return res @@ -210,13 +207,21 @@ def smp_builtin_template(macro_processor, template, content): return _smp_builtin_read(macro_processor, template, template_content=content) +def smp_builtin_iftruthy(content): + if isinstance(content, str) and content.lower() in ["true", "yes"]: + return True + if isinstance(content, bool): + return content + return False + + def _smp_builtin_read(macro_processor, filename, template_content=None, inline=False): macro_processor._enter_file_frame(filename, 0, template_content) with open(filename, "r") as f: file_content = f.read() metadata = {} - if macro_processor._get_macro_with_prefix("parse_file_yaml"): + if smp_builtin_iftruthy(macro_processor._get_macro_with_prefix("parse_file_yaml")): metadata, file_content = extract_parse_yaml_metadata(file_content) _smp_builtin_add_metadata(macro_processor, metadata, overwrite=True) @@ -246,9 +251,6 @@ def _smp_builtin_read(macro_processor, filename, template_content=None, inline=F content = macro_processor.process_input(file_content, file=filename) - if extension == "md": - content = smp_builtin_html_from_markdown(macro_processor, content) - return content -- cgit v1.2.3