aboutsummaryrefslogtreecommitdiff
path: root/src/smp/builtins.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/smp/builtins.py')
-rw-r--r--src/smp/builtins.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/smp/builtins.py b/src/smp/builtins.py
index afa153d..2fde231 100644
--- a/src/smp/builtins.py
+++ b/src/smp/builtins.py
@@ -201,7 +201,7 @@ def smp_builtin_read(macro_processor, filename, template_content=None):
metadata = {}
if 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=False)
+ smp_builtin_add_metadata(macro_processor, metadata, overwrite=True)
extension = os.path.splitext(filename)[1][1:] or ""
macro_processor._define_macro_with_prefix("target_file_extension", extension)
@@ -215,13 +215,22 @@ def smp_builtin_read(macro_processor, filename, template_content=None):
if extension == "md":
content = smp_builtin_html_from_markdown(macro_processor, content)
- if (template := macro_processor.macros.get("METADATA_template")) is not None:
+ if (template := macro_processor._get_metadata("template")) is not None:
if template not in macro_processor._get_macro_with_prefix("template_stack"):
return smp_builtin_read(macro_processor, template, content)
return content
+def smp_builtin_indent(macro_processor, indent: int, content: str):
+ indent = int(indent)
+ content = macro_processor.process_input(content)
+ return "\n".join(
+ f"{' ' * (indent if i > 0 else 0)}{x}"
+ for i, x in enumerate(content.split("\n"))
+ )
+
+
def smp_builtin_wodl(macro_processor, link, timeout_seconds=5):
if (macro_processor._get_macro_with_prefix("wodl_cache")) is None:
macro_processor._define_macro_with_prefix("wodl_cache", {})