Skip to content

Improve RunScript/script components#248

Merged
janezd merged 1 commit into
biolab:masterfrom
janezd:improve-script-elements
Jun 15, 2026
Merged

Improve RunScript/script components#248
janezd merged 1 commit into
biolab:masterfrom
janezd:improve-script-elements

Conversation

@janezd

@janezd janezd commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Important: After merging this, rerun ingestion for notes and pumice. RunScript used to pass the code as children, now it uses a prop code, so the currently compiled code in the database won't work.

Implement a remark plugin that eliminates the need to enclose RunScript children into `{``.

Also replace <script> elements with <RunScript> so that they're executed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the MDX ingestion/rendering pipeline to make <RunScript> easier to author in MDX and to ensure raw <script> tags are executed by converting them into <RunScript> during ingestion.

Changes:

  • Added a new remark plugin that rewrites <RunScript>...</RunScript> and <script>...</script> into <RunScript code="..."/>.
  • Wired the new plugin into the MDX compile step.
  • Updated the runtime RunScript component implementation to eval a code prop instead of using children.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ingest/plugins.ts Adds backtickRunScript remark plugin to rewrite <script>/<RunScript> nodes into <RunScript code="...">.
ingest/md-helpers.ts Registers the new remark plugin in the MDX compilation pipeline.
components/MdxContent.tsx Updates the MDX component mapping for RunScript to eval a code prop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ingest/plugins.ts
Comment thread components/MdxContent.tsx
Comment on lines +158 to +169
RunScript: ({code}: {code: string}) => {
React.useEffect(() => {
if (window === undefined) {
return;
}

try {
eval(children);
eval(code);
} catch (err) {
console.error("RunScript error:", err);
}
}, [children]),
}, [code])
},
@janezd janezd force-pushed the improve-script-elements branch from f810881 to 96d3b1d Compare June 15, 2026 09:19
@janezd janezd merged commit f33cb83 into biolab:master Jun 15, 2026
1 check passed
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