Commits

dan mackinlay committed 12bdff3

sketch of ebtter citation munging

  • Participants
  • Parent commits c8523e6

Comments (0)

Files changed (2)

_ext/possumpalace.py

     import sphinx.writers.html as sphinx_htmlwriter
 except ImportError:
     import sphinx.htmlwriter as sphinx_htmlwriter
+try:
+    import sphinx.writers.latex as sphinx_latexwriter
+except ImportError:
+    import sphinx.latexwriter as sphinx_latexwriter
 import sphinx.roles
-from docutils import nodes
-
 
 def setup(app):
     app.add_crossref_type(
     # this enables
     #app.add_object_type(directivename, rolename, indextemplate='', parse_node=None, ref_nodeclass=None, objname='')
     
-    app.connect('builder-inited', inject_config)
-    
-        
+    app.connect('builder-inited', inject_config)   
 
 def inject_config(app):
     import resocializedtext
             if len(node.children) == 1 and isinstance(node.children[0], self.suppress_blockquote_child_nodes):
                 node.replace_self(node.children[0])
 
+class ManualCite(docutils.nodes.General, docutils.nodes.Element):
+   pass
+
 class PossumPalaceHTMLTranslator(sphinx_htmlwriter.SmartyPantsHTMLTranslator):
     """
     PossumPalace-specific reST to HTML tweaks.
     # Don't use border=1, which docutils does by default.
     def visit_table(self, node):
         self.body.append(self.starttag(node, 'table', CLASS='docutils'))
-    # 
+    
     # # <big>? Really?
     # def visit_desc_parameterlist(self, node):
     #     self.body.append('(')
     # def depart_desc_parameterlist(self, node):
     #     self.body.append(')')
     #     pass
-        
+    
     #
     # Don't apply smartypants to literal blocks
     #
     # # def depart_label(self, node):
     # #     # Context added in footnote_backrefs.
     # #     self.body.append(']%s</td><td>%s' % (self.context.pop(), self.context.pop()))
-    #     
+    #
+class PossumPalaceLaTeXWriter(sphinx_latexwriter.LaTeXWriter):
+    pass
+    
+    #     def visit_citation(self, node):
+    #         # TODO maybe use cite bibitems
+    #         self.bibitems.append(['', '', ''])  # [citeid, citetext, docname]
+    #         self.context.append(len(self.body))
+    #     def depart_citation(self, node):
+    #         size = self.context.pop()
+    #         text = ''.join(self.body[size:])
+    #         del self.body[size:]
+    #         self.bibitems[-1][1] = text
+    # 
+    #     def visit_citation_reference(self, node):
+    #         # This is currently never encountered, since citation_reference nodes
+    #         # are already replaced by pending_xref nodes in the environment.
+    #         self.body.append('\\cite{%s}' % self.idescape(node.astext()))
+    #         raise nodes.SkipNode
+    
 htmlhelp_basename = 'PossumPalacedoc'
 
 # -- Options for LaTeX output --------------------------------------------------
+latex_translator_class = "possumpalace.PossumPalaceLaTeXWriter"
 
 # The paper size ('letter' or 'a4').
 #latex_paper_size = 'letter'
 
 extlinks = {'culref': ('http://www.citeulike.org/user/livingthingdan/article/%s', None)}
 
-html_translator_class = "possumpalace.PossumPalaceHTMLTranslator"