mirror of
https://github.com/luongnv89/claude-howto.git
synced 2026-12-03 02:03:31 +01:00
fix/260-example-plugins
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2b530b7674 |
fix(scripts): keep combining marks in heading anchors (#226)
## Summary
`heading_to_anchor()` kept only Python `\w` characters plus spaces,
hyphens and U+200C, so combining marks (Unicode categories Mn, Mc, Me)
were dropped from heading anchors. GitHub keeps them in heading ids, so
a Persian heading such as `مجموعهٔ استاندارد ایموجی` (U+0654 ARABIC
HAMZA ABOVE) got an anchor without the mark. A link that matched GitHub
then failed the `cross-references` hook, while a link with the mark
removed passed even though it is broken on github.com.
The step-2 filter now keeps Mn/Mc/Me characters.
`scripts/build_website.py` carries its own copy of the function,
documented as mirroring the checker, and gets the identical change.
## Type of Change
- [x] Bug fix
## Changes
| File | Change |
|------|--------|
| `scripts/check_cross_references.py` | `heading_to_anchor`: the step-2
`re.sub` keeps characters whose category is in
`COMBINING_MARK_CATEGORIES` (Mn/Mc/Me) instead of dropping them, with a
comment explaining why |
| `scripts/build_website.py` | The same change in its own copy of
`heading_to_anchor` |
| `scripts/tests/test_check_cross_references.py` | U+0654 kept (Persian
from the issue); decomposed Latin, Arabic harakat and Devanagari marks
kept; U+FE0F still stripped because step 1 removes it; `main()` passes a
link that keeps the mark and reports a link without it |
| `scripts/tests/test_build_website.py` | U+0654 kept; website and
checker return the same anchor for Persian with a combining mark,
decomposed Latin and Devanagari headings |
## Verification
Before/after on the three headings named in the issue (U+0654 shown as
`\u0654`):
```text
مجموعهٔ استاندارد ایموجی
old: مجموعه-... (mark dropped)
new: مجموعهٔ-...
فرادادهٔ YAML
old: فراداده-yaml
new: فرادادهٔ-yaml
پانوشت فرادادهٔ سند
old: پانوشت-فراداده-سند
new: پانوشت-فرادادهٔ-سند
```
No existing anchor moves. Comparing the old and new implementation over
every heading in the repo:
```bash
$ python ../backups/scan_anchor_diff.py # old() copied from the pre-change code
md files: 478 headings: 13647 changed: 0
```
Tests:
```bash
$ python -m pytest scripts/tests/test_check_cross_references.py scripts/tests/test_build_website.py -q
85 passed, 2 warnings in 10.24s
$ python -m pytest scripts/tests/ -q
1 failed, 197 passed, 2 warnings in 13.63s
```
The one failure
(`test_build_epub.py::TestChapterCollector::test_path_mapping`) is
pre-existing and Windows-only: the test asserts the posix key
`01-test-chapter/README.md` while `ChapterCollector` builds
`01-test-chapter\\README.md` on Windows. That file is untouched by this
PR and the CI job runs on `ubuntu-latest`.
Lint, format, types and security:
```bash
$ ruff check scripts/
All checks passed!
$ ruff format --check scripts/
19 files already formatted
$ mypy scripts/ --ignore-missing-imports
scripts\sync_translations.py:84: error: ... (2 pre-existing errors, file not touched)
$ bandit -c scripts/pyproject.toml -r scripts/ --exclude scripts/tests/
Total issues (by severity): 0
```
No `.md` files change in this PR, so the five Markdown hooks
(`markdown-lint`, `cross-references`, `mermaid-syntax`, `link-check`,
`markdown-rendering`) are unaffected; the `cross-references` logic they
call is what the new tests cover.
## Notes
The markers are kept for Mn, Mc and Me, matching what GitHub's slugger
keeps (`\p{Mark}`). Variation selectors (U+FE00–U+FE0F) are category Mn
but sit in the emoji ranges stripped in step 1, so emoji-prefixed ids
are unchanged — covered by
`test_heading_anchor_still_strips_em_dash_and_zero_width_joiner`.
Closes #223
[](https://github.com/deepseek-ai/deepseek-harness)
|
||
|
|
b968f42986 |
fix(scripts): keep ZWNJ in heading anchors (#222)
Closes #219
## Summary
`heading_to_anchor()` in `scripts/check_cross_references.py` removed
U+200C ZERO WIDTH NON-JOINER (ZWNJ) from heading anchors, but GitHub
keeps it in heading ids. Persian uses ZWNJ inside ordinary words, so a
correct in-page link to a Persian heading failed the `cross-references`
hook and the "Cross-reference Check" CI job, while a link with the ZWNJ
removed passed the checker even though it is broken on github.com. The
checker now keeps U+200C. `scripts/build_website.py` has its own copy of
the function, documented as mirroring the checker, and gets the
identical change. All other characters are handled as before.
## Approach
Keep U+200C in heading anchors (checker plus website copy). The function
dropped ZWNJ in two places, so both change:
1. The step-1 class that strips `U+2000–U+206F` is split into
`U+2000–U+200B` and `U+200D–U+206F`, so it skips U+200C.
2. The step-2 filter `[^\w\s-]` becomes `[^\w\s\U0000200C-]`. ZWNJ is
category Cf, which neither `\w` nor `\s` matches, so without this step 2
would still remove it.
ZWJ (U+200D), the em dash and every other General Punctuation character
are still stripped.
## Decision Record
- **Root cause:** `heading_to_anchor()` removes U+200C twice: the step-1
character class strips all of U+2000–U+206F (General Punctuation, which
contains ZWNJ), and the step-2 `[^\w\s-]` filter strips any Cf
character. GitHub keeps ZWNJ in heading ids. Checked against the
rendered `fa/STYLE_GUIDE.md` on PR #208's branch: 24 of its 62 distinct
heading ids (48 of the 124 `user-content-` ids) contain U+200C, e.g.
`نامگذاری-فایل-و-پوشه`. Before this change the checker's anchors missed
27 of those 62 ids, 24 of them because of ZWNJ.
- **Options considered:** Option 1 — Keep U+200C in heading anchors
(checker plus website copy)
- **Options rejected:** n/a — trivial change, direct plan (light
profile)
- **Selected option:** Option 1 — Keep U+200C in heading anchors
(checker plus website copy)
- **Residual risk:**
- **Only U+200C changes.** The rendered ids are evidence for ZWNJ and
the em dash only. On the rendered `CHANGELOG.md` on `main`, all 96
heading ids (19 with an em dash) match both the old and the new output.
ZWJ (U+200D) and the rest of U+2000–U+206F are still stripped, because
no rendered page here shows GitHub keeping them.
- **U+0654 is still dropped (out of scope).** U+0654 ARABIC HAMZA ABOVE
is a combining mark. Python's `\w` drops it but GitHub keeps it. With
this change, 59 of the 62 headings in `fa/STYLE_GUIDE.md` match GitHub's
ids, and the 3 that still differ all contain U+0654. Links to those
headings will still disagree with GitHub. This needs a separate issue.
- **PR #208 must put the ZWNJ back.** That branch removed the ZWNJ from
78 anchors (
|
||
|
|
eff5bd226a |
test(scripts): cover repo-root boundary in check_cross_references (#95)
* test(scripts): cover repo-root boundary in check_cross_references Locks in the boundary behavior added in #91: links resolving outside the repo root are silently skipped, in-repo broken links still error, and valid in-repo links still pass. * test(scripts): cover missing-README detection in numbered lesson dirs |