+ surf.write_to_png (open (pngfile, "wb"))
+
+ # if solution is false, publish the clues and the image in a HTML file
+ if htmlfile and solution is False:
+ html_contents = ["<html>", "<head>", "<title>"]
+ html_contents.append (puztitle)
+ html_contents.append ("</title>")
+ html_contents.append ("</head>")
+ html_contents.append ("<body>")
+ html_contents.append ("<h1>" + puztitle + "</h1>")
+ html_contents.append ('<img src="' + pngfile + '" alt="puzzle" />')
+
+ html_contents.append ("<h2>Across clues</h2>")
+ html_contents.append ("<p>")
+ for word, clue in clues_across:
+ clue_str = str (self.data[word[1]][word[2]].numbered) + " - " \
+ + clue
+ html_contents.append (clue_str)
+ html_contents.append ("<br />")
+ html_contents.append ("</p>")
+
+ html_contents.append ("<h2>Down clues</h2>")
+ html_contents.append ("<p>")
+ for word, clue in clues_down:
+ clue_str = str (self.data[word[1]][word[2]].numbered) + " - " \
+ + clue
+ html_contents.append (clue_str)
+ html_contents.append ("<br />")
+ html_contents.append ("</p>")
+ html_contents.append ("</body>")
+ html_contents.append ("</html>")
+
+ html_str = "\r\n".join (html_contents)
+
+ fhtml = open (htmlfile, "wb")
+ fhtml.write (html_str)
+ fhtml.close ()