Skip formatting code blocks wrapped in HTML skip comments#22962
Skip formatting code blocks wrapped in HTML skip comments#22962amyreese wants to merge 5 commits intoamy/ruffen-docs-extensionfrom
Conversation
Typing conformance resultsNo changes detected ✅ |
|
|
ntBre
left a comment
There was a problem hiding this comment.
This makes sense to me functionally, but I'm really starting to wonder if we should take a different parsing approach. I believe this now means we're iterating over the whole source code twice, first to find suppression comments, and then a second time to extract code blocks for formatting. Combined with the perf hit we saw in the fancy-regex branch, I'm sort of inclined at least to experiment with a different approach. What do you think?
I guess I'm sort of hopeful that we can reuse some of the logic from the docstring formatting even if we have to copy-paste it instead of factoring out and sharing it directly.
| ``` | ||
| "#); | ||
| } | ||
| #[test] |
There was a problem hiding this comment.
tiny nit:
| #[test] | |
| #[test] |
There was a problem hiding this comment.
sigh, why doesn't rustfmt take care of that for me 😅
|
I had started toying with that (as maybe evidenced by the branch name 🙈) but wanted to get the simple version first to prompt discussion around the comment form, etc. I'll try to put together a line-by-line variant. |
3eebdf9 to
cefa871
Compare
Format markdown with line-by-line regex parse - Uses basic `regex` crate, so no backtracking or backreferences needed - Supports `~~~` and arbitrary length code fences - Supports `<!-- fmt:off -->` to skip formatting code blocks - Includes test cases from previous PRs, as well as new ones Obviates #22962 and #22937
Skips formatting markdown code blocks wrapped in HTML comments like:
<!-- blacken-docs:off -->or
<!-- ruff:off -->