mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Some styling for the index entries
This commit is contained in:
parent
591d2b769b
commit
e395657b78
@ -8,7 +8,7 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from calibre.ebooks.docx.index import process_index
|
from calibre.ebooks.docx.index import process_index, polish_index_markup
|
||||||
from calibre.ebooks.docx.names import XPath, get, namespaces
|
from calibre.ebooks.docx.names import XPath, get, namespaces
|
||||||
|
|
||||||
class Field(object):
|
class Field(object):
|
||||||
@ -184,6 +184,13 @@ class Fields(object):
|
|||||||
|
|
||||||
self.index_fields.append((idx, blocks))
|
self.index_fields.append((idx, blocks))
|
||||||
|
|
||||||
|
def polish_markup(self, object_map):
|
||||||
|
if not self.index_fields:
|
||||||
|
return
|
||||||
|
rmap = {v:k for k, v in object_map.iteritems()}
|
||||||
|
for idx, blocks in self.index_fields:
|
||||||
|
polish_index_markup(idx, [rmap[b] for b in blocks])
|
||||||
|
|
||||||
def test_parse_fields():
|
def test_parse_fields():
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
@ -117,4 +117,9 @@ def process_index(field, index, xe_fields, log):
|
|||||||
|
|
||||||
return hyperlinks, blocks
|
return hyperlinks, blocks
|
||||||
|
|
||||||
|
def polish_index_markup(index, blocks):
|
||||||
|
# prev_block = prev_text = None
|
||||||
|
for block in blocks:
|
||||||
|
cls = block.get('class', '')
|
||||||
|
block.set('class', (cls + ' index-entry').lstrip())
|
||||||
|
|
||||||
|
@ -465,6 +465,9 @@ class Styles(object):
|
|||||||
|
|
||||||
span.tab { white-space: pre }
|
span.tab { white-space: pre }
|
||||||
|
|
||||||
|
p.index-entry a:visited { color: blue }
|
||||||
|
p.index-entry a:hover { color: red }
|
||||||
|
|
||||||
''') % (self.body_font_family, self.body_font_size, self.body_color)
|
''') % (self.body_font_family, self.body_font_size, self.body_color)
|
||||||
if ef:
|
if ef:
|
||||||
prefix = ef + '\n' + prefix
|
prefix = ef + '\n' + prefix
|
||||||
|
@ -209,6 +209,8 @@ class Convert(object):
|
|||||||
notes_header.set('class', '%s notes-header' % cls)
|
notes_header.set('class', '%s notes-header' % cls)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.fields.polish_markup(self.object_map)
|
||||||
|
|
||||||
self.log.debug('Cleaning up redundant markup generated by Word')
|
self.log.debug('Cleaning up redundant markup generated by Word')
|
||||||
self.cover_image = cleanup_markup(self.log, self.html, self.styles, self.dest_dir, self.detect_cover)
|
self.cover_image = cleanup_markup(self.log, self.html, self.styles, self.dest_dir, self.detect_cover)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user