Skip to main content

A markdown toolbox

Project description

marksmith

A Markdown toolbox — write docs in Markdown, ship them as polished DOCX.

PyPI Python CI License: MIT

Installation

pip install marksmith

Optional extras for template support:

pip install marksmith[template]

Quick start

# Using the installed script
marksmith convert my-doc.md output.docx

# Or via python -m
python -m marksmith convert my-doc.md output.docx

Markdown front-matter

You can add a YAML front-matter block at the top of your Markdown file. The metadata is written to the DOCX core properties (title, author, etc.) and is also available as Jinja2 template variables when using --template.

---
title:          My Document
version:        1.0
author:         Paul Cummings
date:           2026-03-16
classification: Internal
---

# My Document

Content goes here...

Supported Markdown elements

Element Status
Headings H1 – H6
Bold / italic / inline code
Fenced and indented code blocks
Unordered lists (nested)
Ordered lists (nested)
Block-quotes
Tables
Thematic breaks (horizontal rules)
Strikethrough
Links (text rendered, no hyperlink) ⚠️
Images ⚠️ placeholder text only
Inline HTML ➖ ignored

Template support

Keep your content in plain Markdown while producing brand-consistent DOCX output from a corporate template.

pip install marksmith[template]
marksmith convert my-doc.md output.docx --template company-template.docx

How it works

  1. Create a .docx template in Word with Jinja2-style placeholders for metadata sourced from your Markdown front-matter:

    {{ title }}        {{ version }}      {{ author }}
    {{ date }}         {{ classification }}
    
  2. Add a {{p marksmith_content }} paragraph alone on its own line at the exact point where the Markdown body should be inserted:

    {{p marksmith_content }}
    

    Important: Use {{p ... }} (with the p modifier), not {{ ... }}. The p modifier inserts a paragraph-level sub-document rather than plain text, so all headings, lists, tables, and code blocks are preserved.

  3. Run the conversion — marksmith will:

    • Render all front-matter metadata into the Jinja2 placeholders.
    • Convert the Markdown body to native DOCX content.
    • Insert the body at {{p marksmith_content }}.
    • Save the merged document.

Style inheritance

Content is inserted as a sub-document, so heading and paragraph styles are matched by name against those in your template. If your template defines Heading 1 with a custom font and colour, the converted content will pick it up automatically.


Roadmap

Action Description
convert Markdown → DOCX ✔️
convert --template Merge into branded DOCX template ✔️
lint Validate Markdown style and structure
toc Generate / update table of contents
diff Show structural diff between two Markdown files
Images Embed local images via run.add_picture()
Hyperlinks Full OOXML hyperlink support

Development

git clone https://github.com/tkdpython/marksmith
cd marksmith
pip install -e .[dev,template]

# Run tests
pytest

# Lint
ruff check .

Releasing

  1. Bump __version__ in marksmith/__init__.py.
  2. Commit and push.
  3. Create a GitHub Release with a tag matching the version (e.g. v0.2.0).
  4. The publish workflow fires automatically and publishes to PyPI via OIDC Trusted Publisher — no API tokens needed.

License

MIT — see LICENSE.

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

marksmith-0.2.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marksmith-0.2.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file marksmith-0.2.0.tar.gz.

File metadata

  • Download URL: marksmith-0.2.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for marksmith-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7d59452385d17da158f6f2a9fc2eeb6cb7ae2b8451fba1ad5e1c9ad839945608
MD5 8cc98d63c369780671b84bc30df0e071
BLAKE2b-256 dcf0e5a4c155c47f18cf02eeb749d273ba9d074efbee717b07ca89ff63f1feb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for marksmith-0.2.0.tar.gz:

Publisher: publish.yml on tkdpython/marksmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file marksmith-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: marksmith-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for marksmith-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9efeeff58726df2e6713f0af1194c6c9129f87ccb827e93d25d9eb1139380b0
MD5 a63d66157f05823cb2451e92b32ae324
BLAKE2b-256 f9882ed0504803d85bbb66996ff6fdceef70babbe0e7aecf3c6aed183ccaebae

See more details on using hashes here.

Provenance

The following attestation bundles were made for marksmith-0.2.0-py3-none-any.whl:

Publisher: publish.yml on tkdpython/marksmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page