Skip to content

Add async Lua execution, fetch_url, and blocking native support#107

Merged
gordonwoodhull merged 3 commits into
mainfrom
feature/async-lua
Apr 6, 2026
Merged

Add async Lua execution, fetch_url, and blocking native support#107
gordonwoodhull merged 3 commits into
mainfrom
feature/async-lua

Conversation

@gordonwoodhull

Copy link
Copy Markdown
Member

Summary

  • Make Lua filter/shortcode execution fully async, enabling yielding operations like network fetches during document rendering
  • Implement fetch_url for both native (reqwest) and WASM (JS fetch shim) runtimes, with pandoc.mediabag.fetch(url) support
  • Make AstTransform trait and the full shortcode resolution pipeline async to propagate async through the render pipeline
  • Use reqwest::blocking for native fetch_url since the render pipeline uses pollster::block_on (no tokio reactor)
  • Fix quarto.base64.encode to accept binary (non-UTF-8) data from fetched images
  • Add e2e smoke test for the full mediabag.fetchbase64.encode → data URI image pipeline

Test plan

  • E2e smoke test: image shortcode extension that fetches a local PNG via mediabag.fetch, base64-encodes it, and embeds as a data URI
  • Manual test: {{< placeholder 200 format=png >}} renders embedded PNG via native CLI
  • Manual test: {{< image url >}} shortcode works in both native and quarto-hub (WASM)
  • cargo nextest run --workspace — 7232 passed, 0 failed

Make Lua filter/shortcode execution async to support yielding operations
like network fetches. Implement fetch_url for both native (reqwest) and
WASM (JS fetch shim) runtimes. Make AstTransform trait and the full
shortcode resolution pipeline async to propagate async through the
render pipeline. Add pcall+async test and mediabag fetch error logging.
The native render pipeline uses pollster::block_on which provides no
tokio reactor. Switch NativeRuntime::fetch_url to reqwest::blocking::get
so HTTP requests work without an async runtime. Fix quarto.base64.encode
to accept binary (non-UTF-8) data. Add e2e smoke test exercising the
full mediabag.fetch -> base64.encode -> data URI image pipeline.
@gordonwoodhull gordonwoodhull merged commit 1b81920 into main Apr 6, 2026
4 checks passed
@gordonwoodhull gordonwoodhull deleted the feature/async-lua branch April 6, 2026 23:36
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.

1 participant