File: caption.py

package info (click to toggle)
openmm 8.1.2%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 119,192 kB
  • sloc: xml: 377,325; cpp: 226,673; ansic: 42,767; python: 32,634; lisp: 2,441; sh: 440; makefile: 254; f90: 233; csh: 19
file content (18 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from docutils.parsers.rst import Directive
from docutils.nodes import compound, raw

class CaptionDirective(Directive):
    
    has_content = True

    def run(self):
        latexPrefix = raw('', '{\\centering', format='latex')
        latexSuffix = raw('', '\\par}\\bigskip', format='latex')
        text = '\n'.join(self.content)
        content_node = compound(rawsource=text)
        self.state.nested_parse(self.content, self.content_offset, content_node)
        content_node.attributes['classes'].append('caption')
        return [latexPrefix, content_node, latexSuffix]

def setup(app):
    app.add_directive('caption', CaptionDirective)