mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-01 02:46:04 +01:00
...
This commit is contained in:
parent
95102dee29
commit
3e715dd604
2 changed files with 12 additions and 4 deletions
|
|
@ -7,6 +7,7 @@
|
|||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re
|
||||
from future_builtins import map
|
||||
|
||||
from lxml.etree import XPath as X
|
||||
|
||||
|
|
@ -94,3 +95,8 @@ def generate_anchor(name, existing):
|
|||
c += 1
|
||||
return y
|
||||
|
||||
def children(elem, *args):
|
||||
return elem.iterchildren(*map(expand, args))
|
||||
|
||||
def descendants(elem, *args):
|
||||
return elem.iterdescendants(*map(expand, args))
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@
|
|||
HTML, HEAD, TITLE, BODY, LINK, META, P, SPAN, BR, DIV)
|
||||
|
||||
from calibre.ebooks.docx.container import DOCX, fromstring
|
||||
from calibre.ebooks.docx.names import XPath, is_tag, XML, STYLES, NUMBERING, FONTS, expand, get, generate_anchor
|
||||
from calibre.ebooks.docx.names import (
|
||||
XPath, is_tag, XML, STYLES, NUMBERING, FONTS, get, generate_anchor,
|
||||
descendants)
|
||||
from calibre.ebooks.docx.styles import Styles, inherit, PageProperties
|
||||
from calibre.ebooks.docx.numbering import Numbering
|
||||
from calibre.ebooks.docx.fonts import Fonts
|
||||
|
|
@ -120,8 +122,8 @@ def read_page_properties(self, doc):
|
|||
current = []
|
||||
self.page_map = OrderedDict()
|
||||
|
||||
for p in XPath('//w:p')(doc):
|
||||
sect = XPath('descendant::w:sectPr')(p)
|
||||
for p in descendants(doc, 'w:p'):
|
||||
sect = tuple(descendants(p, 'w:sectPr'))
|
||||
if sect:
|
||||
pr = PageProperties(sect)
|
||||
for x in current + [p]:
|
||||
|
|
@ -197,7 +199,7 @@ def convert_p(self, p):
|
|||
|
||||
current_anchor = None
|
||||
|
||||
for x in p.iterdescendants(expand('w:r'), expand('w:bookmarkStart')):
|
||||
for x in descendants(p, 'w:r', 'w:bookmarkStart'):
|
||||
if x.tag.endswith('}r'):
|
||||
span = self.convert_run(x)
|
||||
if current_anchor is not None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue