aboutsummaryrefslogtreecommitdiff
path: root/scripts/comments.py
blob: 3767f973af95bbe1c68ce2add9f79a002f226ff4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
from pandoc import toJSONFilter
import re

incomment = False

def comment(k,v,format=""):
  global incomment
  if k == 'RawBlock':
    f, s = v
    fmt = f['unFormat']
    if fmt == "html":
      if re.search("<!-- BEGIN COMMENT -->", s):
        incomment = True
        return []
      elif re.search("<!-- END COMMENT -->", s):
        incomment = False
        return []
  if incomment:
    return []  # suppress anything in a comment

if __name__ == "__main__":
  toJSONFilter(comment)