Skip to content

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Dec 30, 2025

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

```{python.marimo}

This already works fine as long as the engine is directly specified in the metadata

engine: marimo

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:

  claimsLanguage: (language: string, firstClass?: string) => boolean | number;

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

gordonwoodhull and others added 2 commits December 30, 2025 11:21
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 <[email protected]>
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 <[email protected]>
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Dec 30, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gordonwoodhull gordonwoodhull changed the title feature: engine claim class feature: engine claim by language and class Dec 30, 2025
gordonwoodhull and others added 2 commits December 30, 2025 12:14
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 <[email protected]>
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 <[email protected]>
@gordonwoodhull gordonwoodhull force-pushed the feature/engine-claim-class branch from f6b0d92 to 022f9cd Compare December 30, 2025 18:24
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.

3 participants