hypermarkdown 0.4.0__tar.gz → 0.5.1__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 (37) hide show
  1. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/CHANGELOG.md +170 -2
  2. {hypermarkdown-0.4.0/src/hypermarkdown.egg-info → hypermarkdown-0.5.1}/PKG-INFO +16 -13
  3. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/README.md +15 -12
  4. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/pyproject.toml +5 -0
  5. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/__init__.py +1 -1
  6. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/cli.py +22 -9
  7. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/config.py +83 -44
  8. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/embed.py +70 -28
  9. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/frontmatter.py +79 -34
  10. hypermarkdown-0.5.1/src/hypermarkdown/frontmatter_position.py +231 -0
  11. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/graph.py +1 -1
  12. hypermarkdown-0.5.1/src/hypermarkdown/highlight.py +171 -0
  13. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/imports.py +11 -5
  14. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/lint/rules.py +106 -41
  15. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/mkdocs_plugin.py +61 -8
  16. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/model.py +48 -4
  17. hypermarkdown-0.5.1/src/hypermarkdown/parse.py +317 -0
  18. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/render/flat.py +11 -5
  19. hypermarkdown-0.5.1/src/hypermarkdown/render/ids.py +116 -0
  20. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/resolve.py +259 -59
  21. hypermarkdown-0.5.1/src/hypermarkdown/scan.py +334 -0
  22. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1/src/hypermarkdown.egg-info}/PKG-INFO +16 -13
  23. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown.egg-info/SOURCES.txt +4 -1
  24. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown.egg-info/entry_points.txt +3 -0
  25. hypermarkdown-0.4.0/src/hypermarkdown/parse.py +0 -211
  26. hypermarkdown-0.4.0/src/hypermarkdown/scan.py +0 -153
  27. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/LICENSE +0 -0
  28. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/MANIFEST.in +0 -0
  29. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/setup.cfg +0 -0
  30. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/diagram.py +0 -0
  31. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/lint/__init__.py +0 -0
  32. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/lint/report.py +0 -0
  33. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/render/__init__.py +0 -0
  34. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown/urls.py +0 -0
  35. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown.egg-info/dependency_links.txt +0 -0
  36. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown.egg-info/requires.txt +0 -0
  37. {hypermarkdown-0.4.0 → hypermarkdown-0.5.1}/src/hypermarkdown.egg-info/top_level.txt +0 -0
@@ -13,10 +13,166 @@ only for the Python API.
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [0.5.1] — 2026-11-25
17
+
18
+ ### Changed
19
+ - **A tree with no vault says "vault not found".** With no `.hmd/` in the
20
+ start directory or above it, and no `--root`, every command still exits 2,
21
+ and the error now reads the way git's does outside a repository. It starts
22
+ with "vault not found", names the directory searched from, and says to run
23
+ `hmd init` to initialize a vault or to pass `--root`.
24
+ - The README describes `location_path` and `hmd init --location-path`, where it
25
+ still described the `wiki` setting and the `--wiki` flag that 0.5.0 removed.
26
+
27
+ ## [0.5.0] — 2026-11-25
28
+
29
+ ### Added
30
+ - **A Pygments lexer for HyperMarkDown**, registered as `hmd` (alias
31
+ `hypermarkdown`, files `*.hmd`). A code sample fenced as ```` ```hmd ```` is
32
+ coloured as a card in MkDocs, in `hmd render --to html`, and anywhere else
33
+ Pygments is used: wikilinks, embeds, block anchors, and frontmatter are
34
+ distinct tokens, and a fenced block inside the sample is coloured as its own
35
+ language. Nothing has to be configured; Pygments finds the lexer through an
36
+ entry point.
37
+ - **An anchored repeat heading is not HMD011.** A heading whose key equals an
38
+ earlier one's is reported only when it carries no block anchor: the anchor
39
+ is the remedy, and makes the heading reachable.
40
+ - **An anchor on a heading embeds its section.** `![[card#^setup-linux]]`,
41
+ where `^setup-linux` ends a heading's line, expands that heading's whole
42
+ section, exactly as `![[card#Linux]]` does, instead of the heading line alone.
43
+ - **Setext headings are headings.** `Setup` over a line of `===` or `---` is
44
+ indexed and addressable like `# Setup`, at level 1 or 2, and ends an embedded
45
+ section the way an ATX heading does. A `---` after a blank line is still a
46
+ thematic break, a `---` frontmatter fence is still frontmatter, and no line
47
+ inside a fence or a comment is ever a heading.
48
+ - **HMD019**, an error: a file with a card extension that is not valid UTF-8,
49
+ reported at line 1, column 1. The file is then not a card — not scanned, not
50
+ a link target, not in the graph — where it used to stop the run with a
51
+ `UnicodeDecodeError`. `hmd lint` accepts such a file by path.
52
+
53
+ ### Changed
54
+ - **A reference that ends in `/` names a directory**, and resolves only to
55
+ its folder note, in every phase: `[[m/]]` reaches `m/index.hmd` even
56
+ where `m.hmd` claims the name, it never matches a named import, and the
57
+ recursive search considers only folder notes. `[[/]]` is the root's folder
58
+ note. A trailing `/` used to be dropped, so `[[m/]]` reached `m.hmd`.
59
+ - **A `location_path` that resolves into a nested vault is refused.** If a
60
+ directory between the vault and the namespace root carries its own `.hmd/`,
61
+ the vault is not loaded, and the error names `location_path` and the nested
62
+ vault.
63
+ - **Frontmatter diagnostics are reported where the problem is written**, no
64
+ longer all at line 1, column 1. A malformed value of a top-level key is at
65
+ the key; a problem inside `nav` at the key inside it; a malformed list entry,
66
+ such as a tag, a `use` entry, or an `import` statement, at the entry's first
67
+ character (after `- ` in a block list, its own first character in a flow
68
+ list); anything else at its nearest enclosing key. HMD015 and HMD003 about an
69
+ import are at its statement. Invalid YAML stays at the block's start.
70
+ - **A block anchor's position starts at its `^`**, not at the spaces or
71
+ tabs before it, so HMD006 points at the `^`. The blanks before the anchor
72
+ still go with it when a block is embedded or rendered.
73
+ - **Breaking: `wiki` is renamed `location_path`, and its default is `.`**, the
74
+ vault itself, where it was `doc/wiki`. A `.hmd/config.toml` that still sets
75
+ `wiki` is refused: the vault is not loaded, every command exits 2, and the
76
+ error names `wiki` and `location_path`. The MkDocs plugin stops the build
77
+ with the same message. `hmd init` takes `--location-path` in place of
78
+ `--wiki`, writes `location_path`, and with no flag makes no directory of its
79
+ own, since `.` is the project root; it prints the root on a `location:`
80
+ line. In the Python API, `config.init` takes `location_path=`,
81
+ `InitResult.wiki` is `InitResult.location`, and `DEFAULT_WIKI` is
82
+ `DEFAULT_LOCATION_PATH`.
83
+ - **A backslash anywhere in a wikilink is HMD010**: in its path, its
84
+ fragment, or its display. A backslash is never a path separator and
85
+ escapes nothing; one before `[[` is outside the link and changes nothing.
86
+ - **An `import` statement takes only spaces and tabs as whitespace**, between
87
+ its words and on either side of a comma, as the grammar's `WS` says; another
88
+ whitespace character there is HMD014. An imported name or alias is a
89
+ segment with no whitespace, so `:` and the reserved characters make it
90
+ HMD014 too.
91
+ - **A local name bound twice by imports is HMD015 even when both bindings
92
+ reach one card**, as in `from /shared import tokens` beside
93
+ `from ./shared import tokens`. It used to be reported only when the two
94
+ cards differed. The first binding stands.
95
+ - **Resolution follows the HyperMarkDown 0.1 algorithm**, checked by the
96
+ corpus's `resolve-*` cases, which are written from the specification rather
97
+ than generated. `.` and `..` belong to relative references alone, and are
98
+ normalised there: in an absolute or unqualified reference, such as
99
+ `[[/a/../b]]` or `[[a/../b]]`, either one is HMD010 and the reference is not
100
+ a link. A relative reference whose last component is `.` or `..` names that
101
+ directory, and reaches only its folder note. A path that leaves the namespace is HMD003 in every phase: one
102
+ that climbs above the root, enters a nested vault, or meets a symbolic link
103
+ out of the root; a path into a nested vault used to be HMD001. `[[./]]` and
104
+ `[[../]]` bind only the directory's folder note, the root's included. A
105
+ reference that writes an extension reaches a shadowed card in the
106
+ recursive search too, and a named import whose card has another extension
107
+ does not apply to it. In the recursive search a folder note matched by its
108
+ directory's name gives way to a card beside the directory. Every imported
109
+ search path is probed, and HMD016 names each other card once; one card
110
+ reached through two imports is not reported.
111
+ - **A symbolic link out of the namespace root is not a card.** Nothing
112
+ through one is loaded, where a linked file used to be read as a card
113
+ wherever it pointed.
114
+ - **An unclosed `[[` is text, not HMD010.** A `[[` with no `]]` after it on
115
+ its line, or with a `[` or `]` first, begins no link and is ordinary
116
+ Markdown, so a matrix in maths such as `$[[1,2],[3,4]]$` no longer reports an
117
+ error. A link that is closed but malformed is still HMD010.
118
+ - **`:` is reserved in a link target**, for namespace-qualified references
119
+ such as `[[namespace:article]]`. A target containing one is HMD010.
120
+ - **HMD012 is a warning.** A card beside a module's folder note of the same name
121
+ shadows the note, which stays reachable by its `index` path; like HMD018,
122
+ that is a shadow decided by a fixed order, not a content bug.
123
+ - **A heading fragment matches by key, not by slug** — the HyperMarkDown 0.1
124
+ rule. The key is the text in NFC, case-folded, with every character that is
125
+ not a letter, mark, or number turned into a space and the spaces collapsed.
126
+ `[[card#ошибка 404]]` reaches `# Ошибка 404!`, `[[card#STRASSE]]` reaches
127
+ `Straße`, and `[[card#Cafe]]` no longer reaches `Café`: accents are
128
+ significant, and letters of every script are kept, where the old slug
129
+ dropped them. A fragment matches the first heading with its key; the `_1`
130
+ suffix that reached a repeat is gone, so `[[card#setup_1]]` is now HMD004 and
131
+ a repeat is reached by a block anchor on its line.
132
+ - **HMD011 reports headings with the same key**, at each repeat, naming the
133
+ line of the heading a fragment reaches instead. It used to report a slug
134
+ collision and suggest the `_1` address.
135
+ - A heading's text is what a reader sees: `## The *fast* path` is
136
+ `The fast path` in the graph and in the derived nav, without its markup. The
137
+ graph's `slug` field is replaced by `key`.
138
+ - **HMD004 names the fragment as written**, `has no heading '#Cafe Menu'`,
139
+ rather than its slug.
140
+ - The MkDocs plugin and `hmd render` rewrite each heading link to the id
141
+ Python-Markdown's `toc` gives the heading the link matched — numbered `_1`
142
+ when an embedded heading of the same slug comes first on the page, `_1` for
143
+ a heading `toc` cannot slug at all, and the id set by `attr_list`'s `{#id}`.
144
+ A link whose fragment matched nothing links to the page.
145
+ - **Spans count UTF-8 bytes; columns count code points.** A span's offsets are
146
+ byte offsets from byte 0 of the card, and a line ends at `\n`, `\r\n`, or a
147
+ lone `\r`. Cards are read as bytes, so a `\r\n` file keeps its offsets, and a
148
+ block anchor on a `\r\n` line is found. A form feed or U+2028 no longer
149
+ starts a line.
150
+ - **A leading byte-order mark is ignored**, so frontmatter after one is
151
+ frontmatter.
152
+ - **Names compare in NFC.** A reference and a name on disk match whether
153
+ either is stored composed or decomposed, for cards and for import origins.
154
+ - **Only `.hmd/` marks a project root.** The `.git` fallback is gone: a tree
155
+ with no `.hmd/` above it is refused with a pointer to `hmd init` and
156
+ `--root`, where it used to load the repository root as a project.
157
+
158
+ ### Fixed
159
+ - **A key inside a one-line flow mapping is located.** A problem in
160
+ `nav: {order: x}` is reported at `order`, as the frontmatter position rules
161
+ say, no longer at `nav`.
162
+ - **The embed depth limit counts from zero, and HMD008 is reported at the
163
+ embed.** The starting card is depth zero and the limit is 16, so a chain of
164
+ exactly sixteen nested embeds is fine; it used to be reported. HMD008 is now
165
+ reported once, at the embed that would exceed the limit, where it used to
166
+ sit at line 1, column 1 of the card past it, once per chain.
167
+ - **An embed of a section no longer reports a false cycle.** The HMD007 check
168
+ followed every embed in the embedded card, where an embed of a heading or a
169
+ block expands that region only. One section of a card embedding another
170
+ section of the same card is not a cycle, and is no longer reported as one.
171
+
16
172
  ## [0.4.0] — 2026-11-15
17
173
 
18
174
  ### Added
19
- - **Markdown files are cards** ([HMD-0029](https://github.com/ewiger/hypermarkdown/blob/main/doc/proposals/HMD-0029/README.md)).
175
+ - **Markdown files are cards** ([HMD-0029](https://github.com/ewiger/hypermarkdown/blob/main/doc/proposals/HMD-0029/index.hmd)).
20
176
  A `.md` or `.markdown` file below the namespace root loads as a Markdown card:
21
177
  `[[guide]]` resolves to `guide.md`, `[[guide#Install]]` checks its headings,
22
178
  and `![[guide]]` transcludes its body. Its body is not scanned and not
@@ -36,6 +192,15 @@ only for the Python API.
36
192
  sweep is HMD002.
37
193
 
38
194
  ### Fixed
195
+ - **Block anchors are no longer rendered.** `hmd render` and the site printed
196
+ the trailing `^id` of every anchored block, including the tutorial paragraph
197
+ that says its anchor cannot be seen. Expansion now drops each anchor and its
198
+ leading whitespace, in a card's own text and in embedded text alike; an
199
+ anchor shown inside a fenced block stays.
200
+ - **An import alias is compared after NFC**, like every other name, so a
201
+ decomposed alias is reachable by a composed reference.
202
+ - **A code span does not cross a blank line in a `\r\n` or `\r` card.** The
203
+ test looked for two `\n` in a row and missed a blank line written with `\r`.
39
204
  - **A heading right below the frontmatter fence is a heading.** The fence was
40
205
  blanked together with its line breaks, so the first body line read as
41
206
  indented: `# Title` directly under `---` produced no heading, and a fragment
@@ -303,7 +468,10 @@ Deliberate, and tracked per proposal under `doc/proposals/HMD-NNNN/STATUS.md`:
303
468
  Both specifications — the format and the site — are still `drafted`. Expect the
304
469
  format to move before `1.0`.
305
470
 
306
- [Unreleased]: https://github.com/ewiger/hypermarkdown/compare/v0.3.1...HEAD
471
+ [Unreleased]: https://github.com/ewiger/hypermarkdown/compare/v0.5.1...HEAD
472
+ [0.5.1]: https://github.com/ewiger/hypermarkdown/compare/v0.5.0...v0.5.1
473
+ [0.5.0]: https://github.com/ewiger/hypermarkdown/compare/v0.4.0...v0.5.0
474
+ [0.4.0]: https://github.com/ewiger/hypermarkdown/compare/v0.3.1...v0.4.0
307
475
  [0.3.1]: https://github.com/ewiger/hypermarkdown/compare/v0.3.0...v0.3.1
308
476
  [0.3.0]: https://github.com/ewiger/hypermarkdown/compare/v0.2.0...v0.3.0
309
477
  [0.2.0]: https://github.com/ewiger/hypermarkdown/compare/v0.1.1...v0.2.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypermarkdown
3
- Version: 0.4.0
3
+ Version: 0.5.1
4
4
  Summary: A strict, machine-checkable markdown dialect for project knowledge bases.
5
5
  Author: Yauhen Yakimovich
6
6
  License-Expression: MIT
@@ -55,8 +55,8 @@ Dynamic: license-file
55
55
  HyperMarkDown (`.hmd`) is ordinary GitHub-flavored markdown plus the part HTML
56
56
  had on its first day: a link that means something, a page that can be made out
57
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.
58
+ Every `.md` file is already valid `.hmd`. Once a tree has a `.hmd/` directory
59
+ at its top, which `hmd init` creates, it can be adopted one file at a time.
60
60
 
61
61
  This distribution is the **canonical implementation** of that format. It ships
62
62
  three things:
@@ -148,28 +148,31 @@ Every other key is yours, and nothing will inspect it.
148
148
  | Command | What it does |
149
149
  | --- | --- |
150
150
  | `hmd init` | Write `.hmd/config.toml` and create the namespace root it names |
151
- | `hmd lint` | Parse, resolve, and report — `HMD001`–`HMD017`, text or JSON |
151
+ | `hmd lint` | Parse, resolve, and report — `HMD001`–`HMD019`, text or JSON |
152
152
  | `hmd render` | Expand embeds and rewrite links, to flat markdown or HTML |
153
153
  | `hmd graph` | Dump the resolved link graph as JSON |
154
154
  | `hmd info` | Show the resolved root and discovery policy |
155
155
  | `hmd --version` | Print the installed version |
156
156
 
157
- The `wiki` setting in `.hmd/config.toml` is the cards location: where inside
158
- the vault, the directory holding `.hmd/`, the cards start (`doc/wiki` by
159
- default, `.` for directly under the vault). The directory it names is the
160
- namespace root, and every command but `init` takes `--root` to override it. A
157
+ The `location_path` setting in `.hmd/config.toml` is the cards location: where
158
+ inside the vault, the directory holding `.hmd/`, the cards start. It defaults
159
+ to `.`, the vault itself, so an empty `.hmd/` directory is a complete vault. The
160
+ directory it names is the namespace root, and every command but `init` takes
161
+ `--root` to override it. A config that still sets `wiki`, the setting's name
162
+ before HyperMarkDown 0.1, is refused. A
161
163
  `.hmd/` directory doubles as the project root marker, so any subtree can be
162
- self-contained.
164
+ self-contained, and it is the only marker: a `.git` directory is not one, so a
165
+ tree with no `.hmd/` above it needs `--root`.
163
166
 
164
167
  ```bash
165
168
  hmd init # here; the namespace is named after the directory
166
- hmd init path/to/project --wiki notes --name shared
169
+ hmd init path/to/project --location-path notes --name shared
167
170
  ```
168
171
 
169
172
  `init` writes every setting at its default rather than leaving them implicit —
170
- the file is where you find out which keys exist. It creates the wiki root
171
- alongside the config, since a `wiki` setting pointing at nothing is an error
172
- every later command reports. It refuses to replace a config it did not write;
173
+ the file is where you find out which keys exist. It creates the directory
174
+ `--location-path` names alongside the config, since a `location_path` setting
175
+ that points at nothing is an error every later command reports. It refuses to replace a config it did not write;
173
176
  `--force` overrides that.
174
177
 
175
178
  The `[namespace]` section names this tree so another project can bind to it and
@@ -17,8 +17,8 @@
17
17
  HyperMarkDown (`.hmd`) is ordinary GitHub-flavored markdown plus the part HTML
18
18
  had on its first day: a link that means something, a page that can be made out
19
19
  of other pages, a document that is part of a web rather than a file in a folder.
20
- Every `.md` file is already valid `.hmd`, so a tree is adopted one rename at a
21
- time.
20
+ Every `.md` file is already valid `.hmd`. Once a tree has a `.hmd/` directory
21
+ at its top, which `hmd init` creates, it can be adopted one file at a time.
22
22
 
23
23
  This distribution is the **canonical implementation** of that format. It ships
24
24
  three things:
@@ -110,28 +110,31 @@ Every other key is yours, and nothing will inspect it.
110
110
  | Command | What it does |
111
111
  | --- | --- |
112
112
  | `hmd init` | Write `.hmd/config.toml` and create the namespace root it names |
113
- | `hmd lint` | Parse, resolve, and report — `HMD001`–`HMD017`, text or JSON |
113
+ | `hmd lint` | Parse, resolve, and report — `HMD001`–`HMD019`, text or JSON |
114
114
  | `hmd render` | Expand embeds and rewrite links, to flat markdown or HTML |
115
115
  | `hmd graph` | Dump the resolved link graph as JSON |
116
116
  | `hmd info` | Show the resolved root and discovery policy |
117
117
  | `hmd --version` | Print the installed version |
118
118
 
119
- The `wiki` setting in `.hmd/config.toml` is the cards location: where inside
120
- the vault, the directory holding `.hmd/`, the cards start (`doc/wiki` by
121
- default, `.` for directly under the vault). The directory it names is the
122
- namespace root, and every command but `init` takes `--root` to override it. A
119
+ The `location_path` setting in `.hmd/config.toml` is the cards location: where
120
+ inside the vault, the directory holding `.hmd/`, the cards start. It defaults
121
+ to `.`, the vault itself, so an empty `.hmd/` directory is a complete vault. The
122
+ directory it names is the namespace root, and every command but `init` takes
123
+ `--root` to override it. A config that still sets `wiki`, the setting's name
124
+ before HyperMarkDown 0.1, is refused. A
123
125
  `.hmd/` directory doubles as the project root marker, so any subtree can be
124
- self-contained.
126
+ self-contained, and it is the only marker: a `.git` directory is not one, so a
127
+ tree with no `.hmd/` above it needs `--root`.
125
128
 
126
129
  ```bash
127
130
  hmd init # here; the namespace is named after the directory
128
- hmd init path/to/project --wiki notes --name shared
131
+ hmd init path/to/project --location-path notes --name shared
129
132
  ```
130
133
 
131
134
  `init` writes every setting at its default rather than leaving them implicit —
132
- the file is where you find out which keys exist. It creates the wiki root
133
- alongside the config, since a `wiki` setting pointing at nothing is an error
134
- every later command reports. It refuses to replace a config it did not write;
135
+ the file is where you find out which keys exist. It creates the directory
136
+ `--location-path` names alongside the config, since a `location_path` setting
137
+ that points at nothing is an error every later command reports. It refuses to replace a config it did not write;
135
138
  `--force` overrides that.
136
139
 
137
140
  The `[namespace]` section names this tree so another project can bind to it and
@@ -140,6 +140,11 @@ hmd = "hypermarkdown.cli:main"
140
140
  hypermarkdown = "hypermarkdown.mkdocs_plugin:HyperMarkDownPlugin"
141
141
  hyper-markdown = "hypermarkdown.mkdocs_plugin:HyperMarkDownPlugin"
142
142
 
143
+ # A code sample marked ```hmd is coloured as a card. Pygments discovers lexers
144
+ # through this group, so nothing has to be configured where it is used.
145
+ [project.entry-points."pygments.lexers"]
146
+ hmd = "hypermarkdown.highlight:HmdLexer"
147
+
143
148
  [tool.setuptools.dynamic]
144
149
  version = { attr = "hypermarkdown.__version__" }
145
150
 
@@ -15,7 +15,7 @@ from .config import Config, ConfigError
15
15
  from .model import Diagnostic, Document, Link, Span
16
16
  from .resolve import Outcome, Resolution, Workspace
17
17
 
18
- __version__ = "0.4.0"
18
+ __version__ = "0.5.1"
19
19
 
20
20
  __all__ = [
21
21
  "Config",
@@ -32,7 +32,9 @@ EXIT_OK = 0
32
32
  EXIT_DIAGNOSTICS = 1
33
33
  EXIT_USAGE = 2
34
34
 
35
- RootOption = typer.Option(None, "--root", help="Namespace root (default: the `wiki` setting, or doc/wiki).")
35
+ RootOption = typer.Option(
36
+ None, "--root", help="Namespace root (default: the `location_path` setting, or the vault itself)."
37
+ )
36
38
  FormatOption = typer.Option("text", "--format", help="Output format: text or json.")
37
39
 
38
40
 
@@ -75,15 +77,22 @@ def _selected(workspace: Workspace, paths: list[Path] | None) -> list[Path] | No
75
77
  if not paths:
76
78
  return None
77
79
  selected: list[Path] = []
80
+ # A file that is not UTF-8 is not a card, but naming it is how its HMD019
81
+ # is asked for.
82
+ files = [*workspace.pages(), *workspace.undecodable]
78
83
  for raw in paths:
79
84
  candidate = raw.resolve()
80
85
  if candidate.is_dir():
81
- selected.extend(p for p in workspace.pages() if candidate in p.parents or candidate == p.parent)
86
+ selected.extend(p for p in files if candidate in p.parents or candidate == p.parent)
82
87
  elif card_suffix(candidate.name):
83
- if candidate not in workspace.documents:
88
+ if candidate in workspace.undecodable:
89
+ selected.append(candidate)
90
+ continue
91
+ card = workspace.card(candidate)
92
+ if card is None:
84
93
  typer.echo(f"hmd: not inside the namespace root: {raw}", err=True)
85
94
  raise typer.Exit(EXIT_USAGE)
86
- selected.append(candidate)
95
+ selected.append(card)
87
96
  else:
88
97
  typer.echo(f"hmd: not a card ({', '.join(CARD_SUFFIXES)}) or directory: {raw}", err=True)
89
98
  raise typer.Exit(EXIT_USAGE)
@@ -93,13 +102,17 @@ def _selected(workspace: Workspace, paths: list[Path] | None) -> list[Path] | No
93
102
  @app.command()
94
103
  def init(
95
104
  path: Optional[Path] = typer.Argument(None, help="Project root to initialise (default: the working directory)."),
96
- wiki: str = typer.Option(config_mod.DEFAULT_WIKI, "--wiki", help="Namespace root, relative to the project root."),
105
+ location_path: str = typer.Option(
106
+ config_mod.DEFAULT_LOCATION_PATH,
107
+ "--location-path",
108
+ help="Namespace root, relative to the project root (default: the project root itself).",
109
+ ),
97
110
  name: Optional[str] = typer.Option(None, "--name", help="Namespace name (default: the project directory's name)."),
98
111
  force: bool = typer.Option(False, "--force", help="Replace an existing .hmd/config.toml."),
99
112
  ) -> None:
100
113
  """Create `.hmd/config.toml` and the namespace root it names."""
101
114
  try:
102
- result = config_mod.init(path, wiki=wiki, name=name, force=force)
115
+ result = config_mod.init(path, location_path=location_path, name=name, force=force)
103
116
  except config_mod.ConfigError as exc:
104
117
  typer.echo(f"hmd: {exc}", err=True)
105
118
  raise typer.Exit(EXIT_USAGE)
@@ -113,7 +126,7 @@ def init(
113
126
 
114
127
  typer.echo(f"project: {result.project}{note(result.project)}")
115
128
  typer.echo(f"config: {result.config}{note(result.config)}")
116
- typer.echo(f"wiki: {result.wiki}{note(result.wiki)}")
129
+ typer.echo(f"location: {result.location}{note(result.location)}")
117
130
  typer.echo(
118
131
  f"namespace: {result.name} ({result.provider})"
119
132
  f"{' — from the directory name' if result.derived_name else ''}"
@@ -178,8 +191,8 @@ def render(
178
191
  raise typer.Exit(EXIT_USAGE)
179
192
 
180
193
  workspace = _workspace(root)
181
- target = path.resolve()
182
- if target not in workspace.documents:
194
+ target = workspace.card(path.resolve())
195
+ if target is None:
183
196
  typer.echo(f"hmd: not a page inside the namespace root: {path}", err=True)
184
197
  raise typer.Exit(EXIT_USAGE)
185
198