-
Notifications
You must be signed in to change notification settings - Fork 396
feature: engine claim by language and class #13838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The functions in engine-shared.ts (languagesInMarkdown, languagesInMarkdownFile, postProcessRestorePreservedHtml) have identical implementations in src/core/pandoc/pandoc-partition.ts and src/core/jupyter/preserve.ts. Update imports to use the canonical locations and remove the duplicate file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add support for extracting the first class from code block attributes
(e.g., {python .marimo}) and passing it to engine's claimsLanguage method.
Changes:
- Add languagesWithClasses() function returning Map<language, class|undefined>
- Update languagesInMarkdown() to use languagesWithClasses internally
- Update claimsLanguage signature to accept optional firstClass parameter
and return boolean | number for priority-based selection
- Update markdownExecutionEngine to use scoring: highest score wins,
first engine wins ties (backwards compatible)
- Expose getLanguagesWithClasses in the markdownRegex API namespace
Backwards compatibility:
- Old engines returning true -> score 1
- Old engines returning false -> score 0
- New engines can return numbers > 1 to override
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Update the `quarto create extension engine` template to reflect the new claimsLanguage signature that accepts an optional firstClass parameter and returns boolean | number for priority-based selection. No behavioral change - just updated signature and documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use breakQuartoMd API for cell iteration instead of raw regex, making
the code more idiomatic and fixing Windows CI failures caused by line
ending differences. Also fix test syntax to use {python .foo}
(space-separated) which is recognized by breakQuartoMd.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f6b0d92 to
022f9cd
Compare
|
It needs to have a space in order to be compatible with the way we are going to handle this going forward. ```{python .marimo}The situation in Quarto 1.9 is that we split execution cell blocks with regexes and everything after the language in executable is handled as raw text by the execution engine. In the near future, we will have a proper parser for Quarto markdown, so these will need to follow Pandoc's conventions, allowing I also need to change Hope to get these fixes in and update my fork of quarto-marimo in the next week. |
Apologies for filing a PR over holidays. We can discuss next week when everyone is back, but I wanted to put in a draft.
Marimo's preferred syntax for executable cells is
This already works fine as long as the engine is directly specified in the metadata
But the engine won't claim the language without this, because jupyter claims python.
I think it would be nice for us to support claiming by both language and first class, because it allows engine discovery to resolve in favor of an engine extension when the extension supports the same language as a built-in engine.
It can be done in a backward-compatible way:
Where old engines still return true, false, treated as 1 or 0, and new engines can return 2.
But this is a fundamental change to engine discovery, so I want to discuss as a group before merging.
@dmadisetti