Skip to content

Fix off-by-one in <File> line-range extraction and add regression test#2971

Open
afurm wants to merge 1 commit intonear:masterfrom
afurm:fix/copy-md-range-off-by-one
Open

Fix off-by-one in <File> line-range extraction and add regression test#2971
afurm wants to merge 1 commit intonear:masterfrom
afurm:fix/copy-md-range-off-by-one

Conversation

@afurm
Copy link

@afurm afurm commented Feb 17, 2026

Summary

<File ... start="x" end="y" /> snippet extraction had an off-by-one bug that included one extra line after end.

This PR:

  • fixes the line-range slicing so end does not include the next line
  • adds a regression test for start="2" end="3" to ensure only lines 2–3 are returned
  • adds a small require.main guard/export so the helper can be tested directly without changing normal script execution

Before / After

  • Before: start=2, end=3 returned lines 2, 3, 4
  • After: start=2, end=3 returns lines 2, 3

Testing

node --test website/scripts/copy-md-to-static.test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: NEW❗

Development

Successfully merging this pull request may close these issues.

1 participant

Comments