Skip to content

Embedded HTML Formatting (markup_fmt integration) - #797

Open
chandlerc wants to merge 4 commits into
rvben:mainfrom
chandlerc:html-fmt
Open

Embedded HTML Formatting (markup_fmt integration)#797
chandlerc wants to merge 4 commits into
rvben:mainfrom
chandlerc:html-fmt

Conversation

@chandlerc

@chandlerc chandlerc commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

PR: Embedded HTML Formatting (markup_fmt integration)

Adds HTML formatting to rumdl via markup_fmt. Supports HTML blocks, JS/TS in <script> tags (via dprint), and Markdown inside HTML comments.

This is a draft/starting point for discussion.

Changes

1. Engine Integration (MD089 / embedded-html-fmt)

  • Integrated as standard rule MD089.
    • Supports inline disable comments (<!-- rumdl-disable MD089 -->).
    • Supports per-file-ignores.
    • Works with LSP (diagnostics and quick-fixes).
  • Uses lazy rule loading (via Mutex<Option<Vec<Box<dyn Rule>>>>) to avoid recursion when formatting Markdown inside HTML comments.

2. Configuration (.rumdl.toml)

New [html] and [html.script] sections:

[html]
enabled = true
print-width = 80
indent-width = 2
use-tabs = false
quotes = "double" # "double" | "single"
format-comments-as-markdown = false

[html.script]
enabled = false
semi-colons = "always" # "always" | "prefer" | "asi"
quote-style = "prefer-double" # "always-double" | "always-single" | "prefer-double" | "prefer-single"

3. Robustness Fixes (from review)

  • UTF-8 Safety: Fixed panic in LineIndex::byte_to_line_col under multi-byte UTF-8 by clamping offsets to char boundaries.
  • Indentation Stripping: Fixed panic in strip_common_indent on mixed indentation (Unicode whitespace).
  • Performance: Cached dprint typescript configuration outside the script formatting loop.

4. Commits

  • feat(config): add [html] and [html.script] configuration sections
  • feat(html-fmt): implement and integrate embedded HTML formatting check (refactored to MD089 in working copy)
  • docs(html-fmt): add user guide and configuration details for HTML formatting
  • feat(html-fmt): add format-comments-as-markdown option

Feedback Requested

  1. Rule ID/Name: Is MD089 / embedded-html-fmt okay? (Updated from MD088 as it was reserved).
  2. Config Layout: Should these options stay under [html] or move to [MD089]?
  3. Comment Formatting: Is the recursive Markdown formatting in comments useful?
  4. Dependencies: Added markup_fmt and dprint-plugin-typescript (gated under html-fmt feature).

@chandlerc
chandlerc force-pushed the html-fmt branch 2 times, most recently from 0298dfe to 31e8f1c Compare August 5, 2026 08:17
Introduce `HtmlConfig` and `ScriptConfig` settings to control embedded
HTML block formatting.

- Added configuration structures with kebab-case serialization.
- Implemented sourced provenance mapping and merge behavior for
  per-directory configuration inheritance.
- Added `html-fmt` feature dependency gates for `markup_fmt` and
  `dprint-plugin-typescript`.
- Updated intelligent configuration merge unit tests.
- Regenerated JSON schema.

Assisted-by: Antigravity with Gemini
Introduce the embedded HTML block formatting checker and integrate it
into the single-file lint loop and the LSP workspace diagnostics.

- Added `LineIndex::byte_to_line_col` range utility to map global byte
  offsets to 1-indexed (line, character-column) document coordinates.
- Added `check_embedded_html_blocks` which parses Markdown files for
  `Tag::HtmlBlock` events and validates them against `markup_fmt`.
- Added script formatting callback mapping to `dprint-plugin-typescript`
  for script tags.
- Added JSX component tag skipping in MDX.
- Integrated the check under the `html-fmt` feature gate.

Assisted-by: Antigravity with Gemini
…matting

Create `docs/embedded-html-formatting.md` describing how HTML block
formatting and script tag formatting work inside Markdown documents.
Update the global settings reference and configuration file indexes to
point to it.

Assisted-by: Antigravity with Gemini
Assisted-by: Antigravity with Gemini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant