more
This commit is contained in:
parent
c38a60c339
commit
f4db82a1d2
@ -26,7 +26,7 @@ class WikiArticle:
|
||||
|
||||
with open(filename, 'r') as f:
|
||||
content = f.readlines()
|
||||
self.content = [c.strip() for c in content]
|
||||
self.content = [c for c in content]
|
||||
self.title = title(content)
|
||||
self.tags = tags(content)
|
||||
self.filename = filename
|
||||
@ -38,9 +38,9 @@ class WikiArticle:
|
||||
for line in content:
|
||||
if line == self.header: break
|
||||
else: yield line
|
||||
yield self.header
|
||||
yield self.header + '\n'
|
||||
for w in linked_articles:
|
||||
yield f'- [[../{w.filename}][{w.title}]]'
|
||||
yield f'- [[../{w.filename}][{w.title}]]\n'
|
||||
return rep()
|
||||
|
||||
def __repr__(self):
|
||||
@ -62,7 +62,7 @@ class MetaPage(WikiArticle):
|
||||
raise Exception(f'Multiple tags in metapage: {self.filename}')
|
||||
self.meta = self.tags[0]
|
||||
|
||||
correct_section = list(filter(lambda l: l == self.header, self.content))
|
||||
correct_section = list(filter(lambda l: l.strip() == self.header, self.content))
|
||||
if len(correct_section) != 1:
|
||||
raise Exception(f'Invalid meta section in {filename}')
|
||||
|
||||
@ -106,7 +106,7 @@ def links(article: ContentArticle):
|
||||
|
||||
def writetodisk(m: WikiArticle, content: list[str]):
|
||||
with open(m.filename, 'w') as f:
|
||||
f.writelines(map(lambda l: l+'\n', content))
|
||||
f.writelines(content)
|
||||
|
||||
if __name__ == '__main__':
|
||||
files_ = [ContentArticle(f) for f in files()]
|
||||
@ -122,5 +122,6 @@ if __name__ == '__main__':
|
||||
|
||||
for f in files_:
|
||||
related = set(links(f))
|
||||
if related:
|
||||
newcontent = f.enrich(map(lambda f: byfilename[f], related))
|
||||
writetodisk(f, newcontent)
|
||||
|
Loading…
Reference in New Issue
Block a user