blob: 7f9e8d23db85061e4829d84bb8acbfcd86e614f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import docutils.parsers
import docutils.parsers.rst as rst
class CStrip(docutils.parsers.Parser):
def __init__(self):
self.rst_parser = rst.Parser()
def parse(self, inputstring, document):
stripped = []
for line in inputstring.split("\n"):
line = line.strip()
if line == "//|":
stripped.append("")
elif line.startswith("//| "):
stripped.append(line[len("//| "):])
stripped = "\r\n".join(stripped)
self.rst_parser.parse(stripped, document)
|