PlutoStaticHTML.jl icon indicating copy to clipboard operation
PlutoStaticHTML.jl copied to clipboard

Allow specific cells to contain errors

Open MichaelHatherly opened this issue 9 months ago • 5 comments

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?

MichaelHatherly avatar Sep 22 '23 10:09 MichaelHatherly

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.

rikhuijzer avatar Sep 22 '23 11:09 rikhuijzer

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.

MichaelHatherly avatar Sep 22 '23 13:09 MichaelHatherly

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

rikhuijzer avatar Sep 22 '23 13:09 rikhuijzer

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.

MichaelHatherly avatar Sep 22 '23 14:09 MichaelHatherly

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

rikhuijzer avatar Sep 23 '23 12:09 rikhuijzer