From f74f4e1be915d6019c2c4acbd70cc7bfb49f7c85 Mon Sep 17 00:00:00 2001 From: Yuri Takhteyev Date: Mon, 19 Mar 2007 02:37:37 +0000 Subject: Changed the default conversion method to pass the text to the convert() method (was "toString()") rather than to the constructor. The idea is to get rid of the parameter in the constructor later, so that the standard pattern would be: markdown.Markdown().convert(text) rather than str(markdown.Markdown(text)) --- markdown.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'markdown.py') diff --git a/markdown.py b/markdown.py index 4d1eeaf..b368d08 100644 --- a/markdown.py +++ b/markdown.py @@ -942,7 +942,7 @@ class Markdown: Markdown text """ - def __init__(self, source=None, + def __init__(self, source=None, # deprecated extensions=[], extension_configs=None, encoding=None, @@ -1496,7 +1496,7 @@ class Markdown: else : return None - def __str__(self, source = None): + def convert (self, source = None): """Return the document in XHTML format. @returns: A serialized XHTML body.""" @@ -1534,7 +1534,10 @@ class Markdown: return self.docType + xml - toString = __str__ + __str__ = convert # deprecated - will be changed in 1.7 to report + # information about the MD instance + + toString = __str__ # toString() method is deprecated def __unicode__(self): @@ -1543,7 +1546,7 @@ class Markdown: return str(self)#.decode(self.encoding) - toUnicode = __unicode__ + toUnicode = __unicode__ # deprecated - will be removed in 1.7 @@ -1602,11 +1605,11 @@ def markdown(text, extension_configs[name] = configs #print configs - md = Markdown(text, extensions=extension_names, + md = Markdown(extensions=extension_names, extension_configs=extension_configs, safe_mode = safe_mode) - return md.toString() + return md.convert(text) class Extension : -- cgit v1.2.3