View Single Post
Old 05-08-2017, 10:54 PM   #25
nqk
Fanatic
nqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beautynqk does all things with Zen-like beauty
 
Posts: 516
Karma: 32106
Join Date: Feb 2012
Device: Onyx Boox Leaf
Dear you guys,

Please help me with a regex function to move found searches to "endnotes.html" file in the book. I picked a code from this forum, which looks like this.
Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    endnotes = open('D:\endnotes.txt', 'a')
    notes = match.group()+'\n'
    endnotes.write(notes)
    return ''
replace.file_order = 'spine'
This works, yes. It moves all the texts found to the external endnotes.txt and I would manually copy them to endnotes.html that I create in the book.

What I would like to do is have them written directly to the endnotes.html (or even create the file if not there already).

Thanks.
nqk is offline   Reply With Quote