1
0
Fork 0

Fixed a small bug in the python script

This commit is contained in:
Thomas Schmidts 2014-06-18 16:52:35 +02:00
parent 2b3c686e42
commit 01c2770030
2 changed files with 5 additions and 2 deletions

View File

@ -17,6 +17,8 @@ build-books: md-files
build-book:
@test -d books/$(NAME) || mkdir books/$(NAME)
python codeBlockReader.py
python bot.py
cd $(NAME) && gitbook build -o ../books/$(NAME)
cp Users/Arangodb_Logo.png books/Users/
@for file in $(basename $(MD_FILES)); do echo "remove $${file}.md";rm $${file}.md;done

View File

@ -23,9 +23,10 @@ def findStartCode(textFile,full_path):
def getTextFromSourceFile(searchText, full_path):
f=open("allComments.txt", 'rU')
s=f.read()
match = re.search(r'@startDocuBlock\s+'+re.escape(searchText)+'(.+?)@endDocuBlock', s,re.DOTALL)
match = re.search(r'@startDocuBlock\s+'+ searchText + "(?:\s+|$)" +'(.+?)@endDocuBlock', s,re.DOTALL)
if match:
textExtracted = match.group(1)
textExtracted = textExtracted.replace("<br />","\n")
replaceText(textExtracted, full_path, searchText)
def replaceText(text, pathOfFile, searchText):
@ -35,7 +36,7 @@ def replaceText(text, pathOfFile, searchText):
f.close()
f=open(pathOfFile,'w')
replaced=re.sub('@startDocuBlock\s+'+ searchText + "(?:\s+|$)",text,s)
replaced=re.sub("@startDocuBlock\s+"+ searchText + "(?:\s+|$)",text,s)
f.write(replaced)
f.close()