Repository navigation
fix: keep line ranges and titles out of the code block language - #1306
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Parse fence languages and attributes app/Services/CodeSpans.php, resources/js/lib/code.ts, tests/Unit/Services/CodeSpansTest.php, tests/Unit/ComposerPreview.test.tsx |
Both parsers tokenize fence info strings and support single- and double-quoted attributes. The tests cover language and filename selection, including empty and unterminated values. |
Render filename-only headers resources/js/components/code-block.tsx, tests/Unit/ComposerPreview.test.tsx |
The header renders when a filename is present, even without a language. Tests check filename labels in commit and static excerpt rendering. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related issues
- [RFC] Gists #1363: The issue requests matching highlighted rendering for gist code blocks. This PR changes fence parsing but does not implement gist rendering.
Possibly related PRs
- dev-null-sh/dev-null.sh#1210: This PR extends the code-block filename parsing and labels added by PR
#1210. - dev-null-sh/dev-null.sh#1201: Mermaid rendering depends on the parsed language, which this PR changes.
Suggested reviewers: mnapoli, xheaven
Merge Risk: 
Minimal · up to 90d02
-
No actionable current-head defect was established in the reviewed parser or filename-header behavior.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "fix: keep line ranges and titles out of the code block language" matches the main change in the changeset. The raw summary shows that the parser in CodeSpans::block and resources/js/lib/code.ts now takes the language only from the first token that is not a brace group or a quoted key=value attribute. The tests add cases for line ranges and single-quoted titles and filenames. The title is specific, uses a conventional commit prefix, and is a single sentence of 12 words.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 5 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
f6cd14b to
90d0272
Compare
Summary
Follow-up to #1210. Some opening fences put the wrong thing in the code block's language, or lost their title:
``` title="routes/web.php", usedtitle="routes/web.php"as its label and had no filename.```js{2}(the VitePress and Gatsby style), keptjs{2}as the language, so the block wasn't highlighted and the label showedjs{2}.```php title='app/Models/User.php', was ignored.Now the first block shows
routes/web.php, also in quoted commits and notifications, the second is highlighted asjs, and the third showsapp/Models/User.php.Changes
CodeSpansreads the whole info string with the same tokens as before (key="value"pairs,{…}ranges, bare words), pluskey='value'pairs, and{now ends a bare word. The language is the first token only when it's a bare word.lib/code.tsmirrors it, and both sides are tested with the same cases.CodeBlockkeeps its header for a block with a filename but no language in excerpts, where there's no copy button.Validation
Local, on
90d02728(based onf7aa5e97, the latestproduction):composer test:lintandcomposer test:typespass, type coverage is 100%..tsxunit test passes.production. The rows for an apostrophe inside double quotes and for an empty or unclosed single-quoted title are guards and pass on both.Visual evidence
Guest view of the same demo commit in Chrome (2x),
production(f7aa5e97) vs this branch.1366×650: light before · light after · dark before · dark after
Quoted excerpt of a block with only a title:
Its other viewports and themes are on the assets branch.
Device verification
No mobile interaction changes, only a label and highlighting. 390×844 was checked with viewport emulation in Chrome, not on hardware or a simulator.
Independent review
A separate, read-only reviewer agent (given the task, #1210, the repo guidelines, the diff and these captures) returned CODE: PASS and VISUAL: PASS for
a4670abe..f6cd14b9, mediab2c285a9, and again for the rebasedf7aa5e97..90d02728, mediafccf3217, checking that #1351's new code block wrapper is intact and that nothing else reads the language or filename, after parity runs of 120,134 fuzzed and real-world fences (c++,f#,js:line-numbers,ts twoslash, mixed quotes and more) with 0 mismatches. It confirmed the feature tests fail onproductionand the guard rows pass on both. Nested fences (#1227) were checked by reading the code, since only the opening line is parsed.Limitations
```{r}used to show{r}as the label and now show none. Neither was highlighted.Summary by CodeRabbit