Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Style the output so that quotation marks (as string characters) appear
ResourceFunction["ShowQuotes"][expr] shows any quotation marks in expr rather than suppressing them. |
Without wrapping the output in ShowQuotes, the front end defaults to suppress presentation of the quotation marks. The ShowQuotes function styles the output so that the quotation marks are visible:
In[1]:= | ![]() |
Out[1]= | ![]() |
If there are no quotation marks in the input, no quotation marks appear in the output:
In[2]:= | ![]() |
Out[2]= | ![]() |
Nested quotation marks appear with the backslash escape character:
In[3]:= | ![]() |
Out[3]= | ![]() |
ShowQuotes works even if the input is already styled:
In[4]:= | ![]() |
Out[4]= | ![]() |
You can style the output from ShowQuotes:
In[5]:= | ![]() |
Out[5]= | ![]() |
Often, one might want to postfix ShowQuotes so that the textual input stands out:
In[6]:= | ![]() |
Out[6]= | ![]() |
ShowQuotes[x_] is equivalent to Style[x,ShowStringCharacters->True]. The purpose of the command is mostly to provide a simpler notation:
In[7]:= | ![]() |
Out[7]= | ![]() |
InputForm will generally result in the string characters being visible, but the cell label will have a //InputForm postfixed. Also, notice that the Head of the InputForm of "hello" is InputForm, whereas the Head of a ShowQuotes expression is Style:
In[8]:= | ![]() |
Out[72]= | ![]() |
In[73]:= | ![]() |
Out[73]= | ![]() |
Be wary of order of operations when using the postfix form of ShowQuotes:
In[74]:= | ![]() |
Out[74]= | ![]() |
In[75]:= | ![]() |
Out[75]= | ![]() |
In[76]:= | ![]() |
Out[76]= | ![]() |
ShowQuotes works within Dataset. Compare the following two outputs:
In[77]:= | ![]() |
Out[77]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License