Jason Moiron  committed e10b46c

version 0.6, change url to bitbucket, add extras to `argot` script including auto-pygments styling to generated document

  • Participants
  • Parent commits 7a638e9
  • Tags r0.6

Comments (0)

Files changed (4)

 ``argot`` requires markdown and pygments.  The optional amazon link processor,
 disabled by default, requires lxml.
-version 0.5 notes
+version 0.6 notes
-Version 0.5 of argot adds blockquote blocks, and is in this way incompatible 
-with older versions.  These blocks are unlikely to have occured by chance,
-so this should probably not be a problem.
+Version 0.6 of argot adds some functionality to the `argot` script, allowing
+you to easily create full HTML documents (*with* pygments styling) from
+argot markup in one easy command.
-A non-documented method of extending the way argot applied preprocessors that
-was nevertheless implied by the code has been removed as its presence was
-viewed as needless complexity.  If you were extending argot by adding to 
-``enabled_extensions``, you will have to find another entrypoint for your 
-customizations.  The old method of operation will not be restored in future 
+Version 0.6 of argot *is backwards compatible* with version 0.5, but maintains
+the blockquote blocks which makes it incompatible with versions previous to
+0.5.  If you are using a version older than 0.5 and wish to upgrade, please
+consult the README.rst file in 0.5 for a full list of incompatabilities.
 moin-style highlighted code blocks
       -h, --help            show this help message and exit
       -r REFERER, --referer=REFERER
                             http referer for google link parser
+      -d, --document        render as full html document
+      -t TITLE, --title=TITLE
+                            title to use in HEAD (implies -d)
+      -s STYLE, --style=STYLE
+                            pygments style to use
+With the ``-d`` option, argot will create a full HTML document with the
+specified pygments style (defaults to ``default``).

File argot/

 __all__ = ['set_google_referer', 'link_processor', 'render', 'VERSION']
 from markup import set_google_referer, link_processor, render
-VERSION = '0.5'
+VERSION = '0.6'
 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""Argot script to turn argot marked up files to html."""
+from __future__ import with_statement
 import optparse
+from pygments.formatters import HtmlFormatter
 from argot import *
+document = '''\
+  <head>
+    <title>%(title)s</title>
+    <style type="text/css">
+      %(style)s
+    </style>
+  </head>
+  <body>
+    %(content)s
+  </body>
 def parse_args():
     parser = optparse.OptionParser(version=VERSION, usage='%prog [options] file')
     parser.add_option('-r', '--referer', help='http referer for google link parser')
+    parser.add_option('-d', '--document', action='store_true', help='render as full html document')
+    parser.add_option('-t', '--title', help='title to use in HEAD (implies -d)')
+    parser.add_option('-s', '--style', help='pygments style to use', default='default')
     return parser.parse_args()
-if __name__ == '__main__':
+def main():
     opts, args = parse_args()
     filename = args[0]
-    f = open(filename)
-    print unicode(render('utf-8')
-    f.close()
+    context = {'title' : opts.title or ''}
+    if opts.title:
+        opts.document = True
+    # XXX: fetch the css
+    with open(filename) as fp:
+        content = unicode(render('utf-8')
+        context['content'] = content 
+    if opts.document:
+ = or 'default'
+        context['style'] = HtmlFormatter(
+        print document % context
+    else:
+        print content
+if __name__ == '__main__':
+    import sys
+    try:
+        sys.exit(main())
+    except KeyboardInterrupt:
+        sys.exit(-1)
 from setuptools import setup
 #from distutils.core import setup
-version = '0.5'
+version = '0.6'
     import argot
     version = argot.VERSION
       keywords='html markup markdown',
       author='Jason Moiron',
-      url='',
+      url='',