diff options
author | Keuin <[email protected]> | 2023-05-31 02:58:49 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2023-05-31 02:58:49 +0800 |
commit | 6e4683716eade6a7254921dc17d7fb5868a5423c (patch) | |
tree | 27edc5a83c07a3b4776a3f6c7b16e573f7b7a0fb | |
parent | edc01b400707d5fff2df7bed6bd19e5b4c46a96d (diff) |
Pass params through fields
-rw-r--r-- | main.py | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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__': |