From b688bf59dee2ed1552c0b232a43066ba18393ab0 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Sun, 23 Aug 2009 14:42:52 -0400 Subject: Fixed Ticket 43. Apparenlty ElementTree does not recognize 'utf8' as an alias of 'utf-8' and outputs invalid xml. We never noticed as stripTopLevelTags removes the offending fragment. However, there are legitimate uses for turning off stripTopLevelTags. Therefore, from now on we will be using 'utf-8' internally. Thanks to Mark Eichin for the report. --- docs/using_as_module.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/using_as_module.txt') diff --git a/docs/using_as_module.txt b/docs/using_as_module.txt index cfeb88d..130d0a7 100644 --- a/docs/using_as_module.txt +++ b/docs/using_as_module.txt @@ -20,13 +20,13 @@ string should work) and returns output as Unicode. Do not pass encoded strings If your input is encoded, e.g. as UTF-8, it is your responsibility to decode it. E.g.: - input_file = codecs.open("some_file.txt", mode="r", encoding="utf8") + input_file = codecs.open("some_file.txt", mode="r", encoding="utf-8") text = input_file.read() html = markdown.markdown(text, extensions) If you later want to write it to disk, you should encode it yourself: - output_file = codecs.open("some_file.html", "w", encoding="utf8") + output_file = codecs.open("some_file.html", "w", encoding="utf-8") output_file.write(html) More Options @@ -61,7 +61,7 @@ The ``Markdown`` class has the method ``convertFile`` which reads in a file and writes out to a file-like-object: md = markdown.Markdown() - md.convertFile(input="in.txt", output="out.html", encoding="utf8") + md.convertFile(input="in.txt", output="out.html", encoding="utf-8") The markdown module also includes a shortcut function ``markdownFromFile`` that wraps the above method. @@ -69,7 +69,7 @@ wraps the above method. markdown.markdownFromFile(input="in.txt", output="out.html", extensions=[], - encoding="utf8", + encoding="utf-8", safe=False) In either case, if the ``output`` keyword is passed a file name (i.e.: -- cgit v1.2.3