Skip to content

Commit efd288f

Browse files
authored
fix(lint): disable remark formatting for content files to preserve GitHub Alerts (#6502)
Remark-stringify escapes square brackets in GitHub Alerts syntax (> [!Note] becomes > \[!Note]), breaking alert rendering. Changes: - Remove lint-markdown-content pre-commit hook from lefthook.yml - Configure remark-lint-no-undefined-references to allow GitHub Alerts - Add remark-lint-no-undefined-references dependency - Unescaped GitHub Alerts in content/create.md Content files now preserve GitHub Alerts syntax while instruction files continue to use remark auto-formatting (they don't contain alerts). Vale provides adequate style linting for content files. Closes #6501 See: remarkjs/remark-gfm#53
1 parent ffbe4e5 commit efd288f

File tree

3 files changed

+21
-31
lines changed

3 files changed

+21
-31
lines changed

.ci/remark-lint/.remark-lint.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,31 @@ import remarkPresetLintMarkdownStyleGuide from 'remark-preset-lint-markdown-styl
44
import remarkFrontmatter from 'remark-frontmatter';
55
import remarkFrontmatterSchema from 'remark-lint-frontmatter-schema';
66
import remarkNoShellDollars from 'remark-lint-no-shell-dollars';
7+
import remarkLintNoUndefinedReferences from 'remark-lint-no-undefined-references';
78
import remarkToc from 'remark-toc';
89

910
const remarkConfig = {
1011
settings: {
1112
bullet: '-',
12-
plugins: [
13-
remarkPresetLintConsistent,
14-
remarkPresetLintRecommended,
15-
remarkPresetLintMarkdownStyleGuide,
16-
remarkFrontmatter,
17-
remarkFrontmatterSchema,
18-
remarkNoShellDollars,
19-
// Generate a table of contents in `## Contents`
20-
[remarkToc, { heading: '' }],
21-
],
2213
},
14+
plugins: [
15+
remarkPresetLintConsistent,
16+
remarkPresetLintRecommended,
17+
remarkPresetLintMarkdownStyleGuide,
18+
remarkFrontmatter,
19+
remarkFrontmatterSchema,
20+
remarkNoShellDollars,
21+
// Override no-undefined-references to allow GitHub Alerts syntax
22+
// This prevents lint warnings for [!Note], [!Tip], etc. in blockquotes
23+
[
24+
remarkLintNoUndefinedReferences,
25+
{
26+
allow: ['!Note', '!Tip', '!Important', '!Warning', '!Caution'],
27+
},
28+
],
29+
// Generate a table of contents in `## Contents`
30+
[remarkToc, { heading: '' }],
31+
],
2332
};
2433

2534
export default remarkConfig;

.ci/remark-lint/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"remark-preset-lint-recommended": "7.0.0",
1010
"remark-frontmatter": "5.0.0",
1111
"remark-lint-frontmatter-schema": "3.15.4",
12-
"remark-lint-no-shell-dollars": "4.0.0"
12+
"remark-lint-no-shell-dollars": "4.0.0",
13+
"remark-lint-no-undefined-references": "5.0.2"
1314
}
1415
}

lefthook.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,6 @@ pre-commit:
2222
docker compose run --rm --name remark-lint remark-lint $files --output --quiet || \
2323
{ echo "⚠️ Remark found formatting issues in instruction files. Automatic formatting applied."; }
2424
stage_fixed: true
25-
# Report markdown formatting issues in content/api-docs without auto-fixing
26-
lint-markdown-content:
27-
tags: lint
28-
glob: "{api-docs/**/*.md,content/**/*.md}"
29-
run: |
30-
# Prepend /workdir/ to staged files since repository is mounted at /workdir in container
31-
files=$(echo '{staged_files}' | sed 's|^|/workdir/|g; s| | /workdir/|g')
32-
# Run remark to check for formatting differences (without --output, shows diff in stdout)
33-
# If output differs from input, fail the commit
34-
for file in $files; do
35-
original=$(cat "${file#/workdir/}")
36-
formatted=$(docker compose run --rm --name remark-lint-content remark-lint "$file" 2>/dev/null | tail -n +2)
37-
if [ "$original" != "$formatted" ]; then
38-
echo "❌ Markdown formatting issues in ${file#/workdir/}"
39-
echo " Run: docker compose run --rm remark-lint $file --output"
40-
echo " Or manually fix the formatting to match remark style"
41-
exit 1
42-
fi
43-
done
44-
echo "✅ All content files are properly formatted"
4525
# Lint instruction and repository documentation files with generic Vale config
4626
lint-instructions:
4727
tags: lint

0 commit comments

Comments
 (0)