Embedded HTML Formatting (markup_fmt integration) - #797
Conversation
0298dfe to
31e8f1c
Compare
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
|
Just wanted to check in to see if there was any discussions we could kick off on the overall approach, or if it would help to talk through the use case more, etc. I understand this is a pretty big new feature, so just trying to understand the best path forward. |
|
Thanks for the ping, and apologies for the wait. I have been partly away recently, and this is a big enough change that I did not want to answer it off the cuff, so it took longer than my usual turnaround. You clearly put real work into this, so here is a proper answer. The short version, up front rather than buried at the end: I am not going to take the formatter integration. Below is why, and there are two pieces of this branch I do want. The blocking problem: an external formatter cannot see containers
On > <div class="note">
> <p>Some text inside a blockquote.</p>
> </div>becomes > <div class="note">
> <p>Some text inside a blockquote.</p>
>
</div>
I do not think this is something to patch, though: it follows from handing a raw slice to an outside transformer. rumdl has one rule that formats a block correctly inside containers, MD060 for tables, and it gets there by stripping the container prefix, transforming, and re-adding it ( Being default-on sharpens it: a plain What would remain even if that were fixed
On cost, so you have the real numbers rather than a vague concern: +59 crates, about +20s clean build, +4.15 MiB binary. Effectively all of it is What I do want from this branch The infrastructure half is a genuine improvement and I would review it as its own PR expecting to take it: dropping the hand-rolled MD033's A counter-proposal An MD089 that normalizes only the indentation of HTML block lines: opt-in, no new dependency. The appeal is that an indentation-only transform can carry a machine-checkable invariant in its fix path, which a general formatter never can. MD013's reflow does exactly that: I should be straight that the hard half is making that argument at the Markdown level rather than the HTML one. My first instinct was "HTML collapses whitespace, so leading whitespace cannot change rendering", and that is wrong: indentation is load-bearing in CommonMark. These three lines render as HTML at column 0, and as escaped literal text inside a <div>
text
</div>And de-indenting a closing tag out of a list item is the same corruption the current branch produces. So the invariant has to be closer to: container prefix untouched, no line's indent taken below what its container requires or up to the indented-code threshold, line count unchanged, no blank/non-blank flips, everything after the indent byte-identical, and preformatted content skipped outright. Bounded, but not trivial. If it is interesting it is yours to write and I will review it promptly. If it is not what you were after, I understand, and I would still like the HTML block range refactor as its own PR. |
PR: Embedded HTML Formatting (markup_fmt integration)
Adds HTML formatting to
rumdlviamarkup_fmt. Supports HTML blocks, JS/TS in<script>tags (viadprint), and Markdown inside HTML comments.This is a draft/starting point for discussion.
Changes
1. Engine Integration (
MD089/embedded-html-fmt)MD089.<!-- rumdl-disable MD089 -->).per-file-ignores.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:3. Robustness Fixes (from review)
LineIndex::byte_to_line_colunder multi-byte UTF-8 by clamping offsets to char boundaries.strip_common_indenton mixed indentation (Unicode whitespace).dprinttypescript configuration outside the script formatting loop.4. Commits
feat(config): add [html] and [html.script] configuration sectionsfeat(html-fmt): implement and integrate embedded HTML formatting check(refactored toMD089in working copy)docs(html-fmt): add user guide and configuration details for HTML formattingfeat(html-fmt): add format-comments-as-markdown optionFeedback Requested
MD089/embedded-html-fmtokay? (Updated fromMD088as it was reserved).[html]or move to[MD089]?markup_fmtanddprint-plugin-typescript(gated underhtml-fmtfeature).