Repository navigation
mdrefine 0.2.0-rc.1
Pre-releasemdrefine 0.2.0-rc.1
First release candidate of the 0.2 feature release of Markdown Tools. npm
package: mdrefine; executable: mdtools. Requires Node.js 22.12 or newer.
Upgrade with:
npm install --save-dev --save-exact mdrefine@0.2.0-rc.1Changes below are relative to 0.1.0-rc.1. Release candidates use npm's rc
channel, and latest follows the newest prerelease until the first stable
release.
Forgejo, Codeberg, and Gitea support
New forgejo and gitea dialects and presets support documents hosted on those
forges. codeberg is an alias for forgejo, accepted in configuration,
presets, overrides, and --dialect; rules and plugins receive the canonical
name forgejo. Gitea is a separate dialect because its heading anchors and
emphasis behavior differ from Forgejo's. Example configurations are included in
examples/forgejo.jsonc and examples/gitea.jsonc
(PR #73 and
PR #79).
Both presets enable github/alert-marker, which normalizes known alert types
such as [!note] to [!NOTE], along with task-marker and table formatting.
Both dialects protect definition lists, backslash-delimited math, and shortlinks
from formatting that would change how they render. One-line \(...\) math and
[[...]] shortlinks stay together; paragraphs with display-math lines,
definition descriptions, or pairs spanning lines are left unreflowed. Inline
rules also preserve backslash math. Gitea additionally protects its _.py
emphasis exception, so formatting does not turn literal __init__.py into bold
text. Shortlinks are preserved, not resolved as links. On instances configured
to render soft line breaks as hard breaks, disable style/wrap.
More accurate fragment validation
links/valid now follows the renderer's heading and HTML-anchor behavior:
- Forgejo and Gitea recognize trailing heading attributes such as
## Install {#setup}. A customidreplaces the generated anchor; class-only
blocks are left out of the generated text
(PR #86). - Forgejo and Gitea before 1.26 generate anchors from the heading's last text
line as written, including emphasis markers and link destinations. Gitea 1.26
and later use the rendered text of all its lines. The Gitea dialect accepts
both generations' anchors
(PR #100 and
PR #108). - Inline HTML in Markdown headings contributes text without ordinary tags and
comments on GitHub and newer Gitea, while tags filtered into visible text
still contribute to the anchor
(PR #85 and
PR #108). - Explicit HTML anchors, the
idof an element and thenameof an<a>, are
recognized on GitHub, Forgejo, and Gitea. HTML comments, code, and raw-text
contents such as<script>and<textarea>do not create anchors
(PR #104). - Headings written as HTML (
<h2>Title</h2>) get generated anchors on GitHub
and Gitea 1.26 and later. GitHub numbers repeated HTML and Markdown headings
together; newer Gitea does not number them, and an HTML heading with its own
idgets no generated anchor
(PR #105). - Fragments with one leading
user-content-prefix are accepted on GitHub,
Forgejo, and Gitea. GitHub also matches fragments without regard to case;
Forgejo and Gitea remain case-sensitive. CommonMark follows GitHub's anchor
rules; Obsidian keeps its existing behavior
(PR #103 and
PR #106).
Correct fragments previously reported as missing can now resolve, allowing
links/path to rewrite their paths. Links to anchors that the renderer does not
generate can now be reported as missing.
Preserve heading attributes and anchors
On Forgejo and Gitea, formatting now keeps heading attribute blocks intact and
preserves anchors derived from a heading's source. Marker and path rules leave
the last text line unchanged unless a custom id makes its generated anchor
irrelevant; attribute text itself remains protected. Multiline code spans and
Setext-to-ATX conversions also preserve attribute interpretation. The semantic
safety check refuses edits from any rule or plugin that change a heading's
attribute block or move its generated anchors
(PR #99 and
PR #101).
The new forgejo/heading-id problem rule reports non-text heading IDs such as
{id=5}. Such IDs can make Forgejo and older Gitea fail to render the document;
newer Gitea renders the heading without an anchor. The forgejo, codeberg,
and gitea presets enable the rule as an error. It suggests quoting the value
and proposes no edit
(PR #107).
Parsing and performance
GFM documents containing URLs found only by GitHub's later autolink transform,
such as [www.example.com], no longer fail formatting with
Missing source position for text. Literal autolinks now come from the syntax
extension alone. Built-in formatting is unchanged, but plugins inspecting link
nodes no longer see those transform-only autolinks; ordinary URL and email
autolinks remain available
(PR #73).
The workspace now computes and caches target anchors only for the dialects
needed by fragment checks. GitHub and Obsidian workspaces avoid the extra parse
for Forgejo/Gitea heading attributes and their unused anchor calculations;
fragment-validation results are unchanged
(PR #109).
Compatibility and verification
Existing 0.1.0-rc.1 configurations remain accepted, and the Node.js minimum is
unchanged. The public Dialect type adds forgejo and gitea; DialectName
also accepts codeberg for configuration input. The library adds dialects,
dialectAliases, and canonicalDialect exports. Hosts and plugins with
exhaustive dialect handling should include the new canonical names. The API and
configuration remain provisional until the first stable release.
Config.dialect and Override.dialect now use DialectName, so hosts that
pass raw configuration values to an API requiring Dialect must canonicalize
them with canonicalDialect() first. resolveConfig() already returns a
canonical dialect. The configuration schema accepts the new names and alias.
The Gitea dialect covers 1.21 and later and accepts anchors from both sides of
the 1.26 renderer change; it does not guarantee that a fragment accepted for one
version exists on every version. Heading attribute blocks follow the rules used
by Forgejo 16 and Gitea 1.26 and later. Older Gitea attribute forms, attribute
values nested more than 64 levels, and some raw-text, footnote, and character
reference cases remain unmodeled. See design and limitations for
the detailed boundaries.
Runtime dependencies now include ignore@7.0.12, micromark-util-types@2.0.3,
and string-width@8.3.0; decode-named-character-reference@1.3.0 is a direct
dependency for HTML heading text. Development tools have also been updated.
Regression coverage now includes the new dialects, renderer-specific anchors,
preserved heading attributes, HTML tokenization, and dialect-specific lazy
indexing. The wrapping performance test has a longer timeout to tolerate slow
Windows CI runners; its linear-growth assertion is unchanged
(PR #84).
🤖 Generated with GPT-6.1-Sol via Codex