mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
Remove debug messages.\nAlmost the remaining diff are whitespace.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5113 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
17b41b1655
commit
bee4ac06d8
@ -38,16 +38,12 @@ def replace_protected_separator(lines):
|
||||
result = result + " "
|
||||
del lines[i]
|
||||
|
||||
if lines[i-1] != "":
|
||||
lines[i-1] = lines[i-1] + result + lines[i]
|
||||
del lines[i]
|
||||
else:
|
||||
lines[i] = result + lines[i]
|
||||
del lines[i-1]
|
||||
lines[i-1] = lines[i-1] + result + lines[i]
|
||||
else:
|
||||
del lines[i]
|
||||
lines[i-1] = lines[i-1]+ "\\SpecialChar ~"
|
||||
|
||||
del lines[i]
|
||||
|
||||
def merge_formula_inset(lines):
|
||||
i=0
|
||||
while 1:
|
||||
|
@ -48,40 +48,80 @@ def update_tabular(lines):
|
||||
i = i +1
|
||||
|
||||
row_info = []
|
||||
cont_row = []
|
||||
for j in range(rows):
|
||||
row_info.append(string.split(lines[i]))
|
||||
if string.split(lines[i])[2] == '1':
|
||||
cont_row.append(j)
|
||||
del lines[i]
|
||||
|
||||
column_info = []
|
||||
col_info_re = re.compile(r'(\d) (\d) (\d) (".*") (".*")')
|
||||
for j in range(columns):
|
||||
column_info.append(string.split(lines[i]))
|
||||
column_info.append(col_info_re.match(lines[i]).groups())
|
||||
del lines[i]
|
||||
|
||||
cell_info = []
|
||||
cell_col = []
|
||||
ncells = 0
|
||||
cont_row = []
|
||||
cell_re = re.compile(r'(\d) (\d) (\d) (\d) (\d) (\d) (\d) (".*") (".*")')
|
||||
for j in range(rows):
|
||||
c_row = 0
|
||||
for k in range(columns):
|
||||
cell_info.append(string.split(lines[i]))
|
||||
if cell_info[len(cell_info)-1][6] == '1':
|
||||
c_row = 1
|
||||
#add column location to read properties
|
||||
cell_info.append(cell_re.match(lines[i]).groups())
|
||||
cell_col.append(k)
|
||||
if lines[i][0] != "2":
|
||||
ncells = ncells + 1
|
||||
del lines[i]
|
||||
if c_row:
|
||||
cont_row.append(j+1)
|
||||
|
||||
lines[tabular_line] = '<LyXTabular version="1" rows="%s" columns="%s">' % (rows-len(cont_row),columns)
|
||||
del lines[i]
|
||||
if not lines[i]:
|
||||
del lines[i]
|
||||
|
||||
# Read cells
|
||||
l = 0
|
||||
cell_content = []
|
||||
for j in range(rows):
|
||||
cell_content.append([])
|
||||
|
||||
for j in range(rows):
|
||||
for k in range(columns):
|
||||
cell_content[j].append([])
|
||||
|
||||
for j in range(rows):
|
||||
for k in range(columns):
|
||||
m = j*columns + k
|
||||
if cell_info[m][0] == '2':
|
||||
continue
|
||||
|
||||
if l == ncells -1:
|
||||
# the end variable refers to cell end, not to file end.
|
||||
end = find_tokens(lines, ['\\layout','\\the_end','\\end_deeper','\\end_float'], i)
|
||||
else:
|
||||
end = find_token(lines, '\\newline ', i)
|
||||
|
||||
if end == -1:
|
||||
sys.stderr.write("Malformed lyx file\n")
|
||||
sys.exit(1)
|
||||
|
||||
end = end - i
|
||||
while end > 0:
|
||||
cell_content[j][k].append(lines[i])
|
||||
del lines[i]
|
||||
end = end -1
|
||||
|
||||
if lines[i] == '\\newline ':
|
||||
del lines[i]
|
||||
l = l + 1
|
||||
|
||||
tmp = []
|
||||
tmp.append("")
|
||||
|
||||
l = 0
|
||||
for j in range(rows):
|
||||
tmp.append('<Row topline="%s" bottomline="%s" newpage="%s">' % (row_info[j][0],row_info[j][1],row_info[j][2]))
|
||||
if j in cont_row:
|
||||
continue
|
||||
tmp.append('<Row topline="%s" bottomline="%s" newpage="%s">' % (row_info[j][0],row_info[j][1],row_info[j][3]))
|
||||
|
||||
for k in range(columns):
|
||||
if j:
|
||||
@ -95,10 +135,9 @@ def update_tabular(lines):
|
||||
n = m + 1
|
||||
while n < rows * columns - 1 and cell_info[n][0] == '2':
|
||||
n = n + 1
|
||||
rightline = int(column_info[k][2])
|
||||
rightline = int(column_info[cell_col[n-1]][2])
|
||||
else:
|
||||
# not a multicolumn main cell
|
||||
# rightline = int(cell_info[m][5]) or int(column_info[k][2])
|
||||
rightline = int(column_info[k][2])
|
||||
|
||||
tmp.append('<Cell multicolumn="%s" alignment="%s" valignment="0" topline="%s" bottomline="%s" leftline="%d" rightline="%d" rotate="%s" usebox="%s" width=%s special=%s>' % (cell_info[m][0],cell_info[m][1],cell_info[m][2],cell_info[m][3],leftline,rightline,cell_info[m][5],cell_info[m][6],cell_info[m][7],cell_info[m][8]))
|
||||
@ -107,36 +146,22 @@ def update_tabular(lines):
|
||||
tmp.append('\\layout Standard')
|
||||
tmp.append('')
|
||||
|
||||
if cell_info[m][0] == '2':
|
||||
tmp.append('\\end_inset ')
|
||||
tmp.append('</Cell>')
|
||||
tmp.append('</Column>')
|
||||
continue
|
||||
|
||||
if l == ncells -1:
|
||||
end = find_tokens(lines, ['\\layout','\\the_end','\\end_deeper','\\end_float'], i)
|
||||
if end == -1:
|
||||
sys.stderr.write("Malformed lyx file\n")
|
||||
else:
|
||||
end = end - i
|
||||
paragraph = []
|
||||
while end > 0:
|
||||
paragraph.append(lines[i])
|
||||
del lines[i]
|
||||
end = end -1
|
||||
tmp.extend(set_paragraph_properties(paragraph, prop_dict))
|
||||
else:
|
||||
if cell_info[m][0] != '2':
|
||||
paragraph = []
|
||||
while lines[i] != '\\newline ':
|
||||
paragraph.append(lines[i])
|
||||
del lines[i]
|
||||
del lines[i]
|
||||
if cell_info[m][4] == '1':
|
||||
l = j
|
||||
paragraph.extend(cell_content[j][k])
|
||||
while cell_info[m][4] == '1':
|
||||
m = m + columns
|
||||
l = l + 1
|
||||
paragraph.extend(cell_content[l][k])
|
||||
else:
|
||||
paragraph = cell_content[j][k]
|
||||
tmp.extend(set_paragraph_properties(paragraph, prop_dict))
|
||||
|
||||
tmp.append('\\end_inset ')
|
||||
tmp.append('</Cell>')
|
||||
tmp.append('</Column>')
|
||||
l = l + 1
|
||||
tmp.append('</Row>')
|
||||
|
||||
tmp.append('</LyXTabular>')
|
||||
@ -215,7 +240,6 @@ def set_paragraph_properties(lines, prop_dict):
|
||||
lines.append('')
|
||||
break
|
||||
|
||||
#debug_list('*' * 10 + ' begin ' + '*' * 10, lines[start:])
|
||||
if not lines[start:] and not lines[end:]:
|
||||
return []
|
||||
|
||||
@ -225,25 +249,18 @@ def set_paragraph_properties(lines, prop_dict):
|
||||
|
||||
return result[:]
|
||||
|
||||
def debug_list(title, list):
|
||||
sys.stderr.write(title+'\n')
|
||||
for line in list:
|
||||
sys.stderr.write(line+'\n')
|
||||
|
||||
def update_language(header):
|
||||
i = find_token(header, "\\language", 0)
|
||||
if i == -1:
|
||||
# no language, should emit a warning
|
||||
header.append('\\language english')
|
||||
return
|
||||
# FIXME: find the document default language in user preferences
|
||||
# This is the lyx behaviour: defaults to english
|
||||
header[i] = '\\language english'
|
||||
return
|
||||
|
||||
def convert(header,body):
|
||||
sys.stderr.write("%d\n" % len(body))
|
||||
update_tabular(body)
|
||||
sys.stderr.write("%d\n" % len(body))
|
||||
update_language(header)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user