File: caption.py

package info (click to toggle)
openmm 7.7.0%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 114,116 kB
  • sloc: xml: 376,993; cpp: 198,330; python: 31,278; ansic: 5,610; lisp: 2,294; sh: 415; f90: 233; makefile: 223; 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)