Skip to content

Commit

Permalink
interpolate variables in spec text as well (fixes fingerprint issue h…
Browse files Browse the repository at this point in the history
  • Loading branch information
darobin committed Jul 15, 2013
1 parent c3637d3 commit 7c83345
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def main(stdin, stdout, select='w3c-html', branch="master"):
def vset(match):
vars[match.group(1)] = match.group(2)
return ''
header = re.sub('<!--SET (\w+)=(.*?)-->\n?', vset, header)

# include nested boiler plate
def boilerplate(match):
Expand All @@ -36,19 +35,17 @@ def boilerplate(match):
content = match.group(0)
sys.stderr.write("Missing file: %s\n" % name)

# substitute variables
content = re.sub('<!--INSERT (\w+)-->', lambda n: vars[n.group(1)], content)

# use content as the replacement
return content
header = re.sub('<!--BOILERPLATE ([-.\w]+)-->', boilerplate, header)
header = re.sub('<!--INSERT (\w+)-->', lambda n: vars[n.group(1)], header)

source = stdin.read()
source = re.compile('^.*?<!--START %s-->' % select, re.DOTALL).sub('', source)
source = re.sub('<!--BOILERPLATE ([-.\w]+)-->', boilerplate, source)

content = header.decode("utf8") + source.decode("utf8")
content = re.sub('<!--SET (\w+)=(.*?)-->\n?', vset, content)
content = re.sub('<!--INSERT (\w+)-->', lambda n: vars[n.group(1)], content)

def adjust_headers(text, delta, pos, endpos=None):
def adjust_header(match):
Expand Down

1 comment on commit 7c83345

@silviapfeiffer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice patch!

Please sign in to comment.