mirror of
https://github.com/beetbox/beets.git
synced 2025-12-09 18:12:19 +01:00
render RST instead of HTML
ReStructuredText has the advantage over HTML that it can be rendered easily to multiple formats (HTML, ePUB, PDF) and it supports indexes. the output needs to be fed into a file and integrated into an existing Sphinx document, of course.
This commit is contained in:
parent
9f3e5b28b4
commit
0fbfa1feae
1 changed files with 26 additions and 9 deletions
|
|
@ -659,6 +659,11 @@ class LyricsPlugin(plugins.BeetsPlugin):
|
|||
action='store_true', default=False,
|
||||
help=u'print lyrics to console',
|
||||
)
|
||||
cmd.parser.add_option(
|
||||
u'-r', u'--print-rst', dest='printrst',
|
||||
action='store_true', default=False,
|
||||
help=u'print lyrics to console as RST text',
|
||||
)
|
||||
cmd.parser.add_option(
|
||||
u'-f', u'--force', dest='force_refetch',
|
||||
action='store_true', default=False,
|
||||
|
|
@ -682,15 +687,27 @@ class LyricsPlugin(plugins.BeetsPlugin):
|
|||
lib, item, write,
|
||||
opts.force_refetch or self.config['force'],
|
||||
)
|
||||
if opts.printlyr and item.lyrics:
|
||||
if artist != item.artist:
|
||||
artist = item.artist
|
||||
ui.print_('<h1>' + artist + '</h1>')
|
||||
if album != item.album:
|
||||
album = item.album
|
||||
ui.print_('<h2>' + artist + '</h2>')
|
||||
ui.print_('<h3>' + item.title + '</h3>')
|
||||
ui.print_('<pre>' + item.lyrics + '</pre>')
|
||||
if item.lyrics:
|
||||
if opts.printlyr:
|
||||
ui.print_(item.lyrics)
|
||||
if opts.printrst:
|
||||
if artist != item.artist:
|
||||
artist = item.artist
|
||||
ui.print_(artist)
|
||||
ui.print_(u'=' * len(artist))
|
||||
ui.print_()
|
||||
if album != item.album:
|
||||
album = item.album
|
||||
ui.print_(album)
|
||||
ui.print_(u'-' * len(album))
|
||||
ui.print_()
|
||||
title_str = u':index:`' + item.title + u'`'
|
||||
ui.print_(title_str)
|
||||
ui.print_(u'~' * len(title_str))
|
||||
ui.print_()
|
||||
# turn lyrics into a line block
|
||||
ui.print_(u'| ' + item.lyrics.replace(u'\n', u'\n| '))
|
||||
ui.print_()
|
||||
|
||||
cmd.func = func
|
||||
return [cmd]
|
||||
|
|
|
|||
Loading…
Reference in a new issue