tools v5.5.3

This commit is contained in:
Apprentice Alf
2012-12-26 23:17:56 +00:00
parent c010e3f77a
commit 602ff30b3a
17 changed files with 142 additions and 63 deletions

View File

@@ -10,6 +10,7 @@ import re
from struct import pack
from struct import unpack
debug = False
class DocParser(object):
def __init__(self, flatxml, fontsize, ph, pw):
@@ -113,7 +114,9 @@ class DocParser(object):
# process each style converting what you can
if debug: print ' ', 'Processing styles.'
for j in xrange(stylecnt):
if debug: print ' ', 'Processing style %d' %(j)
start = styleList[j]
end = styleList[j+1]
@@ -132,6 +135,8 @@ class DocParser(object):
else :
sclass = ''
if debug: print 'sclass', sclass
# check for any "after class" specifiers
(pos, aftclass) = self.findinDoc('style._after_class',start,end)
if aftclass != None:
@@ -140,6 +145,8 @@ class DocParser(object):
else :
aftclass = ''
if debug: print 'aftclass', aftclass
cssargs = {}
while True :
@@ -147,6 +154,9 @@ class DocParser(object):
(pos1, attr) = self.findinDoc('style.rule.attr', start, end)
(pos2, val) = self.findinDoc('style.rule.value', start, end)
if debug: print 'attr', attr
if debug: print 'val', val
if attr == None : break
if (attr == 'display') or (attr == 'pos') or (attr == 'align'):
@@ -164,7 +174,7 @@ class DocParser(object):
scale = self.pw
elif attr == 'line-space':
scale = self.fontsize * 2.0
if val == "":
val = 0
@@ -179,6 +189,7 @@ class DocParser(object):
if aftclass != "" : keep = False
if keep :
if debug: print 'keeping style'
# make sure line-space does not go below 100% or above 300% since
# it can be wacky in some styles
if 'line-space' in cssargs:
@@ -256,7 +267,9 @@ def convert2CSS(flatxml, fontsize, ph, pw):
# create a document parser
dp = DocParser(flatxml, fontsize, ph, pw)
if debug: print ' ', 'Created DocParser.'
csspage = dp.process()
if debug: print ' ', 'Processed DocParser.'
return csspage