summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-05-31 02:58:49 +0800
committerKeuin <[email protected]>2023-05-31 02:58:49 +0800
commit6e4683716eade6a7254921dc17d7fb5868a5423c (patch)
tree27edc5a83c07a3b4776a3f6c7b16e573f7b7a0fb /main.py
parentedc01b400707d5fff2df7bed6bd19e5b4c46a96d (diff)
Pass params through fields
Diffstat (limited to 'main.py')
-rw-r--r--main.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/main.py b/main.py
index 895b2c0..dcf7e58 100644
--- a/main.py
+++ b/main.py
@@ -113,11 +113,13 @@ def tokenize(lyric: Tag) -> typing.Iterator[Token]:
class LatexGenerator:
centering: bool
cjk: CJKProvider
+ artist: typing.Optional[str]
+ title: typing.Optional[str]
def __init__(self):
- pass
+ self.artist, self.title = None, None
- def generate_lyric(self, lyric_tokens: typing.Iterator[Token], artist=None, title=None) -> str:
+ def generate_lyric(self, lyric_tokens: typing.Iterator[Token]) -> str:
injectors = []
injectors.append(LatexDocInjectionInfo([], [r'\usepackage{pxrubrica}'], []))
injectors.append(LatexDocInjectionInfo([], [r'\usepackage{setspace}', r'\doublespacing'], []))
@@ -131,8 +133,8 @@ class LatexGenerator:
r'\setCJKmonofont{Noto Sans Mono CJK TC}',
], []))
injectors.append(LatexDocInjectionInfo([], [
- r'\author{%s}' % (artist or ''),
- r'\title{%s}' % (title or ''),
+ r'\author{%s}' % (self.artist or ''),
+ r'\title{%s}' % (self.title or ''),
r'\date{}',
], []))
injectors.append(LatexDocInjectionInfo([], [r'\begin{document}'], [r'\end{document}']))
@@ -194,7 +196,8 @@ def main():
artist = v
elif k == 'page_song':
title = v
- print(gen.generate_lyric(tokens, artist, title))
+ gen.artist, gen.title = artist, title
+ print(gen.generate_lyric(tokens))
if __name__ == '__main__':