Skip to content

MarkdownToNotebook: captured kernel messages render as a plain text cell, not the styled MessageTemplate2 banner a live evaluation produces #43

Description

@mbahram

Summary

When MarkdownToNotebook[..., "Evaluate" -> True] captures a message emitted by an executable cell, messageCell[s_String] wraps the captured text in a bare Cell[s, "Message", "MSG"] — plain, unstyled text. An interactive front end renders the same message as a TemplateBox[{...}, "MessageTemplate2"] styled banner, carrying {symbol, tag, formatted-text, 2, 1, 2, id, "Local", full-name} and prefixed with a During evaluation of In[n]:= cell label.

As a result, captured messages in a built notebook do not look like what the same code produces when evaluated live: no styled banner, no "During evaluation of" label, no message-suppression affordance.

Repro

# T

```wl #| eval: true
Sqrt[x] /. x -> {1, 2, 3}

A cell that throws (e.g. a `::tag` message) captures the message text and currently emits it as a plain `Cell["Sym::tag: body", "Message", "MSG"]`.

## Expected

The captured `Sym::tag: body` text is reconstructed as the front end's `MessageTemplate2` `TemplateBox`, so the built cell matches a live evaluation (styled banner + `During evaluation of In[1]:=` label). A string that is **not** in `Symbol::tag` form should fall back to the plain text `Message` cell.

## Notes (root cause)

`messageCell[s_String]` in `MarkdownToNotebook.wl`. The kernel only ever writes a message as text; the styled box is an FE rendering. Reconstruct it by parsing `Sym::tag: body` and emitting the `MessageTemplate2` box. The `id` / context args drive only the suppression menu, not the display (rendering is identical for any id/context), so a best-effort `Names[sym]` is sufficient; the formatted body must be a quoted string box (`ToString[.., InputForm]`) or the FE parses a `-` in the text as a math operator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions