Function markdownFromFile

Synopsis

def markdown.markdownFromFile(args, kwargs)

Description

Read markdown code from a file and write it to a file or a stream.

This is a shortcut function which initializes an instance of Markdown, and calls the convertFile method rather than convert.

Keyword arguments:

  • input: a file name or readable object.
  • output: a file name or writable object.
  • encoding: Encoding of input and output.
  • Any arguments accepted by the Markdown class.

Examples

//
//

Source

From lines 497-530 in markdown/init.py

def markdownFromFile(*args, **kwargs):
    """Read markdown code from a file and write it to a file or a stream.

    This is a shortcut function which initializes an instance of Markdown,
    and calls the convertFile method rather than convert.

    Keyword arguments:

    * input: a file name or readable object.
    * output: a file name or writable object.
    * encoding: Encoding of input and output.
    * Any arguments accepted by the Markdown class.

    """
    # For backward compatibility loop through positional args
    pos = ['input', 'output', 'extensions', 'encoding']
    c = 0
    for arg in args:
        if pos[c] not in kwargs:
            kwargs[pos[c]] = arg
        c += 1
        if c == len(pos):
            break
    if len(args):
        warnings.warn('Positional arguments are depreacted in '
                      'Markdown and will raise an error in version 2.7. '
                      'Use keyword arguments only.',
                      DeprecationWarning)

    md = Markdown(**kwargs)
    md.convertFile(kwargs.get('input', None),
                   kwargs.get('output', None),
                   kwargs.get('encoding', None))


Discussions

There are 0 discussions relevant for this page, and 0 discussions in the whole project.




Add Discussion

Log in to comment