Files
archify-vscode-ext/scripts/vendor/yaml/compose/util-contains-newline.js
T
root-at-skic b6b5e57922 Add archify-vscode-ext skill: Archify diagrams and models for the Archify Diagram Viewer extension
Model tasks (validate, list, scaffold, resolve), diagram tasks (validate,
render), the bundled Archify 3.0.1 runtime and yaml parser under
scripts/vendor, references for authoring, formats and folders, and the
online-shop example model.
2026-10-19 11:42:06 +03:00

35 lines
1.0 KiB
JavaScript

function containsNewline(key) {
if (!key)
return null;
switch (key.type) {
case 'alias':
case 'scalar':
case 'double-quoted-scalar':
case 'single-quoted-scalar':
if (key.source.includes('\n'))
return true;
if (key.end)
for (const st of key.end)
if (st.type === 'newline')
return true;
return false;
case 'flow-collection':
for (const it of key.items) {
for (const st of it.start)
if (st.type === 'newline')
return true;
if (it.sep)
for (const st of it.sep)
if (st.type === 'newline')
return true;
if (containsNewline(it.key) || containsNewline(it.value))
return true;
}
return false;
default:
return true;
}
}
export { containsNewline };