Skip to content

Commit 0b8bc98

Browse files
committed
Use the parsed cellSourceWithYAML from breakQuartoMd
No need to count character as the current parser does it already.
1 parent 32e5295 commit 0b8bc98

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/core/schema/validate-document.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ export async function validateDocumentFromSource(
9797
} else {
9898
firstContentCellIndex = 0;
9999
}
100-
101100
for (const cell of nb.cells.slice(firstContentCellIndex)) {
102101
if (
103102
cell.cell_type === "markdown" ||
104-
cell.cell_type === "raw"
103+
cell.cell_type === "raw" ||
104+
cell.cell_type?.language === "_directive"
105105
) {
106106
// not a language chunk
107107
continue;
@@ -110,16 +110,14 @@ export async function validateDocumentFromSource(
110110
const lang = cell.cell_type.language;
111111

112112
try {
113-
const fullCell = mappedString(cell.sourceVerbatim, [{
114-
start: lang.length + 6,
115-
end: cell.sourceVerbatim.value.length - 3,
116-
}]);
117-
await partitionCellOptionsMapped(
118-
lang,
119-
fullCell,
120-
true,
121-
engine,
122-
);
113+
if (cell.sourceWithYaml) {
114+
await partitionCellOptionsMapped(
115+
lang,
116+
cell.sourceWithYaml,
117+
true,
118+
engine,
119+
);
120+
}
123121
} catch (e) {
124122
if (e instanceof ValidationError) {
125123
error("Validation of YAML cell metadata failed.");

tests/smoke/yaml-intelligence/yaml-intelligence-code-cell-options.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ const yamlDocs = fileLoader("yaml");
77
const testYamlValidationFails = (file: string) => {
88
testQuartoCmd(
99
"render",
10-
[yamlDocs(file, "html").input, "--to", "html", "--log-level", "error", "--quiet"],
10+
[yamlDocs(file, "html").input, "--to", "html", "--quiet"],
1111
[printsMessage("ERROR", /Validation of YAML cell metadata failed/)],
1212
);
1313
};
1414

1515
const files = [
1616
"fail-validation-knitr.qmd",
17-
"fail-validation-jupyter.qmd",
18-
"fail-validation-julia.qmd",
1917
"fail-validation-knitr-backticks.qmd",
18+
"fail-validation-jupyter.qmd",
2019
"fail-validation-jupyter-backticks.qmd",
21-
"fail-validation-julia-backticks.qmd",
20+
// FIXME: Activate this when Quarto schema for Julia engine
21+
//"fail-validation-julia.qmd",
22+
//"fail-validation-julia-backticks.qmd",
2223
];
2324

2425
files.forEach(testYamlValidationFails);

0 commit comments

Comments
 (0)