(self, input=None, output=None, encoding=None)
return self
Converts a markdown file and returns the HTML as a unicode string.

        Decodes the file using the provided encoding (defaults to utf-8),
        passes the file content to markdown, and outputs the html to either
        the provided stream or the file with provided name, using the same
        encoding as the source file. The 'xmlcharrefreplace' error handler is
        used when encoding the output.

        **Note:** This is the only place that decoding and encoding of unicode
        takes place in Python-Markdown.  (All other code is unicode-in /
        unicode-out.)

        Keyword arguments:

        * input: File object or path. Reads from stdin if `None`.
        * output: File object or path. Writes to stdout if `None`.
        * encoding: Encoding of input and output files. Defaults to utf-8.
Converts a markdown file and returns the HTML as a unicode string.
Converts a markdown file and returns the HTML as a unicode string .
def convertFile(self, input=None, output=None, encoding=None):
        """Converts a markdown file and returns the HTML as a unicode string.

        Decodes the file using the provided encoding (defaults to utf-8),
        passes the file content to markdown, and outputs the html to either
        the provided stream or the file with provided name, using the same
        encoding as the source file. The 'xmlcharrefreplace' error handler is
        used when encoding the output.

        **Note:** This is the only place that decoding and encoding of unicode
        takes place in Python-Markdown.  (All other code is unicode-in /
        unicode-out.)

        Keyword arguments:

        * input: File object or path. Reads from stdin if `None`.
        * output: File object or path. Writes to stdout if `None`.
        * encoding: Encoding of input and output files. Defaults to utf-8.

        """

        encoding = encoding or "utf-8"

        # Read the source
        if input:
            if isinstance(input, str):
                input_file = codecs.open(input, mode="r", encoding=encoding)
            else:
                input_file = codecs.getreader(encoding)(input)
            text = input_file.read()
            input_file.close()
        else:
            text = sys.stdin.read()
            if not isinstance(text, unicode):
                text = text.decode(encoding)

        text = text.lstrip('\ufeff') # remove the byte-order mark

        # Convert
        html = self.convert(text)

        # Write to file or stdout
        if output:
            if isinstance(output, str):
                output_file = codecs.open(output, "w",
                                          encoding=encoding,
                                          errors="xmlcharrefreplace")
                output_file.write(html)
                output_file.close()
            else:
                writer = codecs.getwriter(encoding)
                output_file = writer(output, errors="xmlcharrefreplace")
                output_file.write(html)
                # Don't close here. User may want to write more.
        else:
            sys.stdout.write(html)

        return self
def convertFile ( self , input = None , output = None , encoding = None ) : encoding = encoding or "utf-8" # Read the source if input : if isinstance ( input , str ) : input_file = codecs . open ( input , mode = "r" , encoding = encoding ) else : input_file = codecs . getreader ( encoding ) ( input ) text = input_file . read ( ) input_file . close ( ) else : text = sys . stdin . read ( ) if not isinstance ( text , unicode ) : text = text . decode ( encoding ) text = text . lstrip ( '\ufeff' ) # remove the byte-order mark # Convert html = self . convert ( text ) # Write to file or stdout if output : if isinstance ( output , str ) : output_file = codecs . open ( output , "w" , encoding = encoding , errors = "xmlcharrefreplace" ) output_file . write ( html ) output_file . close ( ) else : writer = codecs . getwriter ( encoding ) output_file = writer ( output , errors = "xmlcharrefreplace" ) output_file . write ( html ) # Don't close here. User may want to write more. else : sys . stdout . write ( html ) return self