(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, util.string_type):
                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, util.text_type):
                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, util.string_type):
                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:
            # Encode manually and write bytes to stdout.
            html = html.encode(encoding, "xmlcharrefreplace")
            try:
                # Write bytes directly to buffer (Python 3).
                sys.stdout.buffer.write(html)
            except AttributeError:
                # Probably Python 2, which works with bytes by default.
                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 , util . string_type ) : 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 , util . text_type ) : 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 , util . string_type ) : 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 : # Encode manually and write bytes to stdout. html = html . encode ( encoding , "xmlcharrefreplace" ) try : # Write bytes directly to buffer (Python 3). sys . stdout . buffer . write ( html ) except AttributeError : # Probably Python 2, which works with bytes by default. sys . stdout . write ( html ) return self