Skip to content

Commit b96ba51

Browse files
committed
Add support for echo param in embeds
1 parent c742fac commit b96ba51

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/core/handlers/embed.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface EmbedHandler {
2323
name: string;
2424
handle(
2525
filename: string,
26+
params: Record<string, unknown>,
2627
handlerContext: LanguageCellHandlerContext,
2728
): Promise<{
2829
handled: boolean;
@@ -34,16 +35,21 @@ interface EmbedHandler {
3435
const kHandlers: EmbedHandler[] = [
3536
{
3637
name: "Jupyter Notebook Embed",
37-
handle(filename: string, _handlerContext: LanguageCellHandlerContext) {
38+
handle(
39+
filename: string,
40+
params: Record<string, unknown>,
41+
_handlerContext: LanguageCellHandlerContext,
42+
) {
3843
const markdownFragments: EitherString[] = [];
3944

4045
// Resolve the filename into a path
4146
const notebookAddress = parseNotebookAddress(filename);
4247
if (notebookAddress) {
4348
const placeHolder = notebookMarkdownPlaceholder(filename, {
44-
echo: false,
49+
echo: params.echo !== undefined ? params.echo as boolean : false,
4550
warning: false,
4651
asis: true,
52+
eval: false,
4753
});
4854

4955
markdownFragments.push(placeHolder);
@@ -86,7 +92,11 @@ const embedHandler: LanguageHandler = {
8692

8793
// Go through handlers until one handles the embed by returning markdown
8894
for (const handler of kHandlers) {
89-
const result = await handler.handle(filename, handlerContext);
95+
const result = await handler.handle(
96+
filename,
97+
directive.shortcode.namedParams,
98+
handlerContext,
99+
);
90100
if (result.handled) {
91101
textFragments.push(...result.markdownFragments);
92102
if (result.resources) {

0 commit comments

Comments
 (0)