@@ -199,15 +199,23 @@ $boxOp = <| SuperscriptBox -> "^", SubscriptBox -> "_" |>;
199
199
200
200
(* How to choose TemplateBox arguments for serialization *)
201
201
$templateBoxRules = < |
202
- "AssistantMessageBox" -> First ,
203
- "ConditionalExpression" -> makeExpressionString ,
204
- "GrayLink" -> First ,
205
- "HyperlinkDefault" -> First ,
206
- "Key0" -> First ,
207
- "Key1" -> (Riffle [ # , "-" ] & ),
208
- "RowDefault" -> Identity ,
209
- "TransferFunctionModelFull" -> makeExpressionString ,
210
- "UserMessageBox" -> First
202
+ "AssistantMessageBox" -> First ,
203
+ "ConditionalExpression" -> makeExpressionString ,
204
+ "GrayLink" -> First ,
205
+ "HyperlinkDefault" -> First ,
206
+ "Key0" -> First ,
207
+ "Key1" -> (Riffle [ # , "-" ] & ),
208
+ "RowDefault" -> Identity ,
209
+ "TransferFunctionModelFull" -> makeExpressionString ,
210
+ "UserMessageBox" -> First ,
211
+ "CMYKColorSwatchTemplate" -> inputFormString @ * Lookup [ "color" ],
212
+ "GrayLevelColorSwatchTemplate" -> inputFormString @ * Lookup [ "color" ],
213
+ "HueColorSwatchTemplate" -> inputFormString @ * Lookup [ "color" ],
214
+ "LABColorSwatchTemplate" -> inputFormString @ * Lookup [ "color" ],
215
+ "LCHColorSwatchTemplate" -> inputFormString @ * Lookup [ "color" ],
216
+ "LUVColorSwatchTemplate" -> inputFormString @ * Lookup [ "color" ],
217
+ "RGBColorSwatchTemplate" -> inputFormString @ * Lookup [ "color" ],
218
+ "XYZColorSwatchTemplate" -> inputFormString @ * Lookup [ "color" ]
211
219
|> ;
212
220
213
221
(* ::**************************************************************************************************************:: *)
@@ -232,6 +240,7 @@ $$graphicsBox = Alternatives[
232
240
(* Serialize the first argument of these and ignore the rest *)
233
241
$stringStripHeads = Alternatives [
234
242
ActionMenuBox ,
243
+ AdjustmentBox ,
235
244
ButtonBox ,
236
245
CellGroupData ,
237
246
FrameBox ,
@@ -1300,6 +1309,10 @@ fasterCellToString0[ TemplateBox[ args: { _, _, str_String, ___ }, "MessageTempl
1300
1309
fasterCellToString0 @ str
1301
1310
);
1302
1311
1312
+ (* Percent References *)
1313
+ fasterCellToString0 [ TemplateBox [ KeyValuePattern [ "OutNumber" -> n_ Integer ], "PercentRef" , ___ ] ] :=
1314
+ "%" <> ToString @ n ;
1315
+
1303
1316
(* Large Outputs *)
1304
1317
fasterCellToString0 [ TemplateBox [ KeyValuePattern [ "shortenedBoxes" -> boxes_ ], "OutputSizeLimitTemplate" , ___ ] ] :=
1305
1318
fasterCellToString0 @ boxes ;
@@ -1487,12 +1500,6 @@ fasterCellToString0[ box: TemplateBox[ args_, name_String, ___ ] ] :=
1487
1500
fasterCellToString0 @ f @ args /; ! MissingQ @ f && f =!= makeExpressionString
1488
1501
];
1489
1502
1490
- fasterCellToString0 [ TemplateBox [ { args___ }, ___ , InterpretationFunction -> f_ , ___ ] ] :=
1491
- fasterCellToString0 @ f @ args ;
1492
-
1493
- fasterCellToString0 [ TemplateBox [ args_ , ___ , InterpretationFunction -> f_ , ___ ] ] :=
1494
- fasterCellToString0 @ f @ args ;
1495
-
1496
1503
fasterCellToString0 [ OverlayBox [ { a_ , ___ }, ___ ] ] :=
1497
1504
fasterCellToString0 @ a ;
1498
1505
@@ -2303,6 +2310,64 @@ fasterCellToString0[ DynamicModuleBox[ a___ ] ] /; ! TrueQ @ $CellToStringDebug
2303
2310
"DynamicModule[\[ LeftSkeleton]" <> ToString @ Length @ HoldComplete @ a <> "\[ RightSkeleton]]"
2304
2311
);
2305
2312
2313
+ (* ::**************************************************************************************************************:: *)
2314
+ (* ::Subsubsubsection::Closed:: *)
2315
+ (*Unhandled TemplateBoxes*)
2316
+ fasterCellToString0 [ box : TemplateBox [ args_ , ___ ] ] :=
2317
+ With [ { f = getTemplateBoxFunction @ box },
2318
+ fasterCellToString0 @ applyTemplateBoxDisplayFunction [ f , args ] /; ! MissingQ @ f
2319
+ ];
2320
+
2321
+ (* ::**************************************************************************************************************:: *)
2322
+ (* ::Subsubsubsubsection::Closed:: *)
2323
+ (*getTemplateBoxFunction*)
2324
+ getTemplateBoxFunction // beginDefinition ;
2325
+ getTemplateBoxFunction [ TemplateBox [ __ , InterpretationFunction -> f : Except [ $$unspecified ], ___ ] ] := f ;
2326
+ getTemplateBoxFunction [ TemplateBox [ __ , DisplayFunction -> f : Except [ $$unspecified ], ___ ] ] := f ;
2327
+ getTemplateBoxFunction [ TemplateBox [ _ , name_ String , ___ , InterpretationFunction -> Automatic , ___ ] ] := name ;
2328
+ getTemplateBoxFunction [ TemplateBox [ _ , name_ String , ___ ] ] := getTemplateBoxFunction @ name ;
2329
+ getTemplateBoxFunction [ name_ String ] := Lookup [ $templateBoxCache , name , getTemplateBoxFunction0 @ name ];
2330
+ getTemplateBoxFunction // endDefinition ;
2331
+
2332
+
2333
+ getTemplateBoxFunction0 // beginDefinition ;
2334
+
2335
+ getTemplateBoxFunction0 [ name_ String ] :=
2336
+ getTemplateBoxFunction0 [ name , usingFrontEnd @ CurrentValue @ { StyleDefinitions , name , TemplateBoxOptions } ];
2337
+
2338
+ getTemplateBoxFunction0 [
2339
+ name_ ,
2340
+ KeyValuePattern [ InterpretationFunction |"InterpretationFunction" -> f : Except [ $$unspecified ] ]
2341
+ ] := $templateBoxCache [ name ] = f ;
2342
+
2343
+ getTemplateBoxFunction0 [
2344
+ name_ ,
2345
+ KeyValuePattern [ InterpretationFunction |"InterpretationFunction" -> Automatic ]
2346
+ ] := $templateBoxCache [ name ] = name ;
2347
+
2348
+ getTemplateBoxFunction0 [
2349
+ name_ ,
2350
+ KeyValuePattern [ DisplayFunction |"DisplayFunction" -> f : Except [ $$unspecified ] ]
2351
+ ] := $templateBoxCache [ name ] = f ;
2352
+
2353
+ getTemplateBoxFunction0 [ name_ , _ ] :=
2354
+ $templateBoxCache [ name ] = Missing [ "NotFound" ];
2355
+
2356
+ getTemplateBoxFunction0 // endDefinition ;
2357
+
2358
+
2359
+ $templateBoxCache = < | |> ;
2360
+
2361
+ (* ::**************************************************************************************************************:: *)
2362
+ (* ::Subsubsubsubsection::Closed:: *)
2363
+ (*applyTemplateBoxDisplayFunction*)
2364
+ applyTemplateBoxDisplayFunction // beginDefinition ;
2365
+ applyTemplateBoxDisplayFunction [ f_ , TemplateBox [ args_ , ___ ] ] := applyTemplateBoxDisplayFunction [ f , args ];
2366
+ applyTemplateBoxDisplayFunction [ f_ String , a_ List ] := f <> "[" <> StringRiffle [ fasterCellToString0 /@ a , ", " ] <> "]" ;
2367
+ applyTemplateBoxDisplayFunction [ f_ , { args___ } ] := f @ args ;
2368
+ applyTemplateBoxDisplayFunction [ f_ , args___ ] := f @ args ;
2369
+ applyTemplateBoxDisplayFunction // endDefinition ;
2370
+
2306
2371
(* ::**************************************************************************************************************:: *)
2307
2372
(* ::Subsubsubsection::Closed:: *)
2308
2373
(*Ignored/Skipped*)
0 commit comments