File: samepage.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 (17 lines) | stat: -rw-r--r-- 585 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from docutils.parsers.rst import Directive
from docutils.nodes import compound, raw

class SamepageDirective(Directive):
    
    has_content = True

    def run(self):
        prefix = raw('', '\\par\\begin{samepage}', format='latex')
        suffix = raw('', '\\end{samepage}\\par', format='latex')
        text = '\n'.join(self.content)
        content_node = compound(rawsource=text)
        self.state.nested_parse(self.content, self.content_offset, content_node)
        return [prefix, content_node, suffix]

def setup(app):
    app.add_directive('samepage', SamepageDirective)