From 18acbec6ce83cd9c7c4ec2ff47f4beb2c662c065 Mon Sep 17 00:00:00 2001 From: Rick Hennigan Date: Tue, 21 Jan 2025 15:09:11 -0500 Subject: [PATCH] Bugfix: Some boxes serialized as graphics weren't recognized as graphics later on --- Source/Chatbook/Graphics.wl | 3 ++- Source/Chatbook/Serialization.wl | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Chatbook/Graphics.wl b/Source/Chatbook/Graphics.wl index d30ebdc0..ff457a16 100644 --- a/Source/Chatbook/Graphics.wl +++ b/Source/Chatbook/Graphics.wl @@ -16,7 +16,8 @@ $$graphicsPattern = HoldPattern @ Alternatives[ _Graphics3D, _Image, _Image3D, - _Legended + _Legended, + Dynamic[ RawBoxes[ _FEPrivate`ImportImage ], ___ ] ]; $$definitelyNotGraphics = HoldPattern @ Alternatives[ diff --git a/Source/Chatbook/Serialization.wl b/Source/Chatbook/Serialization.wl index 3ad7273a..b3ddc837 100644 --- a/Source/Chatbook/Serialization.wl +++ b/Source/Chatbook/Serialization.wl @@ -1190,7 +1190,11 @@ boxesToExpressionURI[ boxes_ ] := Replace[ Quiet @ ToExpression[ boxes, StandardForm, HoldComplete ], { - HoldComplete[ expr_ ] :> MakeExpressionURI @ Unevaluated @ expr, + HoldComplete[ expr_ ] :> ( + (* Ensure that the expression is recognized as a graphics expression later: *) + HoldPattern[ graphicsQ[ Verbatim @ expr ] ] = True; + MakeExpressionURI @ Unevaluated @ expr + ), _? FailureQ :> MakeExpressionURI[ "image", RawBoxes @ StyleBox[ boxes, "GraphicsRawBoxes" ] ] } ];