rikhuijzer / PlutoStaticHTML.jl

Convert Pluto notebooks to HTML in automated workflows
https://PlutoStaticHTML.huijzer.xyz
MIT License
83 stars 7 forks source link

Allow specific cells to contain errors #170

Open MichaelHatherly opened 1 year ago

MichaelHatherly commented 1 year ago

I've got some notebooks that intentionally have errors in specific cells for teaching purposes.

It would be great if there was a way to mark these cells as "expected errors" and just render the error in the output instead of stopping the notebook build with an error.

We've got a custom patched version of PlutoSliderServer which allows for specifying a list of cell UUIDs that we expect to have errors in, and any that error that aren't in that list cause the build to fail. Doing something similar could work here too, but would like your feedback @rikhuijzer for other potential solutions?

rikhuijzer commented 1 year ago

I’m don’t currently have a computer at hand, but have you seen https://github.com/rikhuijzer/PlutoStaticHTML.jl/issues/73? That might be related.

MichaelHatherly commented 1 year ago

Ah, yes, related. That's an option for us, though it does clutter up the notebook file itself for any users that are running it themselves.

rikhuijzer commented 1 year ago

Yeah I get that. Can you suggest how you would like the API to be?

MichaelHatherly commented 1 year ago

Can you suggest how you would like the API to be?

The API we've been using in our patched sliderserver is to pass a Dict of filename mapping to a list of UUIDs where we expect errors. E.g.

expected_errors = Dict(
    "1.jl" => [
        Base.UUID("fdee78e2-5932-11ee-2841-4b729906916f"),
    ],
    "subdir/2.jl" => [
        Base.UUID("1dee78e2-5932-11ee-2841-4b729906916a"),
    ]
)

and pass that as a keyword to the builder function.

It's not terribly elegant, granted.

rikhuijzer commented 1 year ago

Yes agreed on not so elegant, but I also cannot come up with something better. Can you make a PR? I’m okay with this API and would be happy to merge a PR