Skip to content

Commit c984ed4

Browse files
jiangtaoclaude
andcommitted
fix: escape ampersand in puppeteer SVG and add /dev:commit workflow to CLAUDE.md
- Fix puppeteer-start-cover.svg: escape & to &amp; for XML validity - Fix image-lint-cli.cjs: syntax error in regex, add ampersand validation - Update CLAUDE.md: add /dev:commit 5-step workflow documentation - Update CLAUDE.md: add Image Linting section Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0430a9f commit c984ed4

File tree

4 files changed

+134
-46
lines changed

4 files changed

+134
-46
lines changed

CLAUDE.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,95 @@ When creating or modifying diagrams:
132132
- Content syncs to 语雀博客 and Jerret Life WeChat official account
133133
- Licensed under CC BY-NC-SA 3.0 CN (original content by jiangtao)
134134

135+
## Development Workflow
136+
137+
### Git Commit Workflow (MANDATORY)
138+
139+
All code changes MUST follow the structured 5-step commit workflow:
140+
141+
```bash
142+
# Step 1: Create branch with descriptive name
143+
git checkout -b feat/add-feature
144+
git checkout -b fix/error-handling
145+
git checkout -b refactor/cleanup-code
146+
git checkout -b docs/update-readme
147+
git checkout -b test/add-unit-tests
148+
149+
# One-line summary template
150+
# <type>: <what changed> → <outcome/benefit>
151+
```
152+
153+
**Step 2: Create PR with structured summary:**
154+
```markdown
155+
## Summary
156+
<!-- One sentence describing change -->
157+
158+
## Changes
159+
- [ ] File path - Description of change
160+
- [ ] File path - Description of change
161+
162+
## Type
163+
- [ ] feat - New feature
164+
- [ ] fix - Bug fix
165+
- [ ] refactor - Code restructuring (no behavior change)
166+
- [ ] docs - Documentation only
167+
- [ ] test - Tests only
168+
- [ ] chore - Build/config changes
169+
170+
## Related Issue
171+
Closes #(issue number) or Relates to #(issue number)
172+
```
173+
174+
**Step 3: Define test cases BEFORE running tests:**
175+
```markdown
176+
## Test Plan
177+
### Unit Tests
178+
- [ ] Test case 1: Description
179+
- [ ] Test case 2: Description
180+
181+
### Integration Tests
182+
- [ ] Test case 1: Description
183+
184+
### Manual Tests
185+
- [ ] Test case 1: Description
186+
187+
### Edge Cases
188+
- [ ] Test case 1: Description
189+
```
190+
191+
**Step 4: Run tests and generate report:**
192+
```bash
193+
npm test # Run test suite
194+
npm run build # Run build (if applicable)
195+
npm run lint # Run linter
196+
```
197+
198+
**Step 5: User review checklist:**
199+
- [ ] Code changes align with one-line summary
200+
- [ ] All tests pass (no failures)
201+
- [ ] Documentation is updated (if applicable)
202+
- [ ] No unintended side effects
203+
- [ ] Edge cases are covered
204+
- [ ] Code follows project style guidelines
205+
206+
**Only after all 5 steps are completed and approved, merge to main.**
207+
208+
### Image Linting
209+
210+
Before committing changes to blog posts or images:
211+
212+
```bash
213+
cd home && npm run lint:images
214+
```
215+
216+
This validates:
217+
- Duplicate `</svg>` closing tags
218+
- Watermark presence ("Jerret's Blog")
219+
- Malformed attributes (missing `>` in attributes)
220+
- xmllint validation (if available)
221+
135222
## Rules
136223

137224
1. 务必遵守: 禁止删除文件,若要删除的话 请询问
138225
2. 务必遵守:新增的变更,务必走测试,测试验证完成之后,拉分支创建提交
226+
3. 务必遵守:提交代码必须遵循 `/dev:commit` 工作流(5步骤)

home/bin/image-lint-cli.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ function validateSVGFiles() {
5959
});
6060
}
6161

62-
// 检查 5:1: puppeteer 字体空格验证(XML 要求引号
62+
// 检查 5: puppeteer 字体验证(XML 中 & 符号必须转义
6363
if (content.includes('Getting Started') || content.includes('Puppeteer')) {
64-
const hasFontIssue = /font-family="[^"]*"\s+(?!-|,)\s+/.dev:font:/;
65-
if (hasFontIssue) {
64+
const unescapedAmp = /&(?!(?:amp|lt|gt|quot|apos);)/.test(content);
65+
if (unescapedAmp) {
6666
svgErrors.push({
6767
file: file,
68-
error: 'puppeteer 封面: font-family 包含空格的字体名 "sans-serif" 需要引号'
68+
error: 'puppeteer 封面: & 符号未转义,需要使用 &amp;'
6969
});
7070
}
7171
}

home/public/images/blog-covers/puppeteer-start-cover.svg

Lines changed: 21 additions & 21 deletions
Loading

home/src/images/blog-covers/puppeteer-start-cover.svg

Lines changed: 21 additions & 21 deletions
Loading

0 commit comments

Comments
 (0)