Zulip Chat Archive

Stream: lean4

Topic: Widgets not displaying on some terms


Eric Wieser (Apr 19 2024 at 14:13):

In the following example, the widget only displays in one place:

import ProofWidgets.Component.HtmlDisplay

open Lean ProofWidgets Jsx

syntax "foo" term : term
elab_rules : term
| `(term| foo%$stx $t) => do
  let ht := <h2>Hello world</h2>
  Widget.savePanelWidgetInfo (hash HtmlDisplayPanel.javascript)
    (return json% { html: $( Server.RpcEncodable.rpcEncode ht) }) stx
  Elab.Term.elabTerm t none

example : Nat := foo 1 -- widget
example : Nat := foo (by exact 1) -- no widget

Am I passing the wrong syntax to savePanelWidgetInfo, or is this a bug?

Eric Wieser (Apr 19 2024 at 14:31):

Using Elab.Term.elabTerm (← `(term| id $t)) none seems to fix it, but I'd rather not insert the id term

Eric Wieser (Apr 19 2024 at 14:35):

Ah, wrapping with return Expr.mdata {} e also works

𝚠𝚘𝚓𝚌𝚒𝚎𝚌𝚑 𝚗𝚊𝚠𝚛𝚘𝚌𝚔𝚒 (Apr 19 2024 at 22:40):

This is quite bizarre, the adjacent term should make no difference to whether the widget is displayed (since you put it on stx, not on t). I made an issue, lean4#3956.


Last updated: May 02 2025 at 03:31 UTC