Reputation: 16199
Using the two texts given by PyMOTW, difflib.HtmlDiff.make_file()
is used to produce HTML output. Yet when saved and opened in a browser, the raw HTML is displayed rather than rendered as the expected table.
Is the output of make_file()
malformed? See here.
Python 2.7
Upvotes: 2
Views: 1879
Reputation: 17592
I am using python 3.5, and I am getting the html content as given in your link correctly rendered without any modification. You asked about make_table
and make_file
. This is from the link you have given:
This example uses make_table(), which only returns the table tag containing the difference information. The make_file() method produces a fully-formed HTML file as output.
So the output you have shown is from make_file()
, not make_table()
.
If you are using django (just a wild guess) try this:
{% autoescape off %}
{{ your_html_content }}
{% endautoescape %}
You can also do the same using safe:
{{ your_table_content|safe }}
From django docs:
Marks a string as not requiring further HTML escaping prior to output. When autoescaping is off, this filter has no effect
Upvotes: 1