File: underline.py

package info (click to toggle)
haproxy 3.2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,924 kB
  • sloc: ansic: 267,927; sh: 3,466; xml: 1,756; python: 1,345; makefile: 1,155; perl: 168; cpp: 21
file content (16 lines) | stat: -rw-r--r-- 599 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import parser

class UnderlineParser(parser.Parser):
    # Detect underlines
    def parse(self, line):
        pctxt = self.pctxt
        if pctxt.has_more_lines(1):
            nextline = pctxt.get_line(1)
            if (len(line) > 0) and (len(nextline) > 0) and (nextline[0] == '-') and ("-" * len(line) == nextline):
                template = pctxt.templates.get_template("parser/underline.tpl")
                line = template.render(pctxt=pctxt, data=line).strip()
                pctxt.next(2)
                pctxt.eat_empty_lines()
                pctxt.stop = True

        return line