1. dan mackinlay
  2. possumpalace_kit

Commits

dan mackinlay  committed 61cd530

hashing out silly business with citations in a manner that will lead to me reimplementing bibtex AGAIN.

  • Participants
  • Parent commits 5b89528
  • Branches default

Comments (0)

Files changed (2)

File _ext/pp_docutils_helper.py

View file
  • Ignore whitespace
+"""
+plugins for rendering that depend on docutils but not sphinx, for use in exporting drafts
+"""
+
+import docutils.nodes
+from docutils.parsers.rst import roles
+
+class ManualCite(docutils.nodes.citation_reference):
+    "Just a citation ref, really but subclassed so we can treat it differently"
+    pass
+
+def manualcite_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
+    """Manual citations. In LaTeX they render to nothing much.
+    I might do more sophisticated treatment in ReST when I have time.
+    cribbed from
+    http://www.doughellmann.com/articles/how-tos/sphinx-custom-roles/index.html
+
+    Returns 2 part tuple containing list of nodes to insert into the
+    document and a list of system messages.  Both are allowed to be
+    empty.
+
+    :param name: The role name used in the document.
+    :param rawtext: The entire markup snippet, with role.
+    :param text: The text marked with the role.
+    :param lineno: The line number where rawtext appears in the input.
+    :param inliner: The inliner instance that called us.
+    :param options: Directive options for customization.
+    :param content: The directive content for customization.
+    """
+
+    app = inliner.document.settings.env.app
+    node = ManualCite(rawtext)
+    return [node], []
+
+def register_roles():
+    roles.register_local_role('manualcite', manualcite_role)

File rst2xetex.py

View file
  • Ignore whitespace
+#!/usr/bin/env python
+# encoding: utf-8
+import os
+import os.path
+import sys
+here = os.path.abspath('.')
+sys.path.append(os.path.join(here, 'content'))
+sys.path.append(os.path.join(here, '_ext'))
+sys.path.append(here)
+
+# $Id: rst2xetex.py 7038 2011-05-19 09:12:02Z milde $
+# Author: Guenter Milde
+# Copyright: This module has been placed in the public domain.
+
+"""
+A minimal front end to the Docutils Publisher, producing XeLaTeX source code.
+Modified for local docutils export.
+"""
+
+try:
+    import locale
+    locale.setlocale(locale.LC_ALL, '')
+except:
+    pass
+
+import pp_docutils_helper
+pp_docutils_helper.register_roles()
+
+from docutils.core import publish_cmdline
+
+description = ('Generates XeLaTeX documents from standalone reStructuredText '
+               'sources. '
+               'Reads from <source> (default is stdin) and writes to '
+               '<destination> (default is stdout).  See '
+               '<http://docutils.sourceforge.net/docs/user/latex.html> for '
+               'the full reference.')
+
+publish_cmdline(writer_name='xetex', description=description)