Sha256: 6b44b17f2e98e1a1c2681d437a09764c6c8a36770c642b8822cc5d59b816d9ae

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

#!/usr/bin/env python

"""A small wrapper file for parsing ReST files at GitHub."""

__author__ = "Jannis Leidel"
__copyright__ = "Copyright (C) 2008 Jannis Leidel"
__license__ = "Public Domain"
__version__ = "0.1"

try:
    import locale
    locale.setlocale(locale.LC_ALL, '')
except:
    pass

import sys
from docutils.core import publish_parts
from docutils.writers.html4css1 import Writer

SETTINGS = {
    'cloak_email_addresses': True,
    'file_insertion_enabled': False,
    'raw_enabled': False,
    'strip_comments': True,
}

def main():
    """
    Parses the given ReST file or the redirected string input and returns the
    HTML body.

    Usage: rest2html < README.rst
           rest2html README.rst
    """
    try:
        text = open(sys.argv[1], 'r').read()
    except IOError: # given filename could not be found
        return ''
    except IndexError: # no filename given
        text = sys.stdin.read()

    parts = publish_parts(text, writer=Writer(), settings_overrides=SETTINGS)
    if 'html_body' in parts:
        return parts['html_body']
    return ''

if __name__ == '__main__':
    print main()

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
github-markup-0.2.0 lib/github/commands/rest2html
github-markup-0.1.7 lib/github/commands/rest2html
github-markup-0.1.6 lib/github/commands/rest2html
github-markup-0.1.5 lib/github/commands/rest2html
github-markup-0.1.4 lib/github/commands/rest2html
github-markup-0.1.3 lib/github/commands/rest2html
github-markup-0.1.2 lib/github/commands/rest2html
github-markup-0.1.1 lib/github/commands/rest2html
github_markup-0.1.1 lib/github/commands/rest2html
github_markup-0.1.0 lib/github/commands/rest2html