mdrefine 0.2.0-rc.2 → 0.2.0
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.
- package/CHANGELOG.md +577 -0
- package/CODE_OF_CONDUCT.md +30 -0
- package/CONTRIBUTING.md +189 -16
- package/README.md +100 -154
- package/SECURITY.md +15 -13
- package/config.schema.json +91 -0
- package/dist/cli/diff.d.ts +10 -0
- package/dist/cli/diff.js +247 -0
- package/dist/cli/diff.js.map +1 -0
- package/dist/cli/main.js +270 -150
- package/dist/cli/main.js.map +1 -1
- package/dist/config/load.js +67 -6
- package/dist/config/load.js.map +1 -1
- package/dist/config/problems.d.ts +7 -0
- package/dist/config/problems.js +208 -0
- package/dist/config/problems.js.map +1 -0
- package/dist/config/resolve.d.ts +42 -109
- package/dist/config/resolve.js +193 -52
- package/dist/config/resolve.js.map +1 -1
- package/dist/core/directives.d.ts +7 -0
- package/dist/core/directives.js +25 -13
- package/dist/core/directives.js.map +1 -1
- package/dist/core/engine.d.ts +42 -4
- package/dist/core/engine.js +518 -79
- package/dist/core/engine.js.map +1 -1
- package/dist/core/frozen.d.ts +6 -0
- package/dist/core/frozen.js +15 -0
- package/dist/core/frozen.js.map +1 -0
- package/dist/core/scope.d.ts +30 -0
- package/dist/core/scope.js +122 -0
- package/dist/core/scope.js.map +1 -0
- package/dist/core/types.d.ts +202 -23
- package/dist/core/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +3 -0
- package/dist/node.js +4 -0
- package/dist/node.js.map +1 -0
- package/dist/rules/blocks.d.ts +34 -0
- package/dist/rules/blocks.js +550 -0
- package/dist/rules/blocks.js.map +1 -0
- package/dist/rules/content.d.ts +2 -0
- package/dist/rules/content.js +85 -0
- package/dist/rules/content.js.map +1 -0
- package/dist/rules/dialects.js +10 -6
- package/dist/rules/dialects.js.map +1 -1
- package/dist/rules/links.js +302 -6
- package/dist/rules/links.js.map +1 -1
- package/dist/rules/lists.d.ts +2 -0
- package/dist/rules/lists.js +924 -0
- package/dist/rules/lists.js.map +1 -0
- package/dist/rules/structure.js +127 -1
- package/dist/rules/structure.js.map +1 -1
- package/dist/rules/style.d.ts +8 -2
- package/dist/rules/style.js +1137 -165
- package/dist/rules/style.js.map +1 -1
- package/dist/syntax/block-identifier.d.ts +18 -0
- package/dist/syntax/block-identifier.js +24 -0
- package/dist/syntax/block-identifier.js.map +1 -0
- package/dist/syntax/obsidian.d.ts +29 -11
- package/dist/syntax/obsidian.js +9 -10
- package/dist/syntax/obsidian.js.map +1 -1
- package/dist/syntax/parse.d.ts +87 -3
- package/dist/syntax/parse.js +247 -19
- package/dist/syntax/parse.js.map +1 -1
- package/dist/workspace/access.d.ts +12 -3
- package/dist/workspace/access.js +33 -5
- package/dist/workspace/access.js.map +1 -1
- package/dist/workspace/discovery.d.ts +85 -0
- package/dist/workspace/discovery.js +155 -0
- package/dist/workspace/discovery.js.map +1 -0
- package/dist/workspace/encoding.d.ts +24 -0
- package/dist/workspace/encoding.js +113 -0
- package/dist/workspace/encoding.js.map +1 -0
- package/dist/workspace/files.d.ts +92 -6
- package/dist/workspace/files.js +715 -59
- package/dist/workspace/files.js.map +1 -1
- package/dist/workspace/git.d.ts +54 -0
- package/dist/workspace/git.js +198 -0
- package/dist/workspace/git.js.map +1 -0
- package/dist/workspace/index.d.ts +58 -3
- package/dist/workspace/index.js +136 -37
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/selection.d.ts +2 -2
- package/dist/workspace/selection.js +3 -3
- package/dist/workspace/selection.js.map +1 -1
- package/dist/workspace/slug.js +8 -1
- package/dist/workspace/slug.js.map +1 -1
- package/dist/workspace/vault.js +3 -1
- package/dist/workspace/vault.js.map +1 -1
- package/docs/api.md +239 -0
- package/docs/benchmarks.md +140 -200
- package/docs/changelog.md +1 -0
- package/docs/cli.md +281 -89
- package/docs/configuration.md +193 -480
- package/docs/design.md +163 -284
- package/docs/dialects.md +169 -0
- package/docs/examples.md +151 -109
- package/docs/index.md +21 -37
- package/docs/integrations.md +144 -0
- package/docs/obsidian.md +91 -115
- package/docs/plugins.md +147 -212
- package/docs/quick-start.md +68 -74
- package/docs/rules.md +1237 -0
- package/docs/versions.md +56 -0
- package/examples/README.md +17 -14
- package/examples/automation/summarize-report.mjs +5 -2
- package/examples/library/lint-folder.mjs +5 -4
- package/examples/library/lint-workspace.mjs +32 -0
- package/examples/plugin/notes/release-checklist.md +2 -2
- package/examples/plugin/rules.mjs +17 -23
- package/examples/workspaces/obsidian-vault/after/mdtools.config.jsonc +2 -2
- package/examples/workspaces/obsidian-vault/before/mdtools.config.jsonc +2 -2
- package/examples/workspaces/repository-docs/after/README.md +2 -2
- package/examples/workspaces/repository-docs/after/mdtools.config.jsonc +0 -2
- package/examples/workspaces/repository-docs/before/README.md +2 -2
- package/examples/workspaces/repository-docs/before/docs/guide.md +7 -7
- package/examples/workspaces/repository-docs/before/docs/reference.md +3 -1
- package/examples/workspaces/repository-docs/before/mdtools.config.jsonc +0 -2
- package/package.json +38 -12
- package/docs/contributing.md +0 -218
- package/docs/releases/0.1.0-beta.1.md +0 -39
- package/docs/releases/0.1.0-beta.2.md +0 -83
- package/docs/releases/0.1.0-beta.3.md +0 -61
- package/docs/releases/0.1.0-beta.4.md +0 -50
- package/docs/releases/0.1.0-rc.1.md +0 -99
- package/docs/releases/0.2.0-rc.1.md +0 -141
- package/docs/releases/0.2.0-rc.2.md +0 -225
- package/docs/releases.md +0 -144
- package/docs/testing.md +0 -93
package/CONTRIBUTING.md
CHANGED
|
@@ -1,18 +1,191 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
Issues and pull requests from people and from agents are welcome. The project is
|
|
4
|
+
maintained by AI agents, as the [README](README.md#status) says, and its owner
|
|
5
|
+
follows it through issue and pull request descriptions rather than code, so
|
|
6
|
+
write them for a reader who has not seen the code. Agents maintaining the
|
|
7
|
+
repository also follow [AGENTS.md](AGENTS.md). Everyone follows the [code of
|
|
8
|
+
conduct](CODE_OF_CONDUCT.md).
|
|
9
|
+
|
|
10
|
+
## Report a defect
|
|
11
|
+
|
|
12
|
+
Search the open and closed
|
|
13
|
+
[issues](https://github.com/viell-dev/slop-markdown-tools/issues) first, then
|
|
14
|
+
open one with the bug form's details:
|
|
15
|
+
|
|
16
|
+
- the mdrefine version, the Node.js version, the operating system, and the exact
|
|
17
|
+
command;
|
|
18
|
+
- the dialect in effect, and the configuration, with any plugins;
|
|
19
|
+
- a minimal Markdown input, synthetic or public;
|
|
20
|
+
- the actual output or diagnostics, with the `--json` report when you have one;
|
|
21
|
+
- the expected output, and how the rendering differs.
|
|
22
|
+
|
|
23
|
+
A screenshot can show a rendering difference, but only the Markdown source
|
|
24
|
+
reproduces it. Remove private content from every example. Agents should open an
|
|
25
|
+
issue only when their operator has authorized publishing it. Report
|
|
26
|
+
vulnerabilities privately, as [SECURITY.md](SECURITY.md) describes.
|
|
27
|
+
|
|
28
|
+
## Set up
|
|
29
|
+
|
|
30
|
+
Development needs Node.js 22.22.2 or newer, or 24.15.0 or newer (24 is
|
|
31
|
+
preferred), and npm 10 or newer.
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
git clone https://github.com/viell-dev/slop-markdown-tools.git
|
|
35
|
+
cd slop-markdown-tools
|
|
36
|
+
npm ci
|
|
37
|
+
npm run build
|
|
38
|
+
node dist/cli/main.js --help
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
In a checkout, `node dist/cli/main.js` takes the place of `npx mdtools`. A built
|
|
42
|
+
checkout can also be installed into another project as a local dependency.
|
|
43
|
+
|
|
44
|
+
## Checks
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm run check
|
|
48
|
+
npm run test:package
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`check` runs the TypeScript checks, ESLint, Prettier on everything but Markdown,
|
|
52
|
+
the tool's own lint and format check of the Markdown, the documentation site's
|
|
53
|
+
build, and both test suites. `test:package` packs the package, installs it into
|
|
54
|
+
a temporary project with npm and again with pnpm, whose strict layout lets a
|
|
55
|
+
package use only the dependencies it declares, and runs the installed command,
|
|
56
|
+
the library through `import` and `require()`, a shipped example, and TypeScript
|
|
57
|
+
consumers of the published types. npm fetches the pinned pnpm into the
|
|
58
|
+
repository's cache, and both installations can need access to the npm registry.
|
|
59
|
+
|
|
60
|
+
The configuration's JSON Schema is `src/config/resolve.ts`'s `configSchema`.
|
|
61
|
+
`npm run schema` writes it to `config.schema.json`, which the package ships and
|
|
62
|
+
the site serves; a test fails when the two differ.
|
|
63
|
+
|
|
64
|
+
GitHub Actions runs `check` and a dependency audit on Linux with Node.js 24, the
|
|
65
|
+
build and tests on Linux with Node.js 22.12.0, the lowest version the package
|
|
66
|
+
supports, on Windows with Node.js 24, and on Linux with Node.js 26, and
|
|
67
|
+
`test:package` on all four. `main` requires the first three. The Node.js 26 job
|
|
68
|
+
is not required, so that a defect only the newest Node.js shows does not block
|
|
69
|
+
unrelated merges; its failures get an issue. Windows covers file paths, access
|
|
70
|
+
control lists, junctions, and the installed command; macOS is not a routine
|
|
71
|
+
target.
|
|
72
|
+
|
|
73
|
+
## Dependencies
|
|
74
|
+
|
|
75
|
+
Every dependency is pinned to an exact version, and the lockfile is committed.
|
|
76
|
+
For the runtime dependencies this is deliberate: a formatter's output should
|
|
77
|
+
depend only on its own version, and an update of the parser can change it, so a
|
|
78
|
+
dependency update reaches users only in a release of mdrefine whose tests passed
|
|
79
|
+
with it. `@types/node` stays on the major version of the lowest supported
|
|
80
|
+
Node.js version, 22, so that the type check rejects interfaces that Node.js 22
|
|
81
|
+
does not have; the CI job on 22.12.0 catches those that later 22.x releases
|
|
82
|
+
added.
|
|
83
|
+
|
|
84
|
+
Dependabot proposes updates weekly, the development dependencies as one group,
|
|
85
|
+
and only versions published at least seven days earlier, which leaves time for a
|
|
86
|
+
broken or compromised release to be found. Security updates are not delayed.
|
|
87
|
+
|
|
88
|
+
## Tests
|
|
89
|
+
|
|
90
|
+
| Command | Runs |
|
|
91
|
+
| -------------------------- | ------------------------------------- |
|
|
92
|
+
| `npm test` | The build, then both suites |
|
|
93
|
+
| `npm run test:unit` | The unit suite; needs no build |
|
|
94
|
+
| `npm run test:integration` | The build, then the integration suite |
|
|
95
|
+
|
|
96
|
+
The suites run one after the other, because the processes that integration tests
|
|
97
|
+
start would make the time limits of a few unit tests unreliable.
|
|
98
|
+
|
|
99
|
+
`tests/unit/` imports from `src/` and touches neither files nor other processes.
|
|
100
|
+
A defect in how a rule reads or rewrites Markdown belongs here, as the smallest
|
|
101
|
+
synthetic document that shows it, usually checked together with the contracts of
|
|
102
|
+
every formatting change: formatting the output again changes nothing, the parsed
|
|
103
|
+
meaning is unchanged, and disabling the rule leaves the source as written. Rules
|
|
104
|
+
are tested in `rules.test.ts`, list rules in `lists.test.ts`, code fences,
|
|
105
|
+
thematic breaks, and blank space in `blocks.test.ts`, problem rules in
|
|
106
|
+
`references.test.ts`, `structure.test.ts`, and `content.test.ts`, wrapping in
|
|
107
|
+
`wrap.test.ts` and `callout-wrap.test.ts`, links in `links.test.ts`, dollar math
|
|
108
|
+
in `math.test.ts` against the renderers' output recorded in `math-renderers.ts`,
|
|
109
|
+
the engine, configuration, and plugins in `engine.test.ts`, and the diff that
|
|
110
|
+
`format` prints in `diff.test.ts`.
|
|
111
|
+
|
|
112
|
+
`tests/integration/` runs the built CLI as a child process in temporary
|
|
113
|
+
workspaces, and runs `examples/` and `benchmarks/` as they are, without the
|
|
114
|
+
machine's user and system Git settings, which would change what Git ignores. A
|
|
115
|
+
defect in what the tool selects, prints, writes, or how it exits belongs here:
|
|
116
|
+
`cli.test.ts` for commands and options, `selection.test.ts` for which files a
|
|
117
|
+
run selects, compared with Git's own decisions, `workflows.test.ts` for whole
|
|
118
|
+
tasks, `node.test.ts` for `mdrefine/node`, and `examples.test.ts` and
|
|
119
|
+
`docs.test.ts` for the examples and documentation. `support.ts` holds the
|
|
120
|
+
helpers: `fixture()` writes a temporary workspace, `run()` starts the CLI,
|
|
121
|
+
`restrict()` and `denyRead()` take away read permission on Unix and on Windows,
|
|
122
|
+
`denyWrite()` takes away write permission on Windows, `windowsTool()` runs a
|
|
123
|
+
program of Windows such as `icacls.exe`, and `linkDirectory()` links a
|
|
124
|
+
directory, as a junction on Windows. Tests that need Unix permission modes are
|
|
125
|
+
skipped on Windows and for the root user, and one that links a file needs
|
|
126
|
+
`canSymlink`.
|
|
127
|
+
|
|
128
|
+
A test marked `it.fails` reproduces a confirmed defect that is not fixed yet and
|
|
129
|
+
names its issue; remove the marker with the fix. A few unit tests guard against
|
|
130
|
+
algorithms whose cost grows faster than their input; add one with the fix for
|
|
131
|
+
such a defect.
|
|
132
|
+
|
|
133
|
+
## Benchmarks
|
|
134
|
+
|
|
135
|
+
`npm run benchmark` times the tool on generated documents; it takes a few
|
|
136
|
+
minutes, is not part of `check`, and never fails on a slow result. Run it before
|
|
137
|
+
and after a change that could affect speed, on the same idle machine, and
|
|
138
|
+
compare as the [benchmarks
|
|
139
|
+
page](https://viell-dev.github.io/slop-markdown-tools/benchmarks.html#run-it-and-compare)
|
|
140
|
+
explains. The reference results on that page come from the Benchmark workflow on
|
|
141
|
+
a GitHub-hosted runner, which runs for pull requests that change `benchmarks/`
|
|
142
|
+
and on request (`gh workflow run benchmark.yml --ref <branch>`); replace them
|
|
143
|
+
only from such a run.
|
|
144
|
+
|
|
145
|
+
## Documentation
|
|
146
|
+
|
|
147
|
+
The site's source is `docs/`, built by VitePress. The tool formats and lints the
|
|
148
|
+
repository's own Markdown at 80 columns; Prettier formats everything else and
|
|
149
|
+
leaves Markdown alone. The fixtures in `tests/fixtures/` and the documents of
|
|
150
|
+
`examples/workspaces/` and `examples/plugin/notes/` are left unformatted on
|
|
151
|
+
purpose.
|
|
152
|
+
|
|
153
|
+
```sh
|
|
154
|
+
npm run format:docs # format the Markdown
|
|
155
|
+
npm run format:docs:check # lint it and check its format without writing
|
|
156
|
+
npm run format # both formatters
|
|
157
|
+
npm run docs:dev # preview the site while editing
|
|
158
|
+
npm run docs:build && npm run docs:preview
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The preview's address includes the `/slop-markdown-tools/` base path. The site
|
|
162
|
+
build fails on a link to a page that does not exist, and the tool's lint fails
|
|
163
|
+
on a heading fragment that does not. The integration tests compare the examples
|
|
164
|
+
page, the rule index, and the benchmark page with the code, so update them with
|
|
165
|
+
the behavior they describe. CI builds the site for every pull request. The site
|
|
166
|
+
describes the newest stable release: the Pages workflow deploys it from that
|
|
167
|
+
release's tag after the Release workflow publishes it, as
|
|
168
|
+
[RELEASING.md](RELEASING.md) describes. GitHub Pages must use GitHub Actions as
|
|
169
|
+
its source.
|
|
170
|
+
|
|
171
|
+
## Pull requests
|
|
172
|
+
|
|
173
|
+
Every change to `main` goes through a pull request with passing CI, and is
|
|
174
|
+
merged with a merge commit; `main` requires three of the CI checks and resolved
|
|
175
|
+
review threads, but no approval from a second account. Contributions are made
|
|
176
|
+
under the MIT license. Keep discussion respectful and about reproducible
|
|
177
|
+
behavior; harassment and disclosure of private data are not acceptable.
|
|
178
|
+
|
|
179
|
+
- Describe the problem, the resulting behavior, and the decisions made and why,
|
|
180
|
+
for a reader who will not read the diff. Link the issue.
|
|
181
|
+
- A change to formatting needs tests of the expected output, of formatting
|
|
182
|
+
twice, and of preserved meaning; a defect that changes rendering needs a
|
|
183
|
+
minimal regression example.
|
|
184
|
+
- Update every document, example, and test that describes what you changed, in
|
|
185
|
+
the same pull request, and add the change to the `Unreleased` section of
|
|
186
|
+
[CHANGELOG.md](CHANGELOG.md).
|
|
187
|
+
- A change to the command line, the configuration, the JSON report, or the
|
|
188
|
+
library that is not a defect fix waits for the next minor release; see the
|
|
189
|
+
[versioning
|
|
190
|
+
policy](https://viell-dev.github.io/slop-markdown-tools/versions.html).
|
|
191
|
+
- Keep changes scoped, and state remaining limits.
|
package/README.md
CHANGED
|
@@ -1,173 +1,119 @@
|
|
|
1
|
-
# mdrefine
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
[examples](https://viell-dev.github.io/slop-markdown-tools/examples.html) live
|
|
40
|
-
in `examples/` and ship with the package: starting configurations, workspaces
|
|
41
|
-
before and after formatting, a plugin, and library scripts.
|
|
42
|
-
|
|
43
|
-
## Getting started
|
|
44
|
-
|
|
45
|
-
The CLI requires Node.js 22.12 or newer. The npm package is `mdrefine`; the
|
|
46
|
-
executable is `mdtools`. To install the release candidate in your document
|
|
47
|
-
workspace:
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
npm install --save-dev --save-exact mdrefine@0.2.0-rc.2
|
|
51
|
-
npx --no-install mdtools --help
|
|
1
|
+
# mdrefine
|
|
2
|
+
|
|
3
|
+
Lint and format Markdown for GitHub, Forgejo, Gitea, Obsidian, or any CommonMark
|
|
4
|
+
renderer, with one configuration for both.
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/mdrefine)
|
|
7
|
+
[](https://github.com/viell-dev/slop-markdown-tools/actions/workflows/ci.yml)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
mdrefine is meant to replace a general-purpose linter and formatter, such as
|
|
11
|
+
markdownlint and Prettier, for Markdown. It does not cover all of their checks
|
|
12
|
+
yet; [the
|
|
13
|
+
comparison](https://viell-dev.github.io/slop-markdown-tools/integrations.html#coming-from-prettier-or-markdownlint)
|
|
14
|
+
shows which have a rule.
|
|
15
|
+
|
|
16
|
+
- **One configuration for lint and format.** Style rules report in `lint` and
|
|
17
|
+
fix in `format`; problem rules report what has no single correct repair.
|
|
18
|
+
- **Changes only what its rules target.** Everything else stays byte for byte as
|
|
19
|
+
written, and an edit that would change a document's parsed meaning is refused.
|
|
20
|
+
- **Dialect-aware.** CommonMark, GitHub, Forgejo and Codeberg, Gitea, and
|
|
21
|
+
Obsidian: tables, math, wikilinks, and callouts are read as each renderer
|
|
22
|
+
reads them.
|
|
23
|
+
- **Checks local links** and their heading and block fragments, with each
|
|
24
|
+
renderer's anchors.
|
|
25
|
+
- **Extensible.** Plugins add rules, presets, and syntax, and a library runs the
|
|
26
|
+
same engine without the command line.
|
|
27
|
+
|
|
28
|
+
## Example
|
|
29
|
+
|
|
30
|
+
```markdown
|
|
31
|
+
Weather Station collects *temperature*, *humidity*, and *pressure* readings from a sensor board.
|
|
32
|
+
|
|
33
|
+
> [!note]
|
|
34
|
+
> Use matching firmware and page versions, or the page shows __no data__.
|
|
35
|
+
|
|
36
|
+
| Sensor | Unit |
|
|
37
|
+
|---|---|
|
|
38
|
+
| Temperature | °C |
|
|
52
39
|
```
|
|
53
40
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
for registry availability, preparation, and authentication requirements.
|
|
57
|
-
|
|
58
|
-
Inspect your documents from the workspace where you installed the package:
|
|
59
|
-
|
|
60
|
-
```sh
|
|
61
|
-
npx --no-install mdtools lint --root /path/to/documents --json
|
|
62
|
-
npx --no-install mdtools format --root /path/to/documents --diff
|
|
63
|
-
npx --no-install mdtools format --root /path/to/documents --write
|
|
64
|
-
npx --no-install mdtools format --root /path/to/documents --check
|
|
65
|
-
```
|
|
41
|
+
`npx mdtools format --write` with the `recommended` and `github` presets turns
|
|
42
|
+
it into:
|
|
66
43
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
report. `--no-install` prevents fetching a different package if the local
|
|
71
|
-
executable is missing.
|
|
44
|
+
```markdown
|
|
45
|
+
Weather Station collects _temperature_, _humidity_, and _pressure_ readings from
|
|
46
|
+
a sensor board.
|
|
72
47
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
vault. Version 0.2.0-rc.1 and earlier assumed CommonMark, in which formatting
|
|
76
|
-
reflows tables and joins the lines of a note. The quick start shows how to
|
|
77
|
-
choose a profile for GitHub, Forgejo, Gitea, Obsidian, or plain CommonMark.
|
|
48
|
+
> [!NOTE]
|
|
49
|
+
> Use matching firmware and page versions, or the page shows **no data**.
|
|
78
50
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
24 LTS is preferred.
|
|
83
|
-
|
|
84
|
-
```sh
|
|
85
|
-
git clone https://github.com/viell-dev/slop-markdown-tools.git
|
|
86
|
-
cd slop-markdown-tools
|
|
87
|
-
npm ci
|
|
88
|
-
npm run build
|
|
89
|
-
node dist/cli/main.js --help
|
|
51
|
+
| Sensor | Unit |
|
|
52
|
+
| ----------- | ---- |
|
|
53
|
+
| Temperature | °C |
|
|
90
54
|
```
|
|
91
55
|
|
|
92
|
-
|
|
93
|
-
`npx --no-install mdtools` in the examples above. You can also install the built
|
|
94
|
-
checkout as a local dependency.
|
|
95
|
-
|
|
96
|
-
## Contributions and verification
|
|
97
|
-
|
|
98
|
-
All changes to `main` require a pull request and passing CI, including
|
|
99
|
-
prerelease maintenance. Published npm versions and release tags are immutable;
|
|
100
|
-
corrections get a new version. See [CONTRIBUTING.md](CONTRIBUTING.md) and
|
|
101
|
-
[SECURITY.md](SECURITY.md) for contribution and vulnerability reporting.
|
|
56
|
+
## Install
|
|
102
57
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
expected rendering. A screenshot can help explain a visible defect, but the
|
|
106
|
-
Markdown source is needed to reproduce it. For agents, include the JSON
|
|
107
|
-
diagnostic output when available. Automatic issue reporting is not built into
|
|
108
|
-
the tool.
|
|
58
|
+
mdrefine needs Node.js 22.12 or newer. The package is `mdrefine`, and its
|
|
59
|
+
command is `mdtools`:
|
|
109
60
|
|
|
110
61
|
```sh
|
|
111
|
-
npm
|
|
112
|
-
|
|
62
|
+
npm install --save-dev --save-exact mdrefine@0.2.0
|
|
63
|
+
npx mdtools lint
|
|
64
|
+
npx mdtools format --diff
|
|
65
|
+
npx mdtools format --write
|
|
66
|
+
npx mdtools format --check
|
|
113
67
|
```
|
|
114
68
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
`npm run format:docs:check` checks it without writing. Prettier formats
|
|
118
|
-
implementation and configuration files and excludes Markdown. `npm run format`
|
|
119
|
-
runs both formatters. Markdown fixtures under `tests/fixtures/` and the example
|
|
120
|
-
documents under `examples/workspaces/` and `examples/plugin/notes/` are excluded
|
|
121
|
-
from documentation passes, because they are deliberately unformatted.
|
|
122
|
-
|
|
123
|
-
`npm-run-all2` coordinates scripts, running independent checks in parallel and
|
|
124
|
-
building the CLI before documentation checks and tests.
|
|
125
|
-
|
|
126
|
-
`check` runs strict TypeScript checks, ESLint, Prettier for non-Markdown files,
|
|
127
|
-
Markdown Tools for documentation, the VitePress site build, and both test
|
|
128
|
-
suites. Unit tests in `tests/unit/` call the library's source; integration tests
|
|
129
|
-
in `tests/integration/` run the built CLI on real files and check the examples
|
|
130
|
-
and documentation against the tool. `npm run test:unit` and
|
|
131
|
-
`npm run test:integration` run one suite; see
|
|
132
|
-
[testing](https://viell-dev.github.io/slop-markdown-tools/testing.html). GitHub
|
|
133
|
-
Actions runs full checks on Linux with Node.js 24, plus build and test coverage
|
|
134
|
-
on Linux with Node.js 22 and Windows with Node.js 24. All three jobs verify the
|
|
135
|
-
installed package. Changes to formatting need tests for expected output,
|
|
136
|
-
idempotence, and preserved semantics; defects should add a regression example.
|
|
137
|
-
Keep fixes scoped and describe remaining limitations in the PR.
|
|
138
|
-
|
|
139
|
-
Agent contributors should read
|
|
140
|
-
[AGENTS.md](https://github.com/viell-dev/slop-markdown-tools/blob/main/AGENTS.md)
|
|
141
|
-
for maintenance-specific instructions, including what an assigned agent decides
|
|
142
|
-
and the limits of that authority. `test:package` packs and installs a temporary
|
|
143
|
-
consumer project, then exercises the installed CLI and library; it can require
|
|
144
|
-
access to the npm registry.
|
|
145
|
-
|
|
146
|
-
## Benchmarks
|
|
69
|
+
`lint` reports and never writes. `format` shows a diff, writes with `--write`,
|
|
70
|
+
and with `--check` fails when a document would change.
|
|
147
71
|
|
|
148
|
-
|
|
149
|
-
npm run benchmark
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
The benchmark times parsing, linting, and formatting of synthetic documents
|
|
153
|
-
through the library and the CLI, with Prettier on the same files for comparison.
|
|
154
|
-
It takes a few minutes and is not part of `check`.
|
|
155
|
-
[Benchmarks](https://viell-dev.github.io/slop-markdown-tools/benchmarks.html)
|
|
156
|
-
explains what each number means and whether it is good.
|
|
72
|
+
## Configure
|
|
157
73
|
|
|
158
|
-
|
|
74
|
+
`mdtools.config.jsonc` at the root of the documents:
|
|
159
75
|
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
76
|
+
```jsonc
|
|
77
|
+
{
|
|
78
|
+
"extends": ["recommended", "github"],
|
|
79
|
+
}
|
|
164
80
|
```
|
|
165
81
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
82
|
+
`recommended` wraps prose at 80 columns; writes emphasis as `_text_`, strong
|
|
83
|
+
text as `**text**`, list items as `- item` and `1. item`, headings with `#`,
|
|
84
|
+
code fences with backticks, and thematic breaks as `---`; aligns tables; removes
|
|
85
|
+
trailing spaces and repeated blank lines; ends files with a line break; and
|
|
86
|
+
checks links. It also warns about references without a definition, unused
|
|
87
|
+
definitions, empty links, skipped heading levels, images without alternative
|
|
88
|
+
text, and table rows with the wrong number of cells. Use `forgejo`, `codeberg`,
|
|
89
|
+
`gitea`, or `obsidian` in place of `github` for documents rendered there.
|
|
170
90
|
|
|
171
|
-
##
|
|
91
|
+
## Documentation
|
|
172
92
|
|
|
173
|
-
[
|
|
93
|
+
The [documentation](https://viell-dev.github.io/slop-markdown-tools/) starts
|
|
94
|
+
with [getting
|
|
95
|
+
started](https://viell-dev.github.io/slop-markdown-tools/quick-start.html) and
|
|
96
|
+
covers the [rules](https://viell-dev.github.io/slop-markdown-tools/rules.html),
|
|
97
|
+
configuration, the command line, Obsidian vaults, CI and editors, the library
|
|
98
|
+
and plugins, and [what is not covered
|
|
99
|
+
yet](https://viell-dev.github.io/slop-markdown-tools/design.html#limits). The
|
|
100
|
+
package ships working
|
|
101
|
+
[examples](https://viell-dev.github.io/slop-markdown-tools/examples.html) and
|
|
102
|
+
the [changelog](CHANGELOG.md).
|
|
103
|
+
|
|
104
|
+
## Status
|
|
105
|
+
|
|
106
|
+
mdrefine follows a [pre-1.0 versioning
|
|
107
|
+
policy](https://viell-dev.github.io/slop-markdown-tools/versions.html): a minor
|
|
108
|
+
release may change behavior and says how, and a patch release only fixes
|
|
109
|
+
defects. It is written and maintained by AI agents, and no person reviews the
|
|
110
|
+
code. Changes are accepted on their tests, CI on Linux and Windows, and a
|
|
111
|
+
semantic check that refuses any formatting edit that would change a document's
|
|
112
|
+
parsed meaning.
|
|
113
|
+
|
|
114
|
+
## Contributing, security, and license
|
|
115
|
+
|
|
116
|
+
[CONTRIBUTING.md](CONTRIBUTING.md) explains how to report a defect and how to
|
|
117
|
+
make a change, and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) what is expected of
|
|
118
|
+
everyone who takes part. Report vulnerabilities as [SECURITY.md](SECURITY.md)
|
|
119
|
+
describes. mdrefine is released under the [MIT license](LICENSE).
|
package/SECURITY.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# Security policy
|
|
2
2
|
|
|
3
|
-
Report suspected
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
not
|
|
3
|
+
Report a suspected vulnerability through [GitHub's private vulnerability
|
|
4
|
+
reporting](https://github.com/viell-dev/slop-markdown-tools/security/advisories/new),
|
|
5
|
+
with the affected version, the configuration, and a minimal synthetic example.
|
|
6
|
+
Do not put exploitable details or private documents in a public issue.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
time.
|
|
10
|
-
|
|
11
|
-
stable release exists; older prereleases do not receive separate backports.
|
|
8
|
+
Reports are handled by an AI agent that the repository owner assigns, without a
|
|
9
|
+
guaranteed response time. Fixes go into the newest release line; older versions
|
|
10
|
+
and prereleases do not receive backports.
|
|
12
11
|
|
|
13
|
-
JavaScript configuration and plugins
|
|
14
|
-
load
|
|
15
|
-
load
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
JavaScript configuration files and plugins run with the permissions of whoever
|
|
13
|
+
runs the tool, so load only code you trust. A JSON configuration is data, but
|
|
14
|
+
its `plugins` entries still load code. In a Git repository, the command line
|
|
15
|
+
runs Git (`git config` and `git ls-files`) to read the ignore rules that Git
|
|
16
|
+
applies. It turns off the file system monitor, which a repository's own
|
|
17
|
+
configuration could otherwise name as a program to run, and on Windows it runs
|
|
18
|
+
Git only from an absolute folder of `PATH`. Link checks never fetch URLs. A
|
|
19
|
+
rendering defect without a security impact belongs in an ordinary issue.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "mdtools configuration",
|
|
4
|
+
"description": "Configuration of the mdtools command of mdrefine: https://viell-dev.github.io/slop-markdown-tools/configuration.html",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": {
|
|
9
|
+
"description": "The JSON Schema for editors; the tool ignores it.",
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"resolve": {
|
|
13
|
+
"description": "Files that links may lead to, which are never linted or formatted.",
|
|
14
|
+
"type": "object",
|
|
15
|
+
"additionalProperties": false,
|
|
16
|
+
"properties": {
|
|
17
|
+
"gitIgnored": {
|
|
18
|
+
"description": "Files that .gitignore files exclude are link targets. Default: false.",
|
|
19
|
+
"type": "boolean"
|
|
20
|
+
},
|
|
21
|
+
"nestedRepositories": {
|
|
22
|
+
"description": "Files of nested Git repositories are link targets. Default: false.",
|
|
23
|
+
"type": "boolean"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"extends": {
|
|
28
|
+
"description": "Presets to start from, in order: a preset name or a list of them. Without it, the configuration starts from recommended.",
|
|
29
|
+
"anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
|
|
30
|
+
},
|
|
31
|
+
"dialect": { "$ref": "#/definitions/dialect" },
|
|
32
|
+
"rules": { "$ref": "#/definitions/rules" },
|
|
33
|
+
"ignore": {
|
|
34
|
+
"description": "Path patterns of documents that are never linted or formatted, matched with their letter case. They stay link targets.",
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": { "type": "string" }
|
|
37
|
+
},
|
|
38
|
+
"plugins": {
|
|
39
|
+
"description": "Plugins to load: files relative to this file, or package names.",
|
|
40
|
+
"type": "array",
|
|
41
|
+
"items": { "type": "string" }
|
|
42
|
+
},
|
|
43
|
+
"overrides": {
|
|
44
|
+
"description": "Settings for the documents that match one of the patterns in files.",
|
|
45
|
+
"type": "array",
|
|
46
|
+
"items": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"required": ["files"],
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"properties": {
|
|
51
|
+
"files": {
|
|
52
|
+
"description": "Path patterns, matched with their letter case against paths relative to the workspace root.",
|
|
53
|
+
"type": "array",
|
|
54
|
+
"items": { "type": "string" },
|
|
55
|
+
"minItems": 1
|
|
56
|
+
},
|
|
57
|
+
"dialect": { "$ref": "#/definitions/dialect" },
|
|
58
|
+
"rules": { "$ref": "#/definitions/rules" }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"definitions": {
|
|
64
|
+
"dialect": {
|
|
65
|
+
"description": "The renderer whose syntax documents are read in. When nothing names one, github is assumed, or obsidian inside a vault.",
|
|
66
|
+
"enum": ["commonmark", "github", "forgejo", "codeberg", "gitea", "obsidian"]
|
|
67
|
+
},
|
|
68
|
+
"severity": { "enum": ["off", "warn", "error"] },
|
|
69
|
+
"rules": {
|
|
70
|
+
"description": "Rule IDs and their settings: a severity, or a list of a severity and the rule's options, as in [\"warn\", { \"width\": 100 }].",
|
|
71
|
+
"type": "object",
|
|
72
|
+
"additionalProperties": {
|
|
73
|
+
"anyOf": [
|
|
74
|
+
{ "$ref": "#/definitions/severity" },
|
|
75
|
+
{
|
|
76
|
+
"type": "array",
|
|
77
|
+
"items": [{ "$ref": "#/definitions/severity" }],
|
|
78
|
+
"minItems": 1,
|
|
79
|
+
"maxItems": 1
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "array",
|
|
83
|
+
"items": [{ "$ref": "#/definitions/severity" }, { "type": "object" }],
|
|
84
|
+
"minItems": 2,
|
|
85
|
+
"maxItems": 2
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unified diff that turns `before` into `after`, with the headers and hunks
|
|
3
|
+
* of `diff`'s `createTwoFilesPatch`. That function compares the whole texts,
|
|
4
|
+
* at a cost that grows with their length times the number of changed lines, so
|
|
5
|
+
* that rewrapping a long document took minutes to show. This one compares only
|
|
6
|
+
* the regions that changed and their neighbours. Where it removes and adds
|
|
7
|
+
* other lines than a comparison of the whole texts would, both diffs turn
|
|
8
|
+
* `before` into `after`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function unifiedDiff(oldFileName: string, newFileName: string, before: string, after: string): string;
|