Considering the Lukas Lang’s solution to formalize symbols with a Button
, given in the post: How can I create a shortcut to convert "normal Symbol" to Formal Symbol?, I've created the following Button
to Unformalize:
Button["Unformalize",
NotebookWrite[EvaluationNotebook[],
NotebookRead[EvaluationNotebook[]] /.
s_String /; StringLength[s] == 1 :>
With[{char = StringReplace[CharacterName[s], {"Formal" -> ""}]},
If[MemberQ[{"Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta",
"Eta", "Theta", "Iota", "Kappa", "Lambda",
"Mu", "Nu", "Xi", "Omicron", "Pi", "Rho",
"Sigma", "Tau", "Upsilon", "Phi", "Chi",
"Psi", "Omega"}, char], "\\[" <> char <> "]",
If[StringContainsQ[char, "Capital"], StringReplace[char, "Capital" ~~ l_ :> l],
ToLowerCase[char]]]]]]
The "Unformalize" button works perfectly when applied to individual formal symbols, but when I select a list of formal symbols, the button does not behave as expected. It seems like the transformation is not applied to each symbol in the list.
I attempted to modify the logic to process each element in a list recursively, but so far, I haven't managed to achieve the desired functionality.
How can I modify the "Unformalize" button so that it works correctly for both individual symbols and lists of symbols? Any help or insights would be greatly appreciated. Thanks in advance!