Skip to content

only set the display and view builtins in js and ts cells#172

Merged
mbostock merged 5 commits into
mainfrom
fil/display-builtins
Jun 15, 2026
Merged

only set the display and view builtins in js and ts cells#172
mbostock merged 5 commits into
mainfrom
fil/display-builtins

Conversation

@Fil

@Fil Fil commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

This allows to support a symbol created in ojs with the name view or display:

Capture d’écran 2026-06-15 à 15 30 41

I figured it would also be cleaner to not have view or display in the HTML, md, and tex cells, where they don't work.

@Fil Fil requested a review from mbostock June 15, 2026 13:32

@mbostock mbostock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. 👍 I just don’t like the name displayBuiltins for the option… let me think some more but maybe send candidates my way, thank you.

Comment thread src/javascript/transpile.ts Outdated
? transpileJavaScript(transpileTemplate(cell), options)
: transpileJavaScript(input, options);
if (transpiled.output === undefined) transpiled.output = cell.output;
if (mode === "js" || mode === "ts") transpiled.displayBuiltins = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange to override the user’s setting based on mode. Did you want to provide a default for displayBuiltins instead, like displayBuiltins = mode === "ojs"? Also I think the logic is inverted in that we just want to suppress for ojs, not that we want to suppress for everything except js and ts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point in inverting the logic is that in other cells (like md, html), these builtins don't work anyway? But either way is fine.

Words: displaycallbacks, celldisplay, stdout, printer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they do work, they just display another thing (apart from whatever the template cell evaluates too). But that’s a pretty obscure application of display, and if we allow view and display in template cells then you wouldn’t be able to embed another cell of that name… so you probably had it right the first time! I’ll take another look tonight.

@mbostock mbostock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn’t need to be part of transpile and TranspiledJavaScript, given that it corresponds directly to the passed-in mode and is not depend on the source code in any way; it can just be an option that is passed in to define. I’ll simplify.

@mbostock mbostock merged commit 85b699a into main Jun 15, 2026
1 check passed
@mbostock mbostock deleted the fil/display-builtins branch June 15, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants