#!/usr/bin/env python

# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.
"""
A minimal front end to the Docutils Publisher, producing HTML.
"""

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

from docutils.core import publish_cmdline, default_description
from docutils.writers.html4css1 import Writer, HTMLTranslator
from docutils.readers.standalone import Reader
from docutils.writers import Writer as WriterBase

description = ('Generates (X)HTML with small-caps support from '
               'standalone reStructuredText sources.  ' + default_description)

import zot4rst
zot4rst.init()

class HTMLTranslatorWithSmallCaps(HTMLTranslator):

    def visit_smallcaps(self, node):
        self.body.append(self.starttag(node, 'span style="font-variant:small-caps"', ''))
        
    def depart_smallcaps(self, node):
        self.body.append('</span>')

class WriterWithSmallCaps(Writer):
    def __init__(self):
        WriterBase.__init__(self)
        self.translator_class = HTMLTranslatorWithSmallCaps

writer = WriterWithSmallCaps()

publish_cmdline(writer=writer,
                settings_overrides={'footnotes_at_end': 1},
                description=description)
