Metadata-Version: 2.4
Name: mark-my-word
Version: 0.2.0
Summary: Convert Markdown file to PDF using themes extracted directly from Word templates
Project-URL: Homepage, https://gitlab.com/tastapod/mark-my-word
Project-URL: Repository, https://gitlab.com/tastapod/mark-my-word.git
Project-URL: Issues, https://gitlab.com/tastapod/mark-my-word/-/issues
Author-email: Daniel Terhorst-North <daniel@dannorth.net>
License-Expression: MIT
Keywords: docx,markdown,pdf,theme,weasyprint,word
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: Markup
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Requires-Dist: click~=8.3
Requires-Dist: markdown2~=2.5
Requires-Dist: python-docx~=1.2
Requires-Dist: python-frontmatter~=1.1
Requires-Dist: pyyaml~=6.0
Requires-Dist: weasyprint~=68.1
Description-Content-Type: text/markdown

# mark-my-word

You have a Word template — the right fonts, colours, headers, footers. You have a Markdown file you want to print. `mark-my-word` connects the two: it reads your Word template and uses it to render your Markdown as a styled PDF.

## Is this for me?

It's a good fit if:

- You have a `.docx` or `.dotx` Word template with the styling you want
- You want your PDFs to match that template without manual CSS work
- You're happy running a command-line tool

It's probably not for you if you need pixel-perfect fidelity to complex Word layouts (tables with merged cells, tracked changes, etc.) or if you need to render Word documents directly — this tool works with Markdown input.

## Install

```shell
uv tool install mark-my-word
# or
pipx install mark-my-word
```

Requires Python 3.11+. WeasyPrint (the PDF engine) needs some system libraries — see the [WeasyPrint docs](https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#installation) if the install fails.

## Basic usage

### Step 1 — extract a theme from your Word template

```shell
mark-my-word extract my-template.dotx --output themes/my-theme/
```

This reads your Word template and writes a theme directory containing a stylesheet and HTML fragments for your headers and footers. You only need to do this once (or whenever your template changes).

### Step 2 — render your Markdown to PDF

```shell
mark-my-word render document.md --theme themes/my-theme/
```

Output lands next to the input file by default (`document.pdf`). Use `--output` to put it somewhere else:

```shell
mark-my-word render document.md --theme themes/my-theme/ --output /tmp/document.pdf
```

### Or do it in one step

If you don't want to keep the extracted theme around, you can pass the Word template directly:

```shell
mark-my-word render document.md --template my-template.dotx
```

The theme is extracted on the fly and discarded. Add `--save-theme themes/my-theme/` if you change your mind later.

## Document frontmatter

Headers and footers in your theme can include placeholders like `{title}` or `{author}`. Set them in your Markdown file's YAML frontmatter:

```markdown
---
title: Q1 Report
author: Daniel
---

# Introduction

...
```

Pass extra values on the command line with `--set`:

```shell
mark-my-word render document.md --theme themes/my-theme/ --set version=draft
```

## Skipping preamble

If you write notes in an app like NotePlan, there's often metadata at the top — tags, links, app-specific syntax — that you don't want in the PDF. Put `<!--more-->` on its own line to mark where your real content starts:

```markdown
@project(Quarterly Review)
[[linked-note]]

<!--more-->

# Q1 Report

...
```

Everything before `<!--more-->` is ignored. Everything after renders normally. If `<!--more-->` appears inside a code block in the body, put a second one at the top of the document to act as the separator instead.

## What gets extracted

From your Word template, `mark-my-word extract` pulls:

- Page margins
- Theme colours → CSS custom properties (`--color-body`, `--color-heading`, etc.)
- Base font and heading styles (H1–H6)
- Header and footer content, including tab-separated left/right layouts and page numbers
- Watermark images

The result is a plain directory you can inspect and edit. The stylesheet uses CSS custom properties throughout, so tweaking colours or fonts is a one-line change.

## Theme directory layout

```
themes/my-theme/
  style.css           required
  header.html         header on all pages (or cont-header.html / first-header.html)
  footer.html         footer on all pages (or cont-footer.html / first-footer.html)
  watermark.png       optional full-page background image
```

If your Word template has a different header on the first page, `extract` writes `first-header.html` and `cont-header.html` separately. `render` handles both layouts automatically.

## Options

```
mark-my-word render --help
mark-my-word extract --help
```

## Links

- [Repository](https://gitlab.com/tastapod/mark-my-word)
- [Issue tracker](https://gitlab.com/tastapod/mark-my-word/-/issues)
