hypermarkdown 0.3.1__tar.gz → 0.5.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 (38) hide show
  1. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/CHANGELOG.md +203 -1
  2. {hypermarkdown-0.3.1/src/hypermarkdown.egg-info → hypermarkdown-0.5.0}/PKG-INFO +9 -6
  3. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/README.md +8 -5
  4. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/pyproject.toml +5 -0
  5. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/__init__.py +1 -1
  6. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/cli.py +25 -12
  7. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/config.py +84 -44
  8. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/embed.py +77 -30
  9. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/frontmatter.py +79 -34
  10. hypermarkdown-0.5.0/src/hypermarkdown/frontmatter_position.py +231 -0
  11. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/graph.py +1 -1
  12. hypermarkdown-0.5.0/src/hypermarkdown/highlight.py +171 -0
  13. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/imports.py +11 -5
  14. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/lint/rules.py +145 -43
  15. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/mkdocs_plugin.py +193 -30
  16. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/model.py +61 -5
  17. hypermarkdown-0.5.0/src/hypermarkdown/parse.py +317 -0
  18. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/render/flat.py +11 -5
  19. hypermarkdown-0.5.0/src/hypermarkdown/render/ids.py +116 -0
  20. hypermarkdown-0.5.0/src/hypermarkdown/resolve.py +610 -0
  21. hypermarkdown-0.5.0/src/hypermarkdown/scan.py +334 -0
  22. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0/src/hypermarkdown.egg-info}/PKG-INFO +9 -6
  23. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown.egg-info/SOURCES.txt +4 -1
  24. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown.egg-info/entry_points.txt +3 -0
  25. hypermarkdown-0.3.1/src/hypermarkdown/parse.py +0 -174
  26. hypermarkdown-0.3.1/src/hypermarkdown/resolve.py +0 -361
  27. hypermarkdown-0.3.1/src/hypermarkdown/scan.py +0 -153
  28. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/LICENSE +0 -0
  29. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/MANIFEST.in +0 -0
  30. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/setup.cfg +0 -0
  31. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/diagram.py +0 -0
  32. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/lint/__init__.py +0 -0
  33. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/lint/report.py +0 -0
  34. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/render/__init__.py +0 -0
  35. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown/urls.py +0 -0
  36. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown.egg-info/dependency_links.txt +0 -0
  37. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown.egg-info/requires.txt +0 -0
  38. {hypermarkdown-0.3.1 → hypermarkdown-0.5.0}/src/hypermarkdown.egg-info/top_level.txt +0 -0
@@ -13,6 +13,188 @@ only for the Python API.
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [0.5.0] — 2026-11-25
17
+
18
+ ### Added
19
+ - **A Pygments lexer for HyperMarkDown**, registered as `hmd` (alias
20
+ `hypermarkdown`, files `*.hmd`). A code sample fenced as ```` ```hmd ```` is
21
+ coloured as a card in MkDocs, in `hmd render --to html`, and anywhere else
22
+ Pygments is used: wikilinks, embeds, block anchors, and frontmatter are
23
+ distinct tokens, and a fenced block inside the sample is coloured as its own
24
+ language. Nothing has to be configured; Pygments finds the lexer through an
25
+ entry point.
26
+ - **An anchored repeat heading is not HMD011.** A heading whose key equals an
27
+ earlier one's is reported only when it carries no block anchor: the anchor
28
+ is the remedy, and makes the heading reachable.
29
+ - **An anchor on a heading embeds its section.** `![[card#^setup-linux]]`,
30
+ where `^setup-linux` ends a heading's line, expands that heading's whole
31
+ section, exactly as `![[card#Linux]]` does, instead of the heading line alone.
32
+ - **Setext headings are headings.** `Setup` over a line of `===` or `---` is
33
+ indexed and addressable like `# Setup`, at level 1 or 2, and ends an embedded
34
+ section the way an ATX heading does. A `---` after a blank line is still a
35
+ thematic break, a `---` frontmatter fence is still frontmatter, and no line
36
+ inside a fence or a comment is ever a heading.
37
+ - **HMD019**, an error: a file with a card extension that is not valid UTF-8,
38
+ reported at line 1, column 1. The file is then not a card — not scanned, not
39
+ a link target, not in the graph — where it used to stop the run with a
40
+ `UnicodeDecodeError`. `hmd lint` accepts such a file by path.
41
+
42
+ ### Changed
43
+ - **A reference that ends in `/` names a directory**, and resolves only to
44
+ its folder note, in every phase: `[[m/]]` reaches `m/index.hmd` even
45
+ where `m.hmd` claims the name, it never matches a named import, and the
46
+ recursive search considers only folder notes. `[[/]]` is the root's folder
47
+ note. A trailing `/` used to be dropped, so `[[m/]]` reached `m.hmd`.
48
+ - **A `location_path` that resolves into a nested vault is refused.** If a
49
+ directory between the vault and the namespace root carries its own `.hmd/`,
50
+ the vault is not loaded, and the error names `location_path` and the nested
51
+ vault.
52
+ - **Frontmatter diagnostics are reported where the problem is written**, no
53
+ longer all at line 1, column 1. A malformed value of a top-level key is at
54
+ the key; a problem inside `nav` at the key inside it; a malformed list entry,
55
+ such as a tag, a `use` entry, or an `import` statement, at the entry's first
56
+ character (after `- ` in a block list, its own first character in a flow
57
+ list); anything else at its nearest enclosing key. HMD015 and HMD003 about an
58
+ import are at its statement. Invalid YAML stays at the block's start.
59
+ - **A block anchor's position starts at its `^`**, not at the spaces or
60
+ tabs before it, so HMD006 points at the `^`. The blanks before the anchor
61
+ still go with it when a block is embedded or rendered.
62
+ - **Breaking: `wiki` is renamed `location_path`, and its default is `.`**, the
63
+ vault itself, where it was `doc/wiki`. A `.hmd/config.toml` that still sets
64
+ `wiki` is refused: the vault is not loaded, every command exits 2, and the
65
+ error names `wiki` and `location_path`. The MkDocs plugin stops the build
66
+ with the same message. `hmd init` takes `--location-path` in place of
67
+ `--wiki`, writes `location_path`, and with no flag makes no directory of its
68
+ own, since `.` is the project root; it prints the root on a `location:`
69
+ line. In the Python API, `config.init` takes `location_path=`,
70
+ `InitResult.wiki` is `InitResult.location`, and `DEFAULT_WIKI` is
71
+ `DEFAULT_LOCATION_PATH`.
72
+ - **A backslash anywhere in a wikilink is HMD010**: in its path, its
73
+ fragment, or its display. A backslash is never a path separator and
74
+ escapes nothing; one before `[[` is outside the link and changes nothing.
75
+ - **An `import` statement takes only spaces and tabs as whitespace**, between
76
+ its words and on either side of a comma, as the grammar's `WS` says; another
77
+ whitespace character there is HMD014. An imported name or alias is a
78
+ segment with no whitespace, so `:` and the reserved characters make it
79
+ HMD014 too.
80
+ - **A local name bound twice by imports is HMD015 even when both bindings
81
+ reach one card**, as in `from /shared import tokens` beside
82
+ `from ./shared import tokens`. It used to be reported only when the two
83
+ cards differed. The first binding stands.
84
+ - **Resolution follows the HyperMarkDown 0.1 algorithm**, checked by the
85
+ corpus's `resolve-*` cases, which are written from the specification rather
86
+ than generated. `.` and `..` belong to relative references alone, and are
87
+ normalised there: in an absolute or unqualified reference, such as
88
+ `[[/a/../b]]` or `[[a/../b]]`, either one is HMD010 and the reference is not
89
+ a link. A relative reference whose last component is `.` or `..` names that
90
+ directory, and reaches only its folder note. A path that leaves the namespace is HMD003 in every phase: one
91
+ that climbs above the root, enters a nested vault, or meets a symbolic link
92
+ out of the root; a path into a nested vault used to be HMD001. `[[./]]` and
93
+ `[[../]]` bind only the directory's folder note, the root's included. A
94
+ reference that writes an extension reaches a shadowed card in the
95
+ recursive search too, and a named import whose card has another extension
96
+ does not apply to it. In the recursive search a folder note matched by its
97
+ directory's name gives way to a card beside the directory. Every imported
98
+ search path is probed, and HMD016 names each other card once; one card
99
+ reached through two imports is not reported.
100
+ - **A symbolic link out of the namespace root is not a card.** Nothing
101
+ through one is loaded, where a linked file used to be read as a card
102
+ wherever it pointed.
103
+ - **An unclosed `[[` is text, not HMD010.** A `[[` with no `]]` after it on
104
+ its line, or with a `[` or `]` first, begins no link and is ordinary
105
+ Markdown, so a matrix in maths such as `$[[1,2],[3,4]]$` no longer reports an
106
+ error. A link that is closed but malformed is still HMD010.
107
+ - **`:` is reserved in a link target**, for namespace-qualified references
108
+ such as `[[namespace:article]]`. A target containing one is HMD010.
109
+ - **HMD012 is a warning.** A card beside a module's folder note of the same name
110
+ shadows the note, which stays reachable by its `index` path; like HMD018,
111
+ that is a shadow decided by a fixed order, not a content bug.
112
+ - **A heading fragment matches by key, not by slug** — the HyperMarkDown 0.1
113
+ rule. The key is the text in NFC, case-folded, with every character that is
114
+ not a letter, mark, or number turned into a space and the spaces collapsed.
115
+ `[[card#ошибка 404]]` reaches `# Ошибка 404!`, `[[card#STRASSE]]` reaches
116
+ `Straße`, and `[[card#Cafe]]` no longer reaches `Café`: accents are
117
+ significant, and letters of every script are kept, where the old slug
118
+ dropped them. A fragment matches the first heading with its key; the `_1`
119
+ suffix that reached a repeat is gone, so `[[card#setup_1]]` is now HMD004 and
120
+ a repeat is reached by a block anchor on its line.
121
+ - **HMD011 reports headings with the same key**, at each repeat, naming the
122
+ line of the heading a fragment reaches instead. It used to report a slug
123
+ collision and suggest the `_1` address.
124
+ - A heading's text is what a reader sees: `## The *fast* path` is
125
+ `The fast path` in the graph and in the derived nav, without its markup. The
126
+ graph's `slug` field is replaced by `key`.
127
+ - **HMD004 names the fragment as written**, `has no heading '#Cafe Menu'`,
128
+ rather than its slug.
129
+ - The MkDocs plugin and `hmd render` rewrite each heading link to the id
130
+ Python-Markdown's `toc` gives the heading the link matched — numbered `_1`
131
+ when an embedded heading of the same slug comes first on the page, `_1` for
132
+ a heading `toc` cannot slug at all, and the id set by `attr_list`'s `{#id}`.
133
+ A link whose fragment matched nothing links to the page.
134
+ - **Spans count UTF-8 bytes; columns count code points.** A span's offsets are
135
+ byte offsets from byte 0 of the card, and a line ends at `\n`, `\r\n`, or a
136
+ lone `\r`. Cards are read as bytes, so a `\r\n` file keeps its offsets, and a
137
+ block anchor on a `\r\n` line is found. A form feed or U+2028 no longer
138
+ starts a line.
139
+ - **A leading byte-order mark is ignored**, so frontmatter after one is
140
+ frontmatter.
141
+ - **Names compare in NFC.** A reference and a name on disk match whether
142
+ either is stored composed or decomposed, for cards and for import origins.
143
+ - **Only `.hmd/` marks a project root.** The `.git` fallback is gone: a tree
144
+ with no `.hmd/` above it is refused with a pointer to `hmd init` and
145
+ `--root`, where it used to load the repository root as a project.
146
+
147
+ ### Fixed
148
+ - **A key inside a one-line flow mapping is located.** A problem in
149
+ `nav: {order: x}` is reported at `order`, as the frontmatter position rules
150
+ say, no longer at `nav`.
151
+ - **The embed depth limit counts from zero, and HMD008 is reported at the
152
+ embed.** The starting card is depth zero and the limit is 16, so a chain of
153
+ exactly sixteen nested embeds is fine; it used to be reported. HMD008 is now
154
+ reported once, at the embed that would exceed the limit, where it used to
155
+ sit at line 1, column 1 of the card past it, once per chain.
156
+ - **An embed of a section no longer reports a false cycle.** The HMD007 check
157
+ followed every embed in the embedded card, where an embed of a heading or a
158
+ block expands that region only. One section of a card embedding another
159
+ section of the same card is not a cycle, and is no longer reported as one.
160
+
161
+ ## [0.4.0] — 2026-11-15
162
+
163
+ ### Added
164
+ - **Markdown files are cards** ([HMD-0029](https://github.com/ewiger/hypermarkdown/blob/main/doc/proposals/HMD-0029/README.md)).
165
+ A `.md` or `.markdown` file below the namespace root loads as a Markdown card:
166
+ `[[guide]]` resolves to `guide.md`, `[[guide#Install]]` checks its headings,
167
+ and `![[guide]]` transcludes its body. Its body is not scanned and not
168
+ linted, and its frontmatter is exposed but not interpreted. Binding tries
169
+ `.hmd`, `.md`, `.markdown`, then the folder note in the same order, and
170
+ `[[owl.md]]` binds only `owl.md`. `hmd lint` accepts `.md` and `.markdown`
171
+ paths.
172
+ - **HMD018**, a warning: a card shadows a card of the same name with a later
173
+ extension, as `owl.hmd` beside `owl.md`.
174
+ - The MkDocs plugin links a card to the page MkDocs builds from a Markdown
175
+ card, and never registers one itself; a Markdown card outside `docs_dir` is
176
+ a red link.
177
+
178
+ ### Changed
179
+ - A `.md` file inside the namespace is no longer invisible: a reference that
180
+ was HMD001 can resolve, and a bare name it shares with a card found by the
181
+ sweep is HMD002.
182
+
183
+ ### Fixed
184
+ - **Block anchors are no longer rendered.** `hmd render` and the site printed
185
+ the trailing `^id` of every anchored block, including the tutorial paragraph
186
+ that says its anchor cannot be seen. Expansion now drops each anchor and its
187
+ leading whitespace, in a card's own text and in embedded text alike; an
188
+ anchor shown inside a fenced block stays.
189
+ - **An import alias is compared after NFC**, like every other name, so a
190
+ decomposed alias is reachable by a composed reference.
191
+ - **A code span does not cross a blank line in a `\r\n` or `\r` card.** The
192
+ test looked for two `\n` in a row and missed a blank line written with `\r`.
193
+ - **A heading right below the frontmatter fence is a heading.** The fence was
194
+ blanked together with its line breaks, so the first body line read as
195
+ indented: `# Title` directly under `---` produced no heading, and a fragment
196
+ naming it was HMD004.
197
+
16
198
  ## [0.3.1] — 2026-11-13
17
199
 
18
200
  ### Fixed
@@ -26,6 +208,24 @@ only for the Python API.
26
208
  directory inside a nested vault is HMD015, the same as a missing directory.
27
209
  Linting the nested vault with `--root` set to it, or from a card inside it,
28
210
  is unchanged.
211
+ - **A folder note's ordinary Markdown links reach their targets on a built
212
+ site.** The MkDocs plugin registers `a/b/index.hmd` as the page `a/b.md`, one
213
+ directory above the file, and rewrote its wikilinks for that place but left
214
+ its relative Markdown links as written, so MkDocs resolved them from `a/`.
215
+ A link to a sibling card, such as `` [`Bool`](bool.hmd) ``, reached the site
216
+ as a link to a source file that is not served, and a link to a plain page or
217
+ an image pointed one directory too high. Every relative link in a folder
218
+ note is now resolved from the file's own directory and rewritten for the
219
+ registered page: inline links, images, and reference definitions. A card
220
+ that is not a folder note is unchanged. A site that worked around this by
221
+ writing a folder note's links against the parent directory has to write
222
+ them against the file's own directory again.
223
+
224
+ ### Changed
225
+ - **A Markdown link to a card is repointed in more spellings.** A link to a
226
+ `.hmd` file with a title, `[card](one.hmd "Title")`, and one given as a
227
+ reference definition, `[card]: one.hmd`, now reach the card's page. Before,
228
+ only the bare inline form did.
29
229
 
30
230
  ## [0.3.0] — 2026-09-14
31
231
 
@@ -257,7 +457,9 @@ Deliberate, and tracked per proposal under `doc/proposals/HMD-NNNN/STATUS.md`:
257
457
  Both specifications — the format and the site — are still `drafted`. Expect the
258
458
  format to move before `1.0`.
259
459
 
260
- [Unreleased]: https://github.com/ewiger/hypermarkdown/compare/v0.3.1...HEAD
460
+ [Unreleased]: https://github.com/ewiger/hypermarkdown/compare/v0.5.0...HEAD
461
+ [0.5.0]: https://github.com/ewiger/hypermarkdown/compare/v0.4.0...v0.5.0
462
+ [0.4.0]: https://github.com/ewiger/hypermarkdown/compare/v0.3.1...v0.4.0
261
463
  [0.3.1]: https://github.com/ewiger/hypermarkdown/compare/v0.3.0...v0.3.1
262
464
  [0.3.0]: https://github.com/ewiger/hypermarkdown/compare/v0.2.0...v0.3.0
263
465
  [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.3.1
3
+ Version: 0.5.0
4
4
  Summary: A strict, machine-checkable markdown dialect for project knowledge bases.
5
5
  Author: Yauhen Yakimovich
6
6
  License-Expression: MIT
@@ -148,16 +148,19 @@ 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
- Every command but `init` takes `--root` to override the namespace root, which
158
- otherwise comes from the `wiki` setting in `.hmd/config.toml` (defaulting to
159
- `doc/wiki`). A `.hmd/` directory doubles as the project root marker, so any
160
- subtree can be self-contained.
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
161
+ `.hmd/` directory doubles as the project root marker, so any subtree can be
162
+ self-contained, and it is the only marker: a `.git` directory is not one, so a
163
+ tree with no `.hmd/` above it needs `--root`.
161
164
 
162
165
  ```bash
163
166
  hmd init # here; the namespace is named after the directory
@@ -110,16 +110,19 @@ 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
- Every command but `init` takes `--root` to override the namespace root, which
120
- otherwise comes from the `wiki` setting in `.hmd/config.toml` (defaulting to
121
- `doc/wiki`). A `.hmd/` directory doubles as the project root marker, so any
122
- subtree can be self-contained.
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
123
+ `.hmd/` directory doubles as the project root marker, so any subtree can be
124
+ self-contained, and it is the only marker: a `.git` directory is not one, so a
125
+ tree with no `.hmd/` above it needs `--root`.
123
126
 
124
127
  ```bash
125
128
  hmd init # here; the namespace is named after the directory
@@ -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.3.1"
18
+ __version__ = "0.5.0"
19
19
 
20
20
  __all__ = [
21
21
  "Config",
@@ -20,7 +20,7 @@ from . import graph as graph_mod
20
20
  from .lint import check, format_json, format_text, summarize
21
21
  from .model import Diagnostic
22
22
  from .render import flat
23
- from .resolve import SUFFIX, Workspace
23
+ from .resolve import CARD_SUFFIXES, Workspace, card_suffix
24
24
 
25
25
  app = typer.Typer(
26
26
  add_completion=False,
@@ -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,17 +77,24 @@ 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)
82
- elif candidate.suffix == SUFFIX:
83
- if candidate not in workspace.documents:
86
+ selected.extend(p for p in files if candidate in p.parents or candidate == p.parent)
87
+ elif card_suffix(candidate.name):
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
- typer.echo(f"hmd: not a {SUFFIX} file or directory: {raw}", err=True)
97
+ typer.echo(f"hmd: not a card ({', '.join(CARD_SUFFIXES)}) or directory: {raw}", err=True)
89
98
  raise typer.Exit(EXIT_USAGE)
90
99
  return sorted(set(selected))
91
100
 
@@ -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