Build the spec as part of the build
This commit is contained in:
parent
0af06291fe
commit
8a66b1a68b
4 changed files with 43 additions and 28 deletions
|
@ -8,16 +8,21 @@
|
|||
from sys import argv
|
||||
import re
|
||||
|
||||
script, filename = argv
|
||||
filename = argv[1]
|
||||
|
||||
textfile = open(filename, "r")
|
||||
regex = r'(<h\d id="(.*?)">)'
|
||||
regex2 = r'(<div class="section" id="(.*?)">)'
|
||||
|
||||
replacement = r'<p><a class="anchor" id="\2"></a></p>\n\1'
|
||||
|
||||
with open(filename, "r") as f:
|
||||
lines = list(f)
|
||||
|
||||
# check for <hX id="..." (used in the FAQ) and add anchors - and then check
|
||||
# for <div class="section" id="..." and add anchors (used in the spec)
|
||||
for line in textfile:
|
||||
line = re.sub(regex, replacement, line.rstrip())
|
||||
print(re.sub(regex2, replacement, line.rstrip()))
|
||||
|
||||
with open(filename, "w") as f:
|
||||
for line in lines:
|
||||
line = re.sub(regex, replacement, line)
|
||||
line = re.sub(regex2, replacement, line)
|
||||
f.write(line)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue