1

It is required in the finished lines to replace the characters with the corresponding html-code.

for example:

rules = {
    '<':'&lt;',
    '>':'&gt;'
}
sevnight
  • 105
  • 8
  • 1
    Rather than doing this, consider using something that manipulates a DOM and letting it encode the output. – Brad Sep 24 '18 at 14:02

1 Answers1

3

Since python 3.2 there is the html module with is escape function.

For example

>>> import html
>>> html.escape("5 > 3")
'5 &gt; 3'
kalehmann
  • 4,821
  • 6
  • 26
  • 36