MCPcopy Create free account
hub / github.com/openai/plugins / parseBlockScalar

Function parseBlockScalar

plugins/plugin-eval/src/lib/frontmatter.js:82–125  ·  view source on GitHub ↗
(lines, startIndex, parentIndent, style)

Source from the content-addressed store, hash-verified

80}
81
82function parseBlockScalar(lines, startIndex, parentIndent, style) {
83 const blockLines = [];
84 let index = startIndex;
85
86 while (index < lines.length) {
87 const line = lines[index];
88 const trimmed = line.trim();
89 const currentIndent = countIndent(line);
90
91 if (trimmed && currentIndent <= parentIndent) {
92 break;
93 }
94
95 blockLines.push(line);
96 index += 1;
97 }
98
99 const contentIndent = blockLines.reduce((minimumIndent, line) => {
100 const trimmed = line.trim();
101 if (!trimmed) {
102 return minimumIndent;
103 }
104 const currentIndent = countIndent(line);
105 if (currentIndent <= parentIndent) {
106 return minimumIndent;
107 }
108 return minimumIndent === null ? currentIndent : Math.min(minimumIndent, currentIndent);
109 }, null);
110
111 const normalizedLines = blockLines.map((line) => {
112 if (!line.trim()) {
113 return "";
114 }
115 if (contentIndent === null) {
116 return line.trim();
117 }
118 return line.slice(contentIndent);
119 });
120
121 return {
122 value: style === "|" ? normalizedLines.join("\n") : foldBlockScalarLines(normalizedLines),
123 nextIndex: index,
124 };
125}
126
127function parseBlock(lines, startIndex, indent) {
128 const firstIndex = nextMeaningfulIndex(lines, startIndex);

Callers 1

parseBlockFunction · 0.85

Calls 3

countIndentFunction · 0.85
foldBlockScalarLinesFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected