-
Notifications
You must be signed in to change notification settings - Fork 1
Complete include enhancements: link adjustment and heading-level #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| --- | ||
| id: 69 | ||
| title: 'Include enhancements: link adjustment and heading-level' | ||
| status: "🔲" | ||
| status: "✅" | ||
| --- | ||
| # Include enhancements | ||
|
|
||
|
|
@@ -77,53 +77,53 @@ has `## Build` (level 2) and `### Sub` (level 3). | |
|
|
||
| ## Tasks | ||
|
|
||
| 1. Add a helper `adjustLinks(content, | ||
| 1. [x] Add a helper `adjustLinks(content, | ||
| includedFilePath, includingFilePath)` in | ||
| [`internal/rules/include/`](../internal/rules/include/) | ||
| that rewrites relative link/image targets | ||
| 2. Write unit tests for `adjustLinks`: same directory | ||
| 2. [x] Write unit tests for `adjustLinks`: same directory | ||
| (no-op), different directories, anchors and | ||
| absolute URLs left untouched, query strings | ||
| preserved | ||
| 3. Call `adjustLinks` in `generateIncludeContent` | ||
| 3. [x] Call `adjustLinks` in `generateIncludeContent` | ||
| after frontmatter stripping, before wrap | ||
| 4. Add a helper `adjustHeadings(content, parentLevel)` | ||
| 4. [x] Add a helper `adjustHeadings(content, parentLevel)` | ||
| that shifts ATX and setext heading levels | ||
| 5. Write unit tests for `adjustHeadings`: shift up, | ||
| 5. [x] Write unit tests for `adjustHeadings`: shift up, | ||
| shift down, cap at 6, no headings (no-op) | ||
| 6. Extend `validateIncludeDirective` to accept and | ||
| 6. [x] Extend `validateIncludeDirective` to accept and | ||
| validate the `heading-level` parameter (only | ||
| `"absolute"` is valid) | ||
| 7. In `generateIncludeContent`, detect the parent | ||
| 7. [x] In `generateIncludeContent`, detect the parent | ||
| heading level from the marker position and call | ||
| `adjustHeadings` when `heading-level: "absolute"` | ||
| 8. Add test for parent-level detection (marker under | ||
| 8. [x] Add test for parent-level detection (marker under | ||
| h2, under h3, at document root) | ||
| 9. Update the rule README at | ||
| 9. [x] Update the rule README at | ||
| [`MDS021-include/README.md`](../internal/rules/MDS021-include/README.md) | ||
| to document both features | ||
| 10. Update existing fixtures and tests if link | ||
| 10. [x] Update existing fixtures and tests if link | ||
| adjustment changes their expected output | ||
| 11. Run `go test ./...`, `go tool golangci-lint run`, | ||
| 11. [x] Run `go test ./...`, `go tool golangci-lint run`, | ||
| and `mdsmith check .` | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| - [ ] Relative links in included content are rewritten | ||
| - [x] Relative links in included content are rewritten | ||
| so they resolve from the including file's | ||
| directory, not the source file's directory | ||
| - [ ] Absolute URLs, anchor-only links (`#foo`), and | ||
| - [x] Absolute URLs, anchor-only links (`#foo`), and | ||
| protocol links (`http://`, `https://`) are not | ||
| modified | ||
| - [ ] `heading-level: "absolute"` shifts headings so | ||
| - [x] `heading-level: "absolute"` shifts headings so | ||
| the included top-level headings appear one level | ||
| below the enclosing section | ||
| - [ ] When `heading-level` is omitted, heading levels | ||
| - [x] When `heading-level` is omitted, heading levels | ||
| stay unchanged | ||
|
Comment on lines
+118
to
122
|
||
| - [ ] Heading level never exceeds 6 | ||
| - [ ] Invalid `heading-level` values produce a diagnostic | ||
| - [ ] Link adjustment is always applied (no parameter | ||
| - [x] Heading level never exceeds 6 | ||
| - [x] Invalid `heading-level` values produce a diagnostic | ||
| - [x] Link adjustment is always applied (no parameter | ||
| needed) | ||
| - [ ] All tests pass: `go test ./...` | ||
| - [ ] `golangci-lint run` reports no issues | ||
| - [ ] `mdsmith check .` reports zero diagnostics | ||
| - [x] All tests pass: `go test ./...` | ||
| - [x] `golangci-lint run` reports no issues | ||
| - [x] `mdsmith check .` reports zero diagnostics | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Task 5 is checked off as covering both “shift up” and “shift down”, but the current
adjustHeadingsunit tests only cover positive shifts (making headings deeper) and the no-op case; there is no test where the included content starts too deep and needs a negative shift to bring the minimum heading level up toparentLevel+1. Either add that test (and implement the behavior if needed) or adjust the task wording so it matches what’s actually validated.