Enhance %title (#3059)

Use string.capwords in %title to lower char after apostrophe
This commit is contained in:
Guilherme Danno 2018-11-29 11:30:48 -02:00 committed by GitHub
parent b380a4c9a3
commit fa1037ee28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -23,6 +23,7 @@ import unicodedata
import time
import re
import six
import string
from beets import logging
from beets.mediafile import MediaFile, UnreadableFileError
@ -1456,7 +1457,7 @@ class DefaultTemplateFunctions(object):
@staticmethod
def tmpl_title(s):
"""Convert a string to title case."""
return s.title()
return string.capwords(s)
@staticmethod
def tmpl_left(s, chars):

View file

@ -103,7 +103,9 @@ Fixes:
Thanks to :user:`TaizoSimpson`.
:bug:`3501`
* Confusing typo when the convert plugin copies the art covers. :bug:`3063`
* The ``%title`` template function now works correctly with apostrophes.
Thanks to :user:`GuilhermeHideki`.
:bug:`3033`
.. _python-itunes: https://github.com/ocelma/python-itunes

View file

@ -589,6 +589,10 @@ class DestinationFunctionTest(_common.TestCase, PathFormattingMixin):
self._setf(u'%title{$title}')
self._assert_dest(b'/base/The Title')
def test_title_case_variable_aphostrophe(self):
self._setf(u'%title{I can\'t}')
self._assert_dest(b'/base/I Can\'t')
def test_asciify_variable(self):
self._setf(u'%asciify{ab\xa2\xbdd}')
self._assert_dest(b'/base/abC_ 1_2 d')