Add tweak to change articles in title sort pattern

This commit is contained in:
Charles Haley 2010-10-03 14:54:06 +01:00
parent 60083e325c
commit 6f45344847
2 changed files with 18 additions and 1 deletions

View File

@ -83,6 +83,15 @@ title_series_sorting = 'library_order'
# strictly_alphabetic, it would remain "The Client". # strictly_alphabetic, it would remain "The Client".
save_template_title_series_sorting = 'library_order' save_template_title_series_sorting = 'library_order'
# Set the list of words that are to be considered 'articles' when computing the
# title sort strings. The list is a regular expression, with the articles
# separated by 'or' bars. Comparisons are case insensitive, and that cannot be
# changed. Changes to this tweak won't have an effect until the book is modified
# in some way. If you enter an invalid pattern, it is silently ignored.
# Default: '^(A|The|An)\s+'
title_sort_articles='^(A|The|An)\s+'
# Specify a folder that calibre should connect to at startup using # Specify a folder that calibre should connect to at startup using
# connect_to_folder. This must be a full path to the folder. If the folder does # connect_to_folder. This must be a full path to the folder. If the folder does
# not exist when calibre starts, it is ignored. If there are '\' characters in # not exist when calibre starts, it is ignored. If there are '\' characters in

View File

@ -44,7 +44,15 @@ def author_to_author_sort(author):
def authors_to_sort_string(authors): def authors_to_sort_string(authors):
return ' & '.join(map(author_to_author_sort, authors)) return ' & '.join(map(author_to_author_sort, authors))
_title_pat = re.compile('^(A|The|An)\s+', re.IGNORECASE) try:
_title_pat = re.compile(tweaks.get('title_sort_articles',
r'^(A|The|An)\s+'), re.IGNORECASE)
except:
print 'Error in title sort pattern'
import traceback
traceback.print_exc()
_title_pat = re.compile('^(A|The|An)\s+', re.IGNORECASE)
_ignore_starts = u'\'"'+u''.join(unichr(x) for x in range(0x2018, 0x201e)+[0x2032, 0x2033]) _ignore_starts = u'\'"'+u''.join(unichr(x) for x in range(0x2018, 0x201e)+[0x2032, 0x2033])
def title_sort(title): def title_sort(title):