mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow chapter matching on just tagnames
This commit is contained in:
parent
2a87359439
commit
0f96099453
@ -163,7 +163,7 @@ def option_parser(usage, gui_mode=False):
|
||||
help=_('''The regular expression used to detect chapter titles.'''
|
||||
''' It is searched for in heading tags (h1-h6). Defaults to %default'''))
|
||||
chapter.add_option('--chapter-attr', default='$,,$',
|
||||
help=_('Detect a chapter beginning at an element having the specified attribute. The format for this option is tagname regexp,attribute name,attribute value regexp. For example to match all heading tags that have the attribute class="chapter" you would use "h\d,class,chapter". Default is %default'''))
|
||||
help=_('Detect a chapter beginning at an element having the specified attribute. The format for this option is tagname regexp,attribute name,attribute value regexp. For example to match all heading tags that have the attribute class="chapter" you would use "h\d,class,chapter". You can set the attrivute to "none" to match only on tag names. So for example, to match all <h2> tags, you would use "h2,none,". Default is %default'''))
|
||||
chapter.add_option('--page-break-before-tag', dest='page_break', default='h[12]',
|
||||
help=_('''If html2lrf does not find any page breaks in the '''
|
||||
'''html file and cannot detect chapter headings, it will '''
|
||||
|
@ -1446,10 +1446,11 @@ class HTMLConverter(object, LoggingInterface):
|
||||
pass
|
||||
if not self.disable_chapter_detection and \
|
||||
(self.chapter_attr[0].match(tagname) and \
|
||||
tag.has_key(self.chapter_attr[1]) and \
|
||||
self.chapter_attr[2].match(tag[self.chapter_attr[1]])):
|
||||
(self.chapter_attr[1].pattern.lower() == 'none' or \
|
||||
(tag.has_key(self.chapter_attr[1]) and \
|
||||
self.chapter_attr[2].match(tag[self.chapter_attr[1]])))):
|
||||
self.log_debug('Detected chapter %s', tagname)
|
||||
self.end_page()
|
||||
self.end_page()
|
||||
self.page_break_found = True
|
||||
|
||||
if self.options.add_chapters_to_toc:
|
||||
|
Loading…
x
Reference in New Issue
Block a user