1.1 --- a/parser.py Mon Apr 23 00:41:42 2012 +0200
1.2 +++ b/parser.py Mon Apr 23 19:35:29 2012 +0200
1.3 @@ -72,7 +72,7 @@
1.4
1.5 # Heading, table and list extraction.
1.6
1.7 -list_regexp_str = r"^(?P<listtype>[*#-])[*#-]*.*\n((?P=listtype).*(?:\n|$))*"
1.8 +list_regexp_str = r"^\s*(?P<listtype>[*#-])[*#-]*.*\n(\s*(?P=listtype).*(?:\n|$))*"
1.9 table_regexp_str = r"^((?P<celltype>[|]{1,2})(.+?(?P=celltype))+(\n|$))+"
1.10 blocktext_regexp_str = r"^(?P<type>h\d|bq)\.\s+(?P<text>.*)$"
1.11
1.12 @@ -144,7 +144,7 @@
1.13
1.14 # List item inspection.
1.15
1.16 -listitem_regexp_str = r"^(?P<marker>[*#-])+\s*(?P<text>.*)$"
1.17 +listitem_regexp_str = r"^(?P<marker> *[-*#]+)\s*(?P<text>.*)$"
1.18 listitem_regexp = re.compile(listitem_regexp_str, re.MULTILINE)
1.19
1.20 def get_list_items(text):
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tools/get_macros.py Mon Apr 23 19:35:29 2012 +0200
2.3 @@ -0,0 +1,24 @@
2.4 +#!/usr/bin/env python
2.5 +
2.6 +from os.path import join
2.7 +from os import walk
2.8 +import re, sys
2.9 +
2.10 +pattern = re.compile(r"(?<!{){[^{}]+}")
2.11 +
2.12 +if len(sys.argv) < 2:
2.13 + print >>sys.stderr, "Need a directory name."
2.14 + sys.exit(1)
2.15 +
2.16 +dirname = sys.argv[1]
2.17 +
2.18 +for dirpath, dirnames, filenames in walk(dirname):
2.19 + for filename in filenames:
2.20 + f = open(join(dirpath, filename))
2.21 + try:
2.22 + for match in pattern.finditer(f.read()):
2.23 + print match.group()
2.24 + finally:
2.25 + f.close()
2.26 +
2.27 +# vim: tabstop=4 expandtab shiftwidth=4