Skip to content

Commit 9802462

Browse files
committed
remove include support
1 parent 69be6f4 commit 9802462

File tree

1 file changed

+39
-52
lines changed

1 file changed

+39
-52
lines changed

src/core/handlers/include.ts

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ import {
1818
import { rangedLines } from "../lib/ranged-text.ts";
1919
import { isBlockShortcode } from "../lib/parse-shortcode.ts";
2020
import { DirectiveCell } from "../lib/break-quarto-md-types.ts";
21-
import {
22-
notebookMarkdownPlaceholder,
23-
parseNotebookAddress,
24-
} from "../jupyter/jupyter-embed.ts";
2521

2622
const includeHandler: LanguageHandler = {
2723
...baseHandler,
@@ -49,62 +45,53 @@ const includeHandler: LanguageHandler = {
4945
);
5046
}
5147

52-
const notebookAddress = parseNotebookAddress(filename);
53-
if (notebookAddress) {
54-
const outputs = directive.shortcode.namedParams.outputs as
55-
| string
56-
| undefined;
57-
const placeHolder = notebookMarkdownPlaceholder(filename, {}, outputs);
58-
textFragments.push(placeHolder);
59-
} else {
60-
let includeSrc;
61-
try {
62-
includeSrc = asMappedString(
63-
Deno.readTextFileSync(path),
64-
path,
65-
);
66-
} catch (_e) {
67-
const errMsg: string[] = [`Include directive failed.`];
68-
errMsg.push(...retrievedFiles.map((s) => ` in file ${s}, `));
69-
errMsg.push(
70-
` could not find file ${path
71-
// relative(handlerContext.options.context.target.source, path)
72-
}.`,
73-
);
74-
throw new Error(errMsg.join("\n"));
75-
}
48+
let includeSrc;
49+
try {
50+
includeSrc = asMappedString(
51+
Deno.readTextFileSync(path),
52+
path,
53+
);
54+
} catch (_e) {
55+
const errMsg: string[] = [`Include directive failed.`];
56+
errMsg.push(...retrievedFiles.map((s) => ` in file ${s}, `));
57+
errMsg.push(
58+
` could not find file ${path
59+
// relative(handlerContext.options.context.target.source, path)
60+
}.`,
61+
);
62+
throw new Error(errMsg.join("\n"));
63+
}
7664

77-
retrievedFiles.push(filename);
78-
79-
let rangeStart = 0;
80-
for (const { substring, range } of rangedLines(includeSrc.value)) {
81-
const m = isBlockShortcode(substring);
82-
if (m && m.name.toLocaleLowerCase() === "include") {
83-
textFragments.push(
84-
mappedString(includeSrc, [{
85-
start: rangeStart,
86-
end: range.start,
87-
}]),
88-
);
89-
rangeStart = range.end;
90-
const params = m.params;
91-
if (params.length === 0) {
92-
throw new Error("Include directive needs file parameter");
93-
}
94-
95-
await retrieveInclude(params[0]);
96-
}
97-
}
98-
if (rangeStart !== includeSrc.value.length) {
65+
retrievedFiles.push(filename);
66+
67+
let rangeStart = 0;
68+
for (const { substring, range } of rangedLines(includeSrc.value)) {
69+
const m = isBlockShortcode(substring);
70+
if (m && m.name.toLocaleLowerCase() === "include") {
9971
textFragments.push(
10072
mappedString(includeSrc, [{
10173
start: rangeStart,
102-
end: includeSrc.value.length,
74+
end: range.start,
10375
}]),
10476
);
77+
rangeStart = range.end;
78+
const params = m.params;
79+
if (params.length === 0) {
80+
throw new Error("Include directive needs file parameter");
81+
}
82+
83+
await retrieveInclude(params[0]);
10584
}
106-
textFragments.push(includeSrc.value.endsWith("\n") ? "\n" : "\n\n");
10785
}
86+
if (rangeStart !== includeSrc.value.length) {
87+
textFragments.push(
88+
mappedString(includeSrc, [{
89+
start: rangeStart,
90+
end: includeSrc.value.length,
91+
}]),
92+
);
93+
}
94+
textFragments.push(includeSrc.value.endsWith("\n") ? "\n" : "\n\n");
10895

10996
retrievedFiles.pop();
11097
};

0 commit comments

Comments
 (0)