Python-Markdown extension for parsing Iron Vault journals
Project description
ironvaultmd - Iron Vault Markdown Parser
A Python-Markdown (GitHub) extension to parse Markdown files from the Iron Vault (GitHub) Obsidian plugin.
The main idea for this extension is to convert Iron Vault markdown journals into HTML sites for publishing.
Features
Supports at this point
- parsing
```iron-vault-mechanics ```blocks (see below for details) - collecting frontmatter YAML information into a dictionary
- regular and labeled wiki-style links, i.e.
[[link]]and[[link|label]](see also below for details) - user-definable templates for parsing the supported nodes
Supported mechanics block content
Disclaimer: This extension came into existence for my own purposes, to eventually publish my campaigns.
After old-school pen and paper, and a bunch of other experiments, I eventually gave Iron Vault a try for my most recent campaign - and I haven't looked back. However, this only happened in December 2024, so somewhere around Iron Vault version 1.88.1, and only with a Starforged campaign. Currently, neither journals created with an older version, nor OG Ironsworn, Delve, or Sundered Isles campaigns are supported, and results may be disappointing.
Mechanics nodes
Currently supported nodes within a mechanics block: add, burn, clock, impact, initiative, meter, move, out-of-character comments, oracle (note, only single oracle nodes, no oracle groups), position, progress, progress-roll, reroll, roll, track, xp.
Links
Links are currently detected and optionally collected into a list with their reference and label, but no actual linking is performed. To collect all found links:
By default, links are packed in a <span class="ivm-link"> element, but a link user template string
can be defined to adjust that behavior - see the sections about templates for more information.
User-defined templates
Nodes are parsed using the Jinja templating engine. Every supported node has a default template and gets automatically passed all available data to it.
The default templates for each node (and some extra elements) along with a description of the available
variables can be found from the templates/ directory .
Each node template can be overridden when initiating the IronVaultExtension. See below for some examples.
Installation
pip install ironvaultmd
This will install the required dependencies, markdown and pyyaml, as well.
Usage
Quick usage to convert an Iron Vault journal Markdown file to HTML and print it to the terminal:
import markdown
from ironvaultmd import IronVaultExtension
md = markdown.Markdown(extensions=[IronVaultExtension()])
with open("/path/to/ironvault/Journals/JournalEntry.md", "r", encoding="utf-8") as file:
print(md.convert(file.read()))
Check also the ironparser.py example file for a more complete example to write a given journal Markdown file as HTML file.
Links
import markdown
from ironvaultmd import IronVaultExtension, Link
my_links: list[Link] = []
md = markdown.Markdown(extensions=[IronVaultExtension(links=my_links)])
with open("/path/to/ironvault/Journals/JournalEntry.md", "r", encoding="utf-8") as file:
print(md.convert(file.read()))
print(my_links)
Frontmatter
import markdown
from ironvaultmd import IronVaultExtension
my_frontmatter = {}
md = markdown.Markdown(extensions=[IronVaultExtension(frontmatter=my_frontmatter)])
with open("/path/to/ironvault/Journals/JournalEntry.md", "r", encoding="utf-8") as file:
print(md.convert(file.read()))
print(my_frontmatter)
User Templates
import markdown
from ironvaultmd import IronVaultExtension, IronVaultTemplates
my_templates = IronVaultTemplates()
my_templates.add = '<div class="my-own-class">Adding {{ add }}</div>'
my_templates.roll = '<div class="ivm-roll">{{ total }} vs {{ vs1 }} and {{ vs2 }}</div>'
my_templates.link = '<i>{{ label }}</i>'
md = markdown.Markdown(extensions=[IronVaultExtension(templates=my_templates)])
Developing
See DEVELOPING.md for details on how to set up development environments etc.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ironvaultmd-0.2.0.tar.gz.
File metadata
- Download URL: ironvaultmd-0.2.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a29b739867a6fca3adc892982a6ccdd718af8634e1d8594cd629f3e77294878d
|
|
| MD5 |
c7f9058f0d3c95d74efebc4f0bd57581
|
|
| BLAKE2b-256 |
f57834166e84da62fbaf9f96911ca94af9befe1befeddfac5de9986babc36eca
|
File details
Details for the file ironvaultmd-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ironvaultmd-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c43368e930187713f0bc73a384f58a11b7222ae530fa15e8b36557ddb32be38
|
|
| MD5 |
57b3819aa53233eaf52b267c933889bb
|
|
| BLAKE2b-256 |
d9e09fabebd25ec9c1845ac3e626251ba9c358960968cedc5230cd3215588364
|