4 ms·
It's a bit funny because it's actually hard to represent Python code in regular HTML, exactly because of this collapsing. For example, here is some Python code
by simiones 3y ago
It's a bit funny because it's actually hard to represent Python code in regular HTML, exactly because of this collapsing.
For example, here is some Python code typed correctly in the comment box but rendered without the code formatting support (using a | at beginning of line to prevent the code formatting to kick in):
|def foo(flag):
| if flag:
| print("this is indented")
| print("is this?")
If you check the HTML, it looks like this:
<p>|def foo(flag):</p>
<p>| if flag:</p>
<p>| print("this is indented")</p>
<p>| print("is this?")</p>
- distcs 3y ago> it's actually hard to represent Python code in regular HTML It is not hard. Just use the right tag. You want the <pre> tag here. Here, fixed it for you: def foo(flag): if flag: print("this is indented") print("is this?")