hypermarkdown 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. hypermarkdown-0.2.0/CHANGELOG.md +221 -0
  2. hypermarkdown-0.2.0/LICENSE +21 -0
  3. hypermarkdown-0.2.0/MANIFEST.in +18 -0
  4. hypermarkdown-0.2.0/PKG-INFO +303 -0
  5. hypermarkdown-0.2.0/README.md +265 -0
  6. hypermarkdown-0.2.0/pyproject.toml +147 -0
  7. hypermarkdown-0.2.0/setup.cfg +4 -0
  8. hypermarkdown-0.2.0/src/hypermarkdown/__init__.py +31 -0
  9. hypermarkdown-0.2.0/src/hypermarkdown/cli.py +177 -0
  10. hypermarkdown-0.2.0/src/hypermarkdown/config.py +110 -0
  11. hypermarkdown-0.2.0/src/hypermarkdown/diagram.py +169 -0
  12. hypermarkdown-0.2.0/src/hypermarkdown/embed.py +227 -0
  13. hypermarkdown-0.2.0/src/hypermarkdown/frontmatter.py +191 -0
  14. hypermarkdown-0.2.0/src/hypermarkdown/graph.py +74 -0
  15. hypermarkdown-0.2.0/src/hypermarkdown/imports.py +62 -0
  16. hypermarkdown-0.2.0/src/hypermarkdown/lint/__init__.py +6 -0
  17. hypermarkdown-0.2.0/src/hypermarkdown/lint/report.py +44 -0
  18. hypermarkdown-0.2.0/src/hypermarkdown/lint/rules.py +257 -0
  19. hypermarkdown-0.2.0/src/hypermarkdown/mkdocs_plugin.py +337 -0
  20. hypermarkdown-0.2.0/src/hypermarkdown/model.py +155 -0
  21. hypermarkdown-0.2.0/src/hypermarkdown/parse.py +174 -0
  22. hypermarkdown-0.2.0/src/hypermarkdown/render/__init__.py +5 -0
  23. hypermarkdown-0.2.0/src/hypermarkdown/render/flat.py +77 -0
  24. hypermarkdown-0.2.0/src/hypermarkdown/resolve.py +334 -0
  25. hypermarkdown-0.2.0/src/hypermarkdown/scan.py +153 -0
  26. hypermarkdown-0.2.0/src/hypermarkdown/urls.py +60 -0
  27. hypermarkdown-0.2.0/src/hypermarkdown.egg-info/PKG-INFO +303 -0
  28. hypermarkdown-0.2.0/src/hypermarkdown.egg-info/SOURCES.txt +30 -0
  29. hypermarkdown-0.2.0/src/hypermarkdown.egg-info/dependency_links.txt +1 -0
  30. hypermarkdown-0.2.0/src/hypermarkdown.egg-info/entry_points.txt +6 -0
  31. hypermarkdown-0.2.0/src/hypermarkdown.egg-info/requires.txt +11 -0
  32. hypermarkdown-0.2.0/src/hypermarkdown.egg-info/top_level.txt +1 -0
@@ -0,0 +1,221 @@
1
+ # Changelog — `hypermarkdown` (the `hmd` command)
2
+
3
+ Notable changes to the Python tool, newest first. This file covers **this
4
+ distribution only** — the version on PyPI, the `hmd` CLI, the library, and the
5
+ MkDocs plugin. The other tools in the monorepo version themselves and keep their
6
+ own changelogs; [the repository's index](../../CHANGELOG.md) lists them.
7
+
8
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
9
+ versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html) with
10
+ the usual `0.x` caveat: **the format itself may change between minor versions.**
11
+ Until `1.0`, treat a minor bump as potentially breaking for `.hmd` sources, not
12
+ only for the Python API.
13
+
14
+ ## [Unreleased]
15
+
16
+ ## [0.2.0] — 2026-08-10
17
+
18
+ **The distribution is renamed.** `pip install hypermarkdown` replaces
19
+ `pip install hyper-markdown`, and the import package is `hypermarkdown` rather
20
+ than `hyper_markdown`. PyPI has no rename, so this is a new project: `0.1.1`
21
+ stays installable under the old name, receives no further release, and is
22
+ retired deliberately later.
23
+
24
+ A minor bump rather than a patch, for two reasons that are about `.hmd` sources
25
+ and about the library rather than about the name: `nav` becomes a mapping, and
26
+ the import package moves. Under this project's `0.x` rule a minor release is
27
+ where the format is allowed to move, so that is where these belong.
28
+
29
+ ### Added
30
+ - **`nav.visibility` gates publication, and the default is private.** A card
31
+ reaches a built site only with `nav: {visibility: public}`; absent that there
32
+ is no page and no URL. Visibility inherits the way `use` does — the card, then
33
+ the nearest ancestor `index.hmd`, then the default — so a folder note
34
+ publishes its whole subtree and a card inside opts out with its own `private`.
35
+ Both errors are possible, but they are not symmetric: a page that should have
36
+ shipped and did not is visible to its author on the next build, while one that
37
+ shipped and should not have is a leak nobody looks for.
38
+ - **`HMD017`**, a warning when a published card links to or embeds one that is
39
+ not published. Expansion copies the target's bytes into the host page, so
40
+ `expand` takes a `can_embed` predicate rather than learning what visibility
41
+ is — publication is the caller's policy, and `hmd render` on a card you named
42
+ yourself is not a site build. A blocked embed degrades to the same red link a
43
+ blocked link gets.
44
+
45
+ ### Changed
46
+ - **The MkDocs plugin key is `hypermarkdown`.** The old `hyper-markdown` key is
47
+ retained as an alias resolving to the same class, so an existing `mkdocs.yml`
48
+ keeps building untouched — that key is the one renamed identifier that appears
49
+ inside files this project does not own, and dropping it would be a hard build
50
+ failure whose cause the site's author never saw. `hypermarkdown` is the
51
+ supported spelling; the alias is a compatibility measure with an end date yet
52
+ to be set.
53
+ - **`import hyper_markdown` becomes `import hypermarkdown`.** No alias is
54
+ provided here. The library API was never the documented interface — the `hmd`
55
+ command and the plugin key were — and the package is `0.x`.
56
+ - The project's name is written **HyperMarkDown** in prose and `hypermarkdown`
57
+ in identifiers, its site is `hypermarkdown.org`, and its repository is
58
+ `github.com/ewiger/hypermarkdown`.
59
+
60
+ - **`nav` is a mapping, not an integer.** `nav: 10` becomes
61
+ `nav: {order: 10}`; the known keys are `order` and `visibility`. Ordering was
62
+ simply the dimension that existed first, and a scalar would have needed a
63
+ second spelling the moment `visibility` was wanted. The old form is reported
64
+ as `HMD013` rather than quietly accepted — a card carrying it is asking to be
65
+ ordered, and the silent outcome, falling into the unkeyed bucket and sorting
66
+ last, is exactly the failure its author would not look for.
67
+ - **The distribution has its own README, changelog, and license.** All three
68
+ were symlinks into the repository root, which made the PyPI long description
69
+ the monorepo's front page — an install page that opened by explaining the
70
+ format and closed by naming three tools, two of which you cannot `pip
71
+ install`. Each tool under `tools/` now carries its own set of these files, and
72
+ this one is about the `hmd` command: install, the commands, the linter's
73
+ severities, the MkDocs plugin, and the library. Nothing installed by name
74
+ changed.
75
+ - **Every link in the long description is absolute.** A relative link in a PyPI
76
+ description resolves against `pypi.org`, not against the repository, so the
77
+ old symlinked README's links to `examples/small/` and `DEVELOP.md` were dead
78
+ on the page most users read first.
79
+ - **`hmd lint` is described as `HMD001`–`HMD017`.** Seventeen rules are
80
+ implemented; the README and the changelog had both been saying sixteen since
81
+ `nav` visibility and HMD017 landed.
82
+
83
+ ## [0.1.1] — 2026-08-08
84
+
85
+ A dependency-correctness release. No behaviour of the format, the CLI, or the
86
+ plugin changed.
87
+
88
+ ### Fixed
89
+
90
+ - **`hmd render --to html` was unprotected against the Pygments 2.20 defect.**
91
+ `pymdownx.superfences` is loaded by the HTML renderer, so it is a *base*
92
+ dependency — but 0.1.0 carried its `pygments<2.20` guard in the `mkdocs`
93
+ extra. A plain `pip install hyper-markdown` could therefore resolve a
94
+ combination in which every fenced code block rendered as running text, with
95
+ nothing raised and no site involved.
96
+ - **The README told a `pip install` user to lint `examples/small`**, which
97
+ travels in the repository and the source archive but not in the wheel. The
98
+ quickstart now lints your own tree, and points at a clone for the fixture.
99
+ - **The card that teaches the format taught resolution wrongly.**
100
+ `doc/wiki/hyper-markdown.hmd` described a bare name as matching "by filename
101
+ alone", predating the spine walk. It now states the real order — beside the
102
+ card, then each folder above without recursion, nearest winning, a whole-tree
103
+ sweep only if that fails, and two matches in the sweep an error rather than a
104
+ tie-break.
105
+
106
+ ### Changed
107
+
108
+ - **`pygments<2.20` is gone; `pymdown-extensions>=10.21.2` replaces it.** The
109
+ defect was never Pygments' own: 10.21.2, published the same day as Pygments
110
+ 2.20.0, restores fence matching. Bisected against 2.20.0 — 10.20.1 and 10.21
111
+ broken, 10.21.2, 10.21.3, and 11.0.1 correct. The constraint now sits in the
112
+ base dependencies, with the code that needs it.
113
+ - **Every dependency range is capped at the next major**, the bound a dependency
114
+ is allowed to break its own contract at: `typer>=0.12,<1`, `pyyaml>=6,<7`,
115
+ `markdown>=3.6,<4`, `pymdown-extensions>=10.21.2,<12`, `pytest>=8,<10`. The
116
+ existing `mkdocs>=1.6,<2` and `mkdocs-material>=9,<10` are unchanged.
117
+ - **`uv.lock` is committed**, and CI and the Pages deploy install with
118
+ `uv sync --locked` rather than resolving fresh on every run. The published
119
+ site is now built from the same versions the tests ran against, and a
120
+ dependency upgrade arrives as a reviewable diff. The wheel smoke test stays
121
+ deliberately unlocked, since its job is to exercise what `pip install` gives a
122
+ stranger.
123
+
124
+ Contributor setup is now `uv sync --locked --all-extras`; see
125
+ [DEVELOP.md](../../DEVELOP.md).
126
+
127
+ ## [0.1.0] — 2026-08-08
128
+
129
+ First public release. Everything below is new; there is nothing to compare it
130
+ against.
131
+
132
+ ### The format
133
+
134
+ - **Six owned constructs** on top of GitHub-flavored markdown: wikilinks,
135
+ aliased links, heading links, block anchors, block references, and the three
136
+ embed forms. Everything else is ordinary GFM.
137
+ - **Deterministic resolution.** A bare name is resolved against explicit imports
138
+ first, then the *spine* — this folder, then each folder above it, probed
139
+ without recursion — then imported search paths, then a whole-tree sweep. A
140
+ spine lookup never reaches sideways; the final sweep may find a unique card
141
+ elsewhere in the namespace.
142
+ - **Autodiscovery does not tie-break.** Multiple matches in the final sweep are
143
+ an error. Ordered wildcard imports use declaration precedence and report
144
+ shadowing as HMD016.
145
+ - **Frontmatter** carries `tags`, `use`, `import`, and `nav`. Both import forms
146
+ are supported: named with an alias, and star, which contributes a search path.
147
+ - **Folder notes.** `[[a/b]]` and `[[a/b/index]]` address the folder note at
148
+ `a/b/index.hmd`. A sibling `a/b.hmd` would collide with that address (HMD012).
149
+
150
+ ### The `hmd` command
151
+
152
+ - `hmd lint` — parse, resolve, and report. Sixteen rules with stable IDs, text
153
+ or JSON output, `--strict` to count warnings as errors. Exit codes are pinned
154
+ for CI: `0` clean, `1` diagnostics, `2` usage error.
155
+ - `hmd render PATH --to markdown|html` — expand embeds and rewrite resolved
156
+ links. Embed depth is capped at 16 (`HMD008`) and cycles are reported
157
+ (`HMD007`).
158
+ - `hmd graph` — the resolved link graph as JSON.
159
+ - `hmd info` — the resolved root and the discovery policy in force.
160
+ - `hmd --version`.
161
+ - Every command takes `--root` to override the namespace root, which otherwise
162
+ comes from the `wiki` setting in `.hmd/config.toml` and defaults to
163
+ `doc/wiki`. A `.hmd/` directory doubles as a project-root marker, so any
164
+ subtree can be self-contained.
165
+
166
+ ### Publishing
167
+
168
+ - A **MkDocs plugin**, registered through the `mkdocs.plugins` entry point and
169
+ installed with the `mkdocs` extra. It registers `.hmd` files as pages, derives
170
+ the nav from the namespace tree, expands embeds, and rewrites every wikilink
171
+ to a source-relative link that MkDocs resolves and validates itself.
172
+ - A card at `a/b.hmd` serves at `a/b/`; cards sort by path, or by a `nav:`
173
+ integer in their frontmatter.
174
+ - **A book with a wiki in it.** Point `docs_dir` at a documentation tree and the
175
+ plugin's `root` at the subtree that is a namespace. An authored `nav` is used
176
+ verbatim except where it names `hmd://wiki`, which is replaced by the derived
177
+ wiki section.
178
+ - An unresolved link renders as a **red link** rather than failing the build, so
179
+ a wiki stays publishable while it is still being written.
180
+ - `mkdocs serve` picks up `.hmd` edits — the plugin watches the namespace root,
181
+ which MkDocs would otherwise ignore.
182
+ - Math, callouts, footnotes, and **D2 diagrams**. Diagrams render through the
183
+ `d2` binary, which is not a Python dependency: without it a diagram degrades
184
+ to its labelled source instead of failing the build. Rendered SVG reaches the
185
+ page as a `data:` URI.
186
+
187
+ ### Distribution
188
+
189
+ - Published to PyPI as `hyper-markdown`; `pip install "hyper-markdown[mkdocs]"`
190
+ adds the site extra. Python 3.11 through 3.14.
191
+ - Two dependency ceilings, both deliberate and both carrying their reasons
192
+ inline in `pyproject.toml`: `mkdocs>=1.6,<2`, because "MkDocs 2.0" is a
193
+ ground-up rewrite with no plugin system — under it every card would vanish
194
+ from the build rather than merely render worse — and `pygments<2.20`, which
195
+ silently stops `pymdownx.superfences` from matching fences at all, turning
196
+ every code block on every page into inline text while the build stays green.
197
+
198
+ ### Known limitations
199
+
200
+ Deliberate, and tracked per proposal under `doc/proposals/HMD-NNNN/STATUS.md`:
201
+
202
+ - `hmd render --to markdown` is **one-way**. Erasure drops the embed boundary
203
+ and the provenance of every link; it is a build product, not an interchange
204
+ format.
205
+ - Indented code blocks are not masked, so a `[[link]]` inside one is seen as a
206
+ link. `admonition` and `footnotes` both overload the four-space indent.
207
+ - The scanner is a hand-written masker rather than a CommonMark block parser, so
208
+ divergence from CommonMark is possible and currently undetectable. A
209
+ conformance corpus is the planned way to expose it.
210
+ - Links out of the namespace root are ordinary markdown links and are not
211
+ checked by `hmd lint`. MkDocs reports them at `info`.
212
+ - There is no lint suppression syntax. A finding must be fixed or tolerated at
213
+ the call site.
214
+
215
+ Both specifications — the format and the site — are still `drafted`. Expect the
216
+ format to move before `1.0`.
217
+
218
+ [Unreleased]: https://github.com/ewiger/hypermarkdown/compare/v0.2.0...HEAD
219
+ [0.2.0]: https://github.com/ewiger/hypermarkdown/compare/v0.1.1...v0.2.0
220
+ [0.1.1]: https://github.com/ewiger/hypermarkdown/compare/v0.1.0...v0.1.1
221
+ [0.1.0]: https://github.com/ewiger/hypermarkdown/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yauhen Yakimovich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # What the source distribution carries beyond the package itself. README and
2
+ # LICENSE arrive on their own, named by `readme` and `license-files`; the
3
+ # changelog needs this line. All three are this tool's own files rather than
4
+ # links into the repository root — see the note in `pyproject.toml`.
5
+ #
6
+ # `examples/` is deliberately absent. `hmd lint --root examples/small` working
7
+ # straight out of an unpacked archive is the one property that would buy, and the
8
+ # fixture is a repository fixture that both implementations lint: it lives at the
9
+ # root, one copy, and a reader who wants to run it clones the repository, which
10
+ # is what the README tells them to do.
11
+ #
12
+ # The test suite is excluded for a related reason, and `prune` is required to do
13
+ # it: distutils' default sdist template sweeps in anything that looks like a test
14
+ # directory. Gates are run from a checkout, not from an sdist, and
15
+ # `tests/test_examples.py` lints `examples/small`, which is deliberately not in
16
+ # the archive.
17
+ include CHANGELOG.md
18
+ prune tests
@@ -0,0 +1,303 @@
1
+ Metadata-Version: 2.4
2
+ Name: hypermarkdown
3
+ Version: 0.2.0
4
+ Summary: A strict, machine-checkable markdown dialect for project knowledge bases.
5
+ Author: Yauhen Yakimovich
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://hypermarkdown.org/
8
+ Project-URL: Documentation, https://hypermarkdown.org/
9
+ Project-URL: Repository, https://github.com/ewiger/hypermarkdown
10
+ Project-URL: Changelog, https://github.com/ewiger/hypermarkdown/blob/main/tools/hmd/CHANGELOG.md
11
+ Project-URL: Issues, https://github.com/ewiger/hypermarkdown/issues
12
+ Keywords: markdown,wiki,knowledge-base,wikilinks,linter,mkdocs,documentation
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Documentation
23
+ Classifier: Topic :: Software Development :: Documentation
24
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
25
+ Requires-Python: >=3.11
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: typer<1,>=0.12
29
+ Requires-Dist: pyyaml<7,>=6
30
+ Requires-Dist: markdown<4,>=3.6
31
+ Requires-Dist: pymdown-extensions<12,>=10.21.2
32
+ Provides-Extra: mkdocs
33
+ Requires-Dist: mkdocs<2,>=1.6; extra == "mkdocs"
34
+ Requires-Dist: mkdocs-material<10,>=9; extra == "mkdocs"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest<10,>=8; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ <div align="center">
40
+
41
+ <img src="https://raw.githubusercontent.com/ewiger/hypermarkdown/main/doc/wiki/assets/logo.png" width="76" height="76" alt="">
42
+
43
+ # HyperMarkDown
44
+
45
+ **The Python implementation, and the `hmd` command**
46
+
47
+ [![PyPI](https://img.shields.io/pypi/v/hypermarkdown.svg)](https://pypi.org/project/hypermarkdown/)
48
+ [![Python versions](https://img.shields.io/pypi/pyversions/hypermarkdown.svg)](https://pypi.org/project/hypermarkdown/)
49
+ [![CI](https://github.com/ewiger/hypermarkdown/actions/workflows/ci.yml/badge.svg)](https://github.com/ewiger/hypermarkdown/actions/workflows/ci.yml)
50
+ [![Documentation](https://img.shields.io/badge/docs-hypermarkdown.org-ffb300)](https://hypermarkdown.org/)
51
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/ewiger/hypermarkdown/blob/main/tools/hmd/LICENSE)
52
+
53
+ </div>
54
+
55
+ HyperMarkDown (`.hmd`) is ordinary GitHub-flavored markdown plus the part HTML
56
+ had on its first day: a link that means something, a page that can be made out
57
+ of other pages, a document that is part of a web rather than a file in a folder.
58
+ Every `.md` file is already valid `.hmd`, so a tree is adopted one rename at a
59
+ time.
60
+
61
+ This distribution is the **canonical implementation** of that format. It ships
62
+ three things:
63
+
64
+ - **`hmd`**, a command line tool — lint a tree of cards, render one, dump the
65
+ link graph.
66
+ - **the library under it** — scanner, resolver, embed expander, and renderer,
67
+ importable as `hypermarkdown`.
68
+ - **a MkDocs plugin**, installed with the `mkdocs` extra, which builds a tree of
69
+ cards into a website.
70
+
71
+ There is a second implementation in TypeScript for editors. Where the two
72
+ disagree about a case the shared conformance corpus covers, **this one defines
73
+ the answer**.
74
+
75
+ The format itself — every construct, the resolution algorithm, the rule IDs — is
76
+ documented at **[hypermarkdown.org](https://hypermarkdown.org/)**. This page
77
+ is about the tool.
78
+
79
+ ## Install
80
+
81
+ ```bash
82
+ pip install HyperMarkDown # or: uv pip install HyperMarkDown
83
+ pip install "HyperMarkDown[mkdocs]" # with the site builder
84
+ ```
85
+
86
+ Python 3.11 through 3.14.
87
+
88
+ ## Sixty seconds
89
+
90
+ Point `hmd` at a tree of cards and lint it:
91
+
92
+ ```bash
93
+ hmd lint --root path/to/your/wiki
94
+ ```
95
+
96
+ ```text
97
+ glossary/index.hmd:11:3: warning[HMD001] [[idempotency]] does not resolve to a page
98
+
99
+ 0 error(s), 1 warning(s)
100
+ ```
101
+
102
+ Exit codes are pinned for CI: `0` clean, `1` diagnostics, `2` usage error. Add
103
+ `--strict` to fail on warnings, `--format json` for machine-readable output.
104
+
105
+ That output is
106
+ [`examples/small/`](https://github.com/ewiger/hypermarkdown/tree/main/examples/small),
107
+ a runnable wiki that exercises the spine walk, both import forms, `use`
108
+ inheritance, folder notes, and most of the syntax. It lints with zero errors and
109
+ exactly one deliberate warning — the red link above, showing what an unwritten
110
+ page looks like. The fixture travels in the repository rather than in the
111
+ distribution, so try it from a clone:
112
+
113
+ ```bash
114
+ git clone https://github.com/ewiger/hypermarkdown
115
+ hmd lint --root hypermarkdown/examples/small
116
+ ```
117
+
118
+ ## The card it is reading
119
+
120
+ ```markdown
121
+ ---
122
+ tags: [area/auth, status/accepted]
123
+ use: [autodiscovery]
124
+ import:
125
+ - from /shared import tokens as shared-tokens
126
+ - from /glossary import *
127
+ ---
128
+
129
+ # Login
130
+
131
+ - `[[tokens]]` → the sibling card, found on the spine
132
+ - `[[shared-tokens]]` → `shared/tokens.hmd`, a named import under an alias
133
+ - `[[token]]` → `glossary/token.hmd`, via the imported search path
134
+
135
+ See [[shared-tokens#Rotation|the rotation window]], and embed one block rather
136
+ than restating it:
137
+
138
+ ![[token#^definition]]
139
+ ```
140
+
141
+ Six constructs are what the format adds — wikilinks, aliased links, heading
142
+ links, block anchors, block references, and the three embed forms. Four
143
+ frontmatter keys mean something to this tool: `tags`, `use`, `import`, and `nav`.
144
+ Every other key is yours, and nothing will inspect it.
145
+
146
+ ## Commands
147
+
148
+ | Command | What it does |
149
+ | --- | --- |
150
+ | `hmd lint` | Parse, resolve, and report — `HMD001`–`HMD017`, text or JSON |
151
+ | `hmd render` | Expand embeds and rewrite links, to flat markdown or HTML |
152
+ | `hmd graph` | Dump the resolved link graph as JSON |
153
+ | `hmd info` | Show the resolved root and discovery policy |
154
+ | `hmd --version` | Print the installed version |
155
+
156
+ Each takes `--root` to override the namespace root, which otherwise comes from
157
+ the `wiki` setting in `.hmd/config.toml` (defaulting to `doc/wiki`). A `.hmd/`
158
+ directory doubles as the project root marker, so any subtree can be
159
+ self-contained.
160
+
161
+ `hmd render --to markdown` is **one-way** on purpose. Flattening a card erases
162
+ the embed boundary and the provenance of every link, which is right for
163
+ something you are shipping and wrong for something you are still editing.
164
+
165
+ ## The linter refuses to guess
166
+
167
+ A wiki that guesses is a wiki that quietly rots, because a link that silently
168
+ changes meaning is indistinguishable from one that did not:
169
+
170
+ ```text
171
+ specs/auth/login.hmd:14:5: error[HMD002] [[tokens]] matches 2 pages; qualify it
172
+ (candidates: shared/tokens.hmd, specs/auth/tokens.hmd)
173
+ ```
174
+
175
+ The distinction it draws is a compiler's. A link to a page you have not written
176
+ yet is a **warning** — writing forward is how a wiki grows, so it renders as a
177
+ red link instead of breaking the build. A malformed link or multiple
178
+ autodiscovery matches is an **error**. Ordered wildcard imports instead use
179
+ declaration precedence and report shadowing as HMD016.
180
+
181
+ Resolution runs in phases and stops at the first hit: explicit imports, then the
182
+ **spine** — this folder, then each folder above it, probed without recursion —
183
+ then imported search paths, then one sweep of the whole tree. A bare name
184
+ is a one-segment reference such as `[[tokens]]`; `[[shared/tokens]]` is an
185
+ unqualified path, not a bare name. The spine never searches sideways, but if
186
+ the earlier phases miss, autodiscovery may resolve a unique card elsewhere in
187
+ the namespace. Use `[[/shared/tokens]]` to make that dependency explicit.
188
+
189
+ ## Publish it: a book with a wiki in it
190
+
191
+ The `mkdocs` extra registers a plugin through the `mkdocs.plugins` entry point.
192
+ It registers `.hmd` files as pages, derives the nav from the namespace tree,
193
+ expands embeds, and rewrites every wikilink to a source-relative link that
194
+ MkDocs resolves and validates itself:
195
+
196
+ ```bash
197
+ pip install "HyperMarkDown[mkdocs]"
198
+ mkdocs build --strict # or: mkdocs serve
199
+ ```
200
+
201
+ The namespace does not have to be the whole site, and a wiki on its own is not
202
+ the interesting case — a **book with a wiki inside it** is. Point `docs_dir` at a
203
+ documentation tree and `root` at the part of it that is a namespace: the book is
204
+ hand-ordered markdown, the wiki is generated, and `hmd://wiki` says where the
205
+ generated section belongs in your nav.
206
+
207
+ ```yaml
208
+ # mkdocs.yml
209
+ docs_dir: doc
210
+ plugins:
211
+ - HyperMarkDown:
212
+ root: doc/wiki # only this subtree is a namespace
213
+ exclude_docs: |
214
+ *.hmd
215
+
216
+ nav:
217
+ - Home: index.md
218
+ - Introduction: public/introduction.md
219
+ - Wiki:
220
+ - Overview: wiki/README.md
221
+ - hmd://wiki # ← the derived section lands here
222
+ ```
223
+
224
+ An authored nav wins everywhere except where it names the wiki. Omit the
225
+ placeholder and your nav is used verbatim; omit `nav` entirely and the whole
226
+ thing is derived from the namespace tree. A card at `a/b.hmd` serves at `a/b/`,
227
+ and so does a folder note at `a/b/index.hmd` — two names for one page, one URL.
228
+ Unresolved links render red rather than failing the build, so a wiki stays
229
+ publishable while it is still being written.
230
+
231
+ Publication is opt-in: `nav: {visibility: public}` is what puts a card on the
232
+ site, it inherits down a subtree from a folder note, and the default is private.
233
+ The failure mode is a missing page, never an unintended one.
234
+
235
+ [hypermarkdown.org](https://hypermarkdown.org/) is that build, from this
236
+ repository's own `doc/` tree.
237
+
238
+ ## Math, diagrams, callouts
239
+
240
+ TeX mathematics, D2 diagrams, callouts, tables, task lists, footnotes,
241
+ strikethrough. None of these are HyperMarkDown's own — they are the tier the
242
+ wider markdown world settled on, and both `hmd render --to html` and the site
243
+ build assume them present.
244
+
245
+ Diagrams go through the [`d2`](https://d2lang.com) binary, which is deliberately
246
+ *not* a Python dependency: without it a diagram degrades to its own labelled
247
+ source rather than failing the build.
248
+
249
+ ## The library
250
+
251
+ ```python
252
+ from pathlib import Path
253
+
254
+ from hypermarkdown import Workspace, config
255
+ from hypermarkdown.lint import check
256
+
257
+ workspace = Workspace(config.load(root_override=Path("doc/wiki")))
258
+ for diagnostic in check(workspace):
259
+ print(diagnostic.path, diagnostic.rule, diagnostic.message)
260
+ ```
261
+
262
+ `parse`, `resolve`, `embed`, `urls`, and `lint` do not import MkDocs — the
263
+ plugin is one file, `mkdocs_plugin.py`, and swapping the renderer is that file
264
+ plus a `mkdocs.yml` rather than a re-specification. Every entry point that
265
+ ingests a document takes the document's *text*, not only a path, because the
266
+ language server this package will grow serves buffers that have never been
267
+ saved.
268
+
269
+ ## Versioning
270
+
271
+ Semantic, with the usual `0.x` caveat made explicit: **the format itself may
272
+ change between minor versions.** Until `1.0`, treat a minor bump as potentially
273
+ breaking for `.hmd` sources, not only for the Python API. What each release
274
+ changed, and what is deliberately not implemented, is in
275
+ [CHANGELOG.md](https://github.com/ewiger/hypermarkdown/blob/main/tools/hmd/CHANGELOG.md).
276
+
277
+ ## Development
278
+
279
+ This tool is `tools/hmd/` in the
280
+ [HyperMarkDown monorepo](https://github.com/ewiger/hypermarkdown), whose root
281
+ is a uv workspace:
282
+
283
+ ```bash
284
+ git clone https://github.com/ewiger/hypermarkdown
285
+ cd HyperMarkDown
286
+ uv sync --locked
287
+ uv run python -m pytest
288
+ ```
289
+
290
+ Build the wheel with `uv build --package HyperMarkDown` — the `--package` flag
291
+ is load-bearing, since a bare `uv build` at a workspace root produces an empty
292
+ `unknown-0.0.0` and exits zero.
293
+
294
+ - **[tools/hmd/DEVELOP.md](https://github.com/ewiger/hypermarkdown/blob/main/tools/hmd/DEVELOP.md)**
295
+ — this tool's own guide: the test loop, the gates, dependency policy,
296
+ packaging, and how a release is cut.
297
+ - **[DEVELOP.md](https://github.com/ewiger/hypermarkdown/blob/main/DEVELOP.md)**
298
+ — the repository's: the layout, how the documentation tree is organised, where
299
+ progress is tracked, and how the site is published.
300
+
301
+ ## License
302
+
303
+ MIT — see [LICENSE](https://github.com/ewiger/hypermarkdown/blob/main/tools/hmd/LICENSE).