diff --git a/doc/metadata-values.txt b/doc/metadata-values.txt new file mode 100644 index 0000000..ae73024 --- /dev/null +++ b/doc/metadata-values.txt @@ -0,0 +1,12 @@ +METADATA VALUES USED BY DRAGONGLASS + +aliases + (Obsidian standard metadata) + List of alternative names that can be used to link to a + particular page. + +template + The file name of the template to be used to render this page, overriding the default. + +title + Title to use for the page, overriding the Markdown file name. diff --git a/doc/template-vars.txt b/doc/template-vars.txt new file mode 100644 index 0000000..137b731 --- /dev/null +++ b/doc/template-vars.txt @@ -0,0 +1,21 @@ +TEMPLATE VARIABLES PROVIDED BY DRAGONGLASS WHEN RENDERING A DOCUMENT + +backlinks + A list of pages that link to the page being rendered. Formatted as a list of dicts with + two elements, "name" and "link", containing the page title and the link to it, respectively. + +default_stylesheet + The filename of the default stylesheet which is generated by dragonglass and added to the + generated pages. + +dragonglass_version + The version number of dragonglass. + +python_version + The version number of Python that's running dragonglass. + +text + The text of the page being rendered. + +title + The title of the page being rendered. diff --git a/src/dragonglass/_version.py b/src/dragonglass/_version.py new file mode 100644 index 0000000..3dc1f76 --- /dev/null +++ b/src/dragonglass/_version.py @@ -0,0 +1 @@ +__version__ = "0.1.0" diff --git a/src/dragonglass/config.py b/src/dragonglass/config.py index df5c18d..062bbe4 100644 --- a/src/dragonglass/config.py +++ b/src/dragonglass/config.py @@ -83,4 +83,4 @@ class Context: """ if not self.template_dir.is_dir(): return DEFAULT_TEMPLATE_NAME - return self._default_template_name + return node.metadata.get("template", self._default_template_name) diff --git a/src/dragonglass/template.py b/src/dragonglass/template.py index f7fd978..7bd15b0 100644 --- a/src/dragonglass/template.py +++ b/src/dragonglass/template.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """The template engine used to render the data to the destination.""" +import sys from jinja2 import Environment, BaseLoader, ChoiceLoader, FunctionLoader, FileSystemLoader from typing import Any @@ -9,6 +10,7 @@ from urllib.parse import quote as urlquote from .config import Context, DEFAULT_TEMPLATE_NAME from .style import STYLESHEET_NAME from .tree import SourceNode +from ._version import __version__ """The default template used to render Markdown data.""" @@ -16,6 +18,7 @@ DEFAULT_TEMPLATE = """