Skip to content

Support optional search/replacement in MarkdownSection.replace - #18

Merged
dblock merged 1 commit into
masterfrom
dblock/markdown-replacement-overload
Nov 11, 2026
Merged

dblock merged 1 commit into
masterfrom
dblock/markdown-replacement-overload

Conversation

@dblock

@dblock dblock commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Adds the requested optional second string to MarkdownSection.replace rather than a separate substitution method:

await section.replace("Entire section body.", { cwd });
await section.replace("Old wording", "New wording", { cwd });
await section.replace(/version (\S+)/g, "release $1", { cwd });

The existing whole-body form is unchanged. The search/replacement form uses JavaScript string/regex replacement semantics only within the selected body, including nested subsections. It preserves surrounding content, LF/CRLF style and unmatched spacing; unmatched searches do not rewrite the file. Invalid inputs, ambiguous headings and malformed line endings fail before writing.

Adds shared source/installed behavior assertions, positive/negative declaration contracts, documentation, and a changelog entry. Validation: 88 tests via npm run test:coverage, npm run lint, git diff --check, and strict-engine consumers installed from the exact retained archive. The Markdown module has 100% line, branch and function coverage.

Follow-up to #14, which merged while implementation was in progress. This layer targets #16 and extends existing native stack #17 without rewriting merged history. No publication or merge performed.

AI-authored by GitHub Copilot on behalf of @dblock.

@dblock
dblock added this pull request to stack #17 November 11, 2026 18:32
@dblock
dblock force-pushed the dblock/markdown-replacement-overload branch from 8f1b6b3 to 32d6956 Compare November 11, 2026 18:40
@dblock
dblock force-pushed the dblock/markdown-replacement-overload branch from 32d6956 to 1d9e2db Compare November 11, 2026 18:49
Base automatically changed from dblock/testing-kit to master November 11, 2026 18:51
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dblock
dblock force-pushed the dblock/markdown-replacement-overload branch from 1d9e2db to 6cf156f Compare November 11, 2026 18:52
@dblock
dblock merged commit 9a85fdd into master Nov 11, 2026
8 checks passed
@dblock
dblock deleted the dblock/markdown-replacement-overload branch November 11, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant