I want to use curly brackets in rich text markdown

What I’m trying to do:
In the Anvil design editor, I want to display some Python code, which includes empty curly brackets, in a Rich Text box, using markdown.

What I’ve tried and what’s not working:

Python Code Sample:

mydict = dict()  # this works OK
mydict["keyname"] = "value"

However if I use this format:

mydict = {}  # (using curly brackets)
mydict["keyname"] = "value"

The curly brackets disappear.
I have tried escaping the curly brackets to no avail:

mydict = \{\} # (can see them now - but also the escape character)

By the way - it looks OK in the editor, but disappear when you RUN the app.

Is there some other way to display curly brackets in markdown?
Regards, Chris

just like fstrings use double curly braces when you need an actual curly brace

self.richtext.content = """
```python
mydict = {{}}
mydict["keyname"] = "value"
```
"""

Similarly if you ever just need a left or right curly brace use {{ or }}.

1 Like

Stu - you are a star!
That did the trick, and thanks for your speedy reply.
Regards, Chris