#16

format.mjs: replacing the marked block strips indentation from the content after it

OpenOliverGrothopened 10d ago

replaceMarkedBlock trims the text that follows the end marker:

const suffix = body.slice(afterEnd).trim();

.trim() also removes the leading spaces of the first line after the block. When that line is part of an indented code block, it no longer renders as code. This conflicts with the SKILL.md promise to "preserve every byte of unrelated prose".

Repro (four-space indented code right after the block):

Intro

<!-- before-and-after:start -->
old
<!-- before-and-after:end -->

    indented code line
    second line
node skill/scripts/format.mjs --body-file body.md --after a.gif

Output ends with:

indented code line
    second line

Possible fix: strip only leading blank lines, e.g. body.slice(afterEnd).replace(/^(?:[ \t]*\r?\n)+/, "").trimEnd(), plus a test with indented content directly after the block.

Activity

0

No activity yet.