@@ -14,7 +14,7 @@ superpowers.
1414
1515The simplest use is displaying text:
1616
17- ``` python
17+ ``` python title="Simple Python objects via display()"
1818from pyscript import display
1919
2020
@@ -29,7 +29,7 @@ page. Each call appends content unless you specify otherwise.
2929
3030Control where content appears using the ` target ` parameter:
3131
32- ``` python
32+ ``` python title="Specify where to display things."
3333from pyscript import display
3434
3535
@@ -45,7 +45,7 @@ display("Hello", target="#output-div")
4545By default, ` display() ` appends content. Use ` append=False ` to replace
4646existing content:
4747
48- ``` python
48+ ``` python title="Append or replace."
4949from pyscript import display
5050
5151
@@ -62,7 +62,7 @@ display("More content", target="output-div", append=True)
6262
6363Plain strings are automatically HTML-escaped for safety:
6464
65- ``` python
65+ ``` python title="Strings are escaped."
6666from pyscript import display
6767
6868
@@ -75,7 +75,7 @@ display("<script>alert('XSS')</script>")
7575
7676To display unescaped HTML, wrap it in the ` HTML ` class:
7777
78- ``` python
78+ ``` python title="The HTML class unescapes (handle with care!)"
7979from pyscript import HTML , display
8080
8181
@@ -93,7 +93,7 @@ display(HTML("<p>This is <strong>bold</strong> text.</p>"))
9393
9494Most Python objects display using their ` __repr__() ` method:
9595
96- ``` python
96+ ``` python title="Default behaviour via __repr__()."
9797from pyscript import display
9898
9999
@@ -120,7 +120,7 @@ display(Person("Bob"))
120120
121121Display images from various sources:
122122
123- ``` python
123+ ``` python title="Image handling."
124124from pyscript import display
125125
126126
@@ -162,7 +162,7 @@ Objects are checked for these methods in order of preference:
162162
163163Create objects that display beautifully:
164164
165- ``` python
165+ ``` python title="Custom HTML rendering."
166166from pyscript import display
167167
168168
@@ -199,7 +199,7 @@ display(ColourSwatch("#0000FF", "Blue"))
199199
200200Provide multiple representations for maximum compatibility:
201201
202- ``` python
202+ ``` python title="Define rendering via mime-type."
203203from pyscript import display
204204
205205
@@ -247,7 +247,7 @@ display(table)
247247When PyScript runs a ` <script type="mpy"> ` tag, ` display() ` outputs to
248248that script's location by default:
249249
250- ``` html
250+ ``` html title="Output at the & lt ; script & gt ; 's location in the DOM."
251251<div >
252252 <h2 >Output appears here:</h2 >
253253 <script type =" mpy" >
@@ -261,7 +261,7 @@ that script's location by default:
261261
262262Use the ` target ` attribute on your script tag to send output elsewhere:
263263
264- ``` html
264+ ``` html title="Specify an output target."
265265<div id =" results" ></div >
266266
267267<script type =" mpy" target =" results" >
@@ -293,7 +293,7 @@ This example demonstrates:
293293
294294** Never use ` HTML()` with untrusted content: **
295295
296- ` ` ` python
296+ ` ` ` python title="This is dangerous!"
297297# DANGEROUS - don't do this!
298298user_input = "<script>alert('XSS')</script>"
299299display(HTML(user_input))
@@ -316,7 +316,7 @@ For frequent or rapid updates:
316316
317317Keep display logic close to your data:
318318
319- ` ` ` python
319+ ` ` ` python title="_repr_ logic on a class."
320320class Report:
321321 def __init__(self, data):
322322 self.data = data
0 commit comments