fix(media): keep each index.md row on one line and show control characters as escapes (#8127)

The .media/index.md generators (figma's mediaIndex.ts and media-use's
index-gen.mjs) turned only CR and LF in a record into a space. Vertical
tab, form feed, NEL, U+2028 and U+2029 still ended a row early for
readers that treat them as line breaks, and other control characters
(NUL, ESC, BEL, C1) reached the file as raw bytes.

- Every line-ending character now becomes a space.
- Other control characters are written as visible \xNN escapes through
  the existing terminalText helper; tabs stay as they are.
- Both generators and the skill copy change together, so their output
  stays byte-identical.
This commit is contained in:
andybpan
2026-11-18 03:05:02 +00:00
committed by GitHub
parent e6cee094b1
commit ebddc42486
5 changed files with 39 additions and 8 deletions
+4 -2
View File
@@ -1,8 +1,10 @@
import { currentRecords, indexPath, ownMediaDir, replaceFile } from "./manifest.mjs";
import { terminalText } from "./terminal-text.mjs";
const LINE_BREAKS = /\s*[\r\n\v\f\u0085\u2028\u2029]+\s*/g;
// One table cell: a line break in a record would start a new line of the index, so it becomes a space.
function cell(value) {
return String(value ?? "").replace(/\s*[\r\n]+\s*/g, " ");
return terminalText(String(value ?? "").replace(LINE_BREAKS, " "));
}
function pad(str, len) {