the string is a samp¤
the semantics of a string output are ambiguous to other outputs. we suggest that strings should be represented with the samp
tag.
string displays¤
the standard python display wraps a string in single questions.
example = "this is the example"
example
we could acheive a similar representation with the native samp
element.
from IPython.display import HTML
HTML(F"<samp>{example}</samp>")
the samp
provides double quotes by default with monospace text. it almost exactly mimics the standard display if you are specific about your quotes.
best solution¤
the best solution would associate the string with the variable. the quickest semantic solution i can think of would look close to.
HTML(F"""<figure>
<samp>{example}</samp>
<figcaption><var>example</var></figcaption>
</figure>""")
string representations in code.¤
if we are display code containing a string then the story is different. consider the first snippet of python code.
example = "this is the example"
example
the source of the string in the code would have the following semantics. when samp
contains kbd
it indicates an actual key or other unit of input as a portion of a larger input
HTML(html := """
<pre><code>
<var>example</var> = <span hidden="">"</span><samp><kbd>this is the example</kbd></samp><span hidden="">"</span>
<var>example</var>
</code></pre>
""")
wraps¤
- we explored a few confomrations of the
samp
tag. it seems to hold up as a good semantic for input and output strings. - a consistent use of the
var
tag in code representations and outputs would allow more complex relationships to be inferred from the document.