mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
Convert all python files to utf-8.
Add a documentation string to each module. Add a documentation string to every function in the modules. file is a python reserved word => s/file/document/g as variable add a new property to modules, supported_versions that holds the versions supported by that module git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14534 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2987ccdd9e
commit
695bfd88ed
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2002-2004 Dekel Tsur <dekel@lyx.org>, José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2002-2004 Dekel Tsur <dekel@lyx.org>, José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -34,6 +34,7 @@ default_debug_level = 2
|
||||
# Private helper functions
|
||||
|
||||
def find_end_of_inset(lines, i):
|
||||
" Find beginning of inset, where lines[i] is included."
|
||||
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
|
||||
|
||||
# End of helper functions
|
||||
@ -49,16 +50,16 @@ original_version = re.compile(r"\#LyX (\S*)")
|
||||
# file format information:
|
||||
# file, supported formats, stable release versions
|
||||
format_relation = [("0_08", [210], ["0.8.%d" % i for i in range(7)] + ["0.8"]),
|
||||
("0_10", [210], ["0.10.7","0.10"]),
|
||||
("0_12", [215], ["0.12","0.12.1","0.12"]),
|
||||
("0_10", [210], ["0.10.%d" % i for i in range(8)] + ["0.10"]),
|
||||
("0_12", [215], ["0.12.0","0.12.1","0.12"]),
|
||||
("1_0_0", [215], ["1.0.0","1.0"]),
|
||||
("1_0_1", [215], ["1.0.1","1.0.2","1.0.3","1.0.4", "1.1.2","1.1"]),
|
||||
("1_1_4", [215], ["1.1.4","1.1"]),
|
||||
("1_1_5", [216], ["1.1.5","1.1.5fix1","1.1.5fix2","1.1"]),
|
||||
("1_1_6_0", [217], ["1.1.6","1.1.6fix1","1.1.6fix2","1.1"]),
|
||||
("1_1_6_3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
|
||||
("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
|
||||
("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3.7","1.3"]),
|
||||
("1_2", [220], ["1.2.%d" % i for i in range(5)] + ["1.2"]),
|
||||
("1_3", [221], ["1.3.%d" % i for i in range(8)] + ["1.3"]),
|
||||
("1_4", range(222,246), ["1.4.0", "1.4.1", "1.4.2","1.4.3svn"]),
|
||||
("1_5", range(246,249), ["1.5.0svn","1.5"])]
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx -*- python -*-
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2006 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -16,8 +16,9 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files generated by lyx 0.8"""
|
||||
""" Convert files to the file format generated by lyx 0.8"""
|
||||
|
||||
supported_versions = ["0.8.%d" % i for i in range(7)] + ["0.8"]
|
||||
convert = [[210, []]]
|
||||
revert = []
|
||||
|
||||
|
@ -16,10 +16,10 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files generated by lyx 0.10"""
|
||||
""" Convert files to the file format generated by lyx 0.10"""
|
||||
|
||||
def regularise_header(document):
|
||||
" Place tokens in their separate line. "
|
||||
" Put each entry in header into a separate line. "
|
||||
i = 0
|
||||
while i < len(document.header):
|
||||
line = document.header[i]
|
||||
@ -31,8 +31,9 @@ def regularise_header(document):
|
||||
|
||||
|
||||
def find_next_space(line, j):
|
||||
""" Return position of next space, starting from position k, if
|
||||
not existing return last position in line."""
|
||||
""" Return position of next space or backslash, which one comes
|
||||
first, starting from position k, if not existing return last
|
||||
position in line."""
|
||||
l = line.find(' ', j)
|
||||
if l == -1:
|
||||
l = len(line)
|
||||
@ -46,6 +47,20 @@ def find_next_space(line, j):
|
||||
|
||||
|
||||
def regularise_body(document):
|
||||
""" Place tokens starting with a backslash into a separate line. """
|
||||
|
||||
getline_tokens = ["added_space_bottom", "added_space_top",
|
||||
"align", "layout", "fill_bottom", "fill_top",
|
||||
"labelwidthstring", "pagebreak_top",
|
||||
"pagebreak_bottom", "noindent"]
|
||||
|
||||
noargs_tokens = ["backslash", "begin_deeper", "end_deeper",
|
||||
"end_float", "end_inset", "hfill", "newline",
|
||||
"protected_separator"]
|
||||
|
||||
onearg_tokens = ["bar", "begin_float", "family", "latex", "shape",
|
||||
"size", "series", "cursor"]
|
||||
|
||||
i = 0
|
||||
while i < len(document.body):
|
||||
line = document.body[i]
|
||||
@ -66,18 +81,18 @@ def regularise_body(document):
|
||||
|
||||
# These tokens take the rest of the line
|
||||
token = line[j+1:k]
|
||||
if token in ["added_space_bottom", "added_space_top", "align", "layout", "fill_bottom", "fill_top", "labelwidthstring", "pagebreak_top", "pagebreak_bottom", "noindent"]:
|
||||
if token in getline_tokens:
|
||||
tmp += [line[j:]]
|
||||
break
|
||||
|
||||
# These tokens take no arguments
|
||||
if token in ["backslash", "begin_deeper", "end_deeper", "end_float", "end_inset", "hfill", "newline", "protected_separator"]:
|
||||
if token in noargs_tokens:
|
||||
tmp += [line[j:k]]
|
||||
j = k
|
||||
continue
|
||||
|
||||
# These tokens take one argument
|
||||
if token in ["bar", "begin_float", "family", "latex", "shape", "size", "series", "cursor"]:
|
||||
if token in onearg_tokens:
|
||||
k = find_next_space(line, k + 1)
|
||||
tmp += [line[j:k]]
|
||||
j = k
|
||||
@ -113,10 +128,10 @@ def regularise_body(document):
|
||||
i += len(tmp)
|
||||
|
||||
|
||||
supported_versions = ["0.10.%d" % i for i in range(8)] + ["0.10"]
|
||||
convert = [[210, [regularise_header, regularise_body]]]
|
||||
revert = []
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2003-2004 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2003-2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -16,41 +16,47 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 0.12"""
|
||||
|
||||
import re
|
||||
import string
|
||||
from parser_tools import find_token, find_re, check_token
|
||||
|
||||
|
||||
def space_before_layout(file):
|
||||
lines = file.body
|
||||
def space_before_layout(document):
|
||||
" Remove empty line before \\layout. "
|
||||
lines = document.body
|
||||
i = 2 # skip first layout
|
||||
while 1:
|
||||
i = find_token(lines, '\\layout', i)
|
||||
if i == -1:
|
||||
break
|
||||
|
||||
if lines[i - 1] == '' and string.find(lines[i-2],'\\protected_separator') == -1:
|
||||
prot_space = string.find(lines[i-2],'\\protected_separator')
|
||||
if lines[i - 1] == '' and prot_space == -1:
|
||||
del lines[i-1]
|
||||
i = i + 1
|
||||
|
||||
|
||||
def formula_inset_space_eat(file):
|
||||
lines = file.body
|
||||
i=0
|
||||
def formula_inset_space_eat(document):
|
||||
" Remove space after inset formula."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset Formula", i)
|
||||
if i == -1: break
|
||||
if i == -1:
|
||||
break
|
||||
|
||||
if len(lines[i]) > 22 and lines[i][21] == ' ':
|
||||
lines[i] = lines[i][:20] + lines[i][21:]
|
||||
i = i + 1
|
||||
|
||||
|
||||
# Update from tabular format 1 or 2 to 4
|
||||
def update_tabular(file):
|
||||
lines = file.body
|
||||
def update_tabular(document):
|
||||
" Update from tabular format 1 or 2 to 4."
|
||||
lines = document.body
|
||||
lyxtable_re = re.compile(r".*\\LyXTable$")
|
||||
i=0
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_re(lines, lyxtable_re, i)
|
||||
if i == -1:
|
||||
@ -58,7 +64,7 @@ def update_tabular(file):
|
||||
i = i + 1
|
||||
format = lines[i][8:]
|
||||
|
||||
lines[i]='multicol4'
|
||||
lines[i] = 'multicol4'
|
||||
i = i + 1
|
||||
rows = int(string.split(lines[i])[0])
|
||||
columns = int(string.split(lines[i])[1])
|
||||
@ -82,19 +88,26 @@ def update_tabular(file):
|
||||
|
||||
lines[i] = string.strip(lines[i])
|
||||
|
||||
def final_dot(file):
|
||||
lines = file.body
|
||||
|
||||
def final_dot(document):
|
||||
" Merge lines if the dot is the final character."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while i < len(lines):
|
||||
if lines[i][-1:] == '.' and lines[i+1][:1] != '\\' and lines[i+1][:1] != ' ' and len(lines[i]) + len(lines[i+1])<= 72 and lines[i+1] != '':
|
||||
|
||||
if lines[i][-1:] == '.' and lines[i+1][:1] != '\\' and \
|
||||
lines[i+1][:1] != ' ' and len(lines[i]) + len(lines[i+1])<= 72 \
|
||||
and lines[i+1] != '':
|
||||
|
||||
lines[i] = lines[i] + lines[i+1]
|
||||
del lines[i+1]
|
||||
else:
|
||||
i = i + 1
|
||||
|
||||
|
||||
def update_inset_label(file):
|
||||
lines = file.body
|
||||
def update_inset_label(document):
|
||||
" Update inset Label."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, '\\begin_inset Label', i)
|
||||
@ -104,26 +117,35 @@ def update_inset_label(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def update_latexdel(file):
|
||||
lines = file.body
|
||||
def update_latexdel(document):
|
||||
" Update inset LatexDel."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, '\\begin_inset LatexDel', i)
|
||||
if i == -1:
|
||||
return
|
||||
lines[i] = string.replace(lines[i],'\\begin_inset LatexDel', '\\begin_inset LatexCommand')
|
||||
lines[i] = string.replace(lines[i],
|
||||
'\\begin_inset LatexDel',
|
||||
'\\begin_inset LatexCommand')
|
||||
i = i + 1
|
||||
|
||||
|
||||
def update_vfill(file):
|
||||
lines = file.body
|
||||
def update_vfill(document):
|
||||
" Update fill_top and fill_bottom."
|
||||
lines = document.body
|
||||
for i in range(len(lines)):
|
||||
lines[i] = string.replace(lines[i],'\\fill_top','\\added_space_top vfill')
|
||||
lines[i] = string.replace(lines[i],'\\fill_bottom','\\added_space_bottom vfill')
|
||||
lines[i] = string.replace(lines[i],
|
||||
'\\fill_top',
|
||||
'\\added_space_top vfill')
|
||||
lines[i] = string.replace(lines[i],
|
||||
'\\fill_bottom',
|
||||
'\\added_space_bottom vfill')
|
||||
|
||||
|
||||
def update_space_units(file):
|
||||
lines = file.body
|
||||
def update_space_units(document):
|
||||
" Update space units."
|
||||
lines = document.body
|
||||
added_space_bottom = re.compile(r'\\added_space_bottom ([^ ]*)')
|
||||
added_space_top = re.compile(r'\\added_space_top ([^ ]*)')
|
||||
for i in range(len(lines)):
|
||||
@ -140,8 +162,9 @@ def update_space_units(file):
|
||||
lines[i] = string.replace(lines[i], old, new)
|
||||
|
||||
|
||||
def remove_cursor(file):
|
||||
lines = file.body
|
||||
def remove_cursor(document):
|
||||
" Remove cursor, it is not saved on the file anymore."
|
||||
lines = document.body
|
||||
i = 0
|
||||
cursor_re = re.compile(r'.*(\\cursor \d*)')
|
||||
while 1:
|
||||
@ -149,15 +172,16 @@ def remove_cursor(file):
|
||||
if i == -1:
|
||||
break
|
||||
cursor = cursor_re.search(lines[i]).group(1)
|
||||
lines[i]= string.replace(lines[i], cursor, '')
|
||||
lines[i] = string.replace(lines[i], cursor, '')
|
||||
i = i + 1
|
||||
|
||||
|
||||
def remove_empty_insets(file):
|
||||
lines = file.body
|
||||
def remove_empty_insets(document):
|
||||
" Remove empty insets."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, '\\begin_inset ',i)
|
||||
i = find_token(lines, '\\begin_inset ', i)
|
||||
if i == -1:
|
||||
break
|
||||
if lines[i] == '\\begin_inset ' and lines[i+1] == '\\end_inset ':
|
||||
@ -166,8 +190,9 @@ def remove_empty_insets(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def remove_formula_latex(file):
|
||||
lines = file.body
|
||||
def remove_formula_latex(document):
|
||||
" Remove formula latex."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, '\\latex formula_latex ', i)
|
||||
@ -181,15 +206,17 @@ def remove_formula_latex(file):
|
||||
del lines[i]
|
||||
|
||||
|
||||
def add_end_document(file):
|
||||
lines = file.body
|
||||
def add_end_document(document):
|
||||
" Add \\the_end to the end of the document."
|
||||
lines = document.body
|
||||
i = find_token(lines, '\\the_end', 0)
|
||||
if i == -1:
|
||||
lines.append('\\the_end')
|
||||
|
||||
|
||||
def header_update(file):
|
||||
lines = file.header
|
||||
def header_update(document):
|
||||
" Update document header."
|
||||
lines = document.header
|
||||
i = 0
|
||||
l = len(lines)
|
||||
while i < l:
|
||||
@ -241,8 +268,9 @@ def header_update(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def update_latexaccents(file):
|
||||
body = file.body
|
||||
def update_latexaccents(document):
|
||||
" Update latex accent insets."
|
||||
body = document.body
|
||||
i = 1
|
||||
while 1:
|
||||
i = find_token(body, '\\i ', i)
|
||||
@ -269,8 +297,9 @@ def update_latexaccents(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def obsolete_latex_title(file):
|
||||
body = file.body
|
||||
def obsolete_latex_title(document):
|
||||
" Replace layout Latex_Title with Title."
|
||||
body = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(body, '\\layout', i)
|
||||
@ -283,12 +312,14 @@ def obsolete_latex_title(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
supported_versions = ["0.12.0","0.12.1","0.12"]
|
||||
convert = [[215, [header_update, add_end_document, remove_cursor,
|
||||
final_dot, update_inset_label, update_latexdel,
|
||||
update_space_units, space_before_layout,
|
||||
formula_inset_space_eat, update_tabular,
|
||||
update_vfill, remove_empty_insets,
|
||||
remove_formula_latex, update_latexaccents, obsolete_latex_title]]]
|
||||
remove_formula_latex, update_latexaccents,
|
||||
obsolete_latex_title]]]
|
||||
revert = []
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -16,12 +16,16 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.0"""
|
||||
|
||||
import re
|
||||
import string
|
||||
from parser_tools import find_token, find_re
|
||||
|
||||
def obsolete_latex_title(file):
|
||||
body = file.body
|
||||
def obsolete_latex_title(document):
|
||||
" Replace LatexTitle layout with Title. "
|
||||
|
||||
body = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(body, '\\layout', i)
|
||||
@ -34,11 +38,12 @@ def obsolete_latex_title(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
# Update from tabular format 3 to 4 if necessary
|
||||
def update_tabular(file):
|
||||
lines = file.body
|
||||
def update_tabular(document):
|
||||
" Update from tabular format 3 to 4 if necessary."
|
||||
|
||||
lines = document.body
|
||||
lyxtable_re = re.compile(r".*\\LyXTable$")
|
||||
i=0
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_re(lines, lyxtable_re, i)
|
||||
if i == -1:
|
||||
@ -49,7 +54,7 @@ def update_tabular(file):
|
||||
if format != '3':
|
||||
continue
|
||||
|
||||
lines[i]='multicol4'
|
||||
lines[i] = 'multicol4'
|
||||
i = i + 1
|
||||
rows = int(string.split(lines[i])[0])
|
||||
columns = int(string.split(lines[i])[1])
|
||||
@ -72,6 +77,7 @@ def update_tabular(file):
|
||||
lines[i] = string.strip(lines[i])
|
||||
|
||||
|
||||
supported_versions = ["1.0.0","1.0"]
|
||||
convert = [[215, [obsolete_latex_title, update_tabular]]]
|
||||
revert = []
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -16,6 +16,9 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.0.1"""
|
||||
|
||||
supported_versions = ["1.0.1","1.0.2","1.0.3","1.0.4", "1.1.2","1.1"]
|
||||
convert = [[215, []]]
|
||||
revert = []
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -16,6 +16,9 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.1.4"""
|
||||
|
||||
supported_versions = ["1.1.4","1.1"]
|
||||
convert = [[215, []]]
|
||||
revert = []
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
|
||||
# This document is part of lyx2lyx
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -16,6 +16,8 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.1.5"""
|
||||
|
||||
import re
|
||||
import string
|
||||
from parser_tools import find_token, find_token_backwards, find_re
|
||||
@ -24,6 +26,7 @@ from parser_tools import find_token, find_token_backwards, find_re
|
||||
# Private helper functions
|
||||
|
||||
def get_layout(line, default_layout):
|
||||
" Get the line layout, beware of the empty layout."
|
||||
tokens = string.split(line)
|
||||
if len(tokens) > 1:
|
||||
return tokens[1]
|
||||
@ -34,8 +37,9 @@ def get_layout(line, default_layout):
|
||||
|
||||
math_env = ["\\[","\\begin{eqnarray*}","\\begin{eqnarray}","\\begin{equation}"]
|
||||
|
||||
def replace_protected_separator(file):
|
||||
lines = file.body
|
||||
def replace_protected_separator(document):
|
||||
" Replace protected separator. "
|
||||
lines = document.body
|
||||
i=0
|
||||
while 1:
|
||||
i = find_token(lines, "\\protected_separator", i)
|
||||
@ -43,7 +47,7 @@ def replace_protected_separator(file):
|
||||
break
|
||||
j = find_token_backwards(lines, "\\layout", i)
|
||||
#if j == -1: print error
|
||||
layout = get_layout(lines[j], file.default_layout)
|
||||
layout = get_layout(lines[j], document.default_layout)
|
||||
|
||||
if layout == "LyX-Code":
|
||||
result = ""
|
||||
@ -58,8 +62,9 @@ def replace_protected_separator(file):
|
||||
del lines[i]
|
||||
|
||||
|
||||
def merge_formula_inset(file):
|
||||
lines = file.body
|
||||
def merge_formula_inset(document):
|
||||
" Merge formula insets. "
|
||||
lines = document.body
|
||||
i=0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset Formula", i)
|
||||
@ -70,9 +75,9 @@ def merge_formula_inset(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
# Update from tabular format 4 to 5 if necessary
|
||||
def update_tabular(file):
|
||||
lines = file.body
|
||||
def update_tabular(document):
|
||||
" Update from tabular format 4 to 5 if necessary. "
|
||||
lines = document.body
|
||||
lyxtable_re = re.compile(r".*\\LyXTable$")
|
||||
i=0
|
||||
while 1:
|
||||
@ -103,26 +108,30 @@ def update_tabular(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def update_toc(file):
|
||||
lines = file.body
|
||||
def update_toc(document):
|
||||
" Update table of contents. "
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, '\\begin_inset LatexCommand \\tableofcontents', i)
|
||||
i = find_token(lines,
|
||||
'\\begin_inset LatexCommand \\tableofcontents', i)
|
||||
if i == -1:
|
||||
break
|
||||
lines[i] = lines[i] + '{}'
|
||||
i = i + 1
|
||||
|
||||
|
||||
def remove_cursor(file):
|
||||
lines = file.body
|
||||
def remove_cursor(document):
|
||||
" Remove cursor. "
|
||||
lines = document.body
|
||||
i = find_token(lines, '\\cursor', 0)
|
||||
if i != -1:
|
||||
del lines[i]
|
||||
|
||||
|
||||
def remove_vcid(file):
|
||||
lines = file.header
|
||||
def remove_vcid(document):
|
||||
" Remove \\lyxvcid and \\lyxrcsid. "
|
||||
lines = document.header
|
||||
i = find_token(lines, '\\lyxvcid', 0)
|
||||
if i != -1:
|
||||
del lines[i]
|
||||
@ -131,16 +140,18 @@ def remove_vcid(file):
|
||||
del lines[i]
|
||||
|
||||
|
||||
def first_layout(file):
|
||||
lines = file.body
|
||||
def first_layout(document):
|
||||
" Fix first layout, if empty use the default layout."
|
||||
lines = document.body
|
||||
while (lines[0] == ""):
|
||||
del lines[0]
|
||||
if lines[0][:7] != "\\layout":
|
||||
lines[:0] = ['\\layout %s' % file.default_layout, '']
|
||||
lines[:0] = ['\\layout %s' % document.default_layout, '']
|
||||
|
||||
|
||||
def remove_space_in_units(file):
|
||||
lines = file.header
|
||||
def remove_space_in_units(document):
|
||||
" Remove space in units. "
|
||||
lines = document.header
|
||||
margins = ["\\topmargin","\\rightmargin",
|
||||
"\\leftmargin","\\bottommargin"]
|
||||
|
||||
@ -159,8 +170,9 @@ def remove_space_in_units(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def latexdel_getargs(file, i):
|
||||
lines = file.body
|
||||
def latexdel_getargs(document, i):
|
||||
" Get arguments from latexdel insets. "
|
||||
lines = document.body
|
||||
|
||||
# play safe, clean empty lines
|
||||
while 1:
|
||||
@ -173,7 +185,7 @@ def latexdel_getargs(file, i):
|
||||
if i == j:
|
||||
del lines[i]
|
||||
else:
|
||||
file.warning("Unexpected end of inset.")
|
||||
document.warning("Unexpected end of inset.")
|
||||
j = find_token(lines, '\\begin_inset LatexDel }{', i)
|
||||
|
||||
ref = string.join(lines[i:j])
|
||||
@ -189,7 +201,7 @@ def latexdel_getargs(file, i):
|
||||
if i == j:
|
||||
del lines[i]
|
||||
else:
|
||||
file.warning("Unexpected end of inset.")
|
||||
document.warning("Unexpected end of inset.")
|
||||
j = find_token(lines, '\\begin_inset LatexDel }', i)
|
||||
label = string.join(lines[i:j])
|
||||
del lines[i:j + 1]
|
||||
@ -197,8 +209,9 @@ def latexdel_getargs(file, i):
|
||||
return ref, label
|
||||
|
||||
|
||||
def update_ref(file):
|
||||
lines = file.body
|
||||
def update_ref(document):
|
||||
" Update reference inset. "
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, '\\begin_inset LatexCommand', i)
|
||||
@ -207,21 +220,24 @@ def update_ref(file):
|
||||
|
||||
if string.split(lines[i])[-1] == "\\ref{":
|
||||
i = i + 1
|
||||
ref, label = latexdel_getargs(file, i)
|
||||
ref, label = latexdel_getargs(document, i)
|
||||
lines[i - 1] = "%s[%s]{%s}" % (lines[i - 1][:-1], ref, label)
|
||||
|
||||
i = i + 1
|
||||
|
||||
|
||||
def update_latexdel(file):
|
||||
lines = file.body
|
||||
def update_latexdel(document):
|
||||
" Remove latexdel insets. "
|
||||
lines = document.body
|
||||
i = 0
|
||||
latexdel_re = re.compile(r".*\\begin_inset LatexDel")
|
||||
while 1:
|
||||
i = find_re(lines, latexdel_re, i)
|
||||
if i == -1:
|
||||
return
|
||||
lines[i] = string.replace(lines[i],'\\begin_inset LatexDel', '\\begin_inset LatexCommand')
|
||||
lines[i] = string.replace(lines[i],
|
||||
'\\begin_inset LatexDel',
|
||||
'\\begin_inset LatexCommand')
|
||||
|
||||
j = string.find(lines[i],'\\begin_inset')
|
||||
lines.insert(i+1, lines[i][j:])
|
||||
@ -231,15 +247,19 @@ def update_latexdel(file):
|
||||
if string.split(lines[i])[-1] in ("\\url{", "\\htmlurl{"):
|
||||
i = i + 1
|
||||
|
||||
ref, label = latexdel_getargs(file, i)
|
||||
ref, label = latexdel_getargs(document, i)
|
||||
lines[i -1] = "%s[%s]{%s}" % (lines[i-1][:-1], label, ref)
|
||||
|
||||
i = i + 1
|
||||
|
||||
|
||||
convert = [[216, [first_layout, remove_vcid, remove_cursor, update_toc,
|
||||
replace_protected_separator, merge_formula_inset,
|
||||
update_tabular, remove_space_in_units, update_ref, update_latexdel]]]
|
||||
supported_versions = ["1.1.5","1.1.5fix1","1.1.5fix2","1.1"]
|
||||
convert = [[216, [first_layout, remove_vcid, remove_cursor,
|
||||
update_toc, replace_protected_separator,
|
||||
merge_formula_inset, update_tabular,
|
||||
remove_space_in_units, update_ref,
|
||||
update_latexdel]]]
|
||||
|
||||
revert = []
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -16,14 +16,16 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.1.6"""
|
||||
|
||||
import re
|
||||
import string
|
||||
from parser_tools import find_re, find_tokens, find_token, check_token
|
||||
|
||||
|
||||
lyxtable_re = re.compile(r".*\\LyXTable$")
|
||||
def update_tabular(file):
|
||||
lines = file.body
|
||||
def update_tabular(document):
|
||||
" Update tabular to version 1 (xml like syntax). "
|
||||
lines = document.body
|
||||
i=0
|
||||
while 1:
|
||||
i = find_re(lines, lyxtable_re, i)
|
||||
@ -100,13 +102,13 @@ def update_tabular(file):
|
||||
continue
|
||||
|
||||
if l == ncells -1:
|
||||
# the end variable refers to cell end, not to file end.
|
||||
# the end variable refers to cell end, not to document end.
|
||||
end = find_tokens(lines, ['\\layout','\\the_end','\\end_deeper','\\end_float'], i)
|
||||
else:
|
||||
end = find_token(lines, '\\newline', i)
|
||||
|
||||
if end == -1:
|
||||
file.error("Malformed LyX file.")
|
||||
document.error("Malformed LyX file.")
|
||||
|
||||
end = end - i
|
||||
while end > 0:
|
||||
@ -146,7 +148,7 @@ def update_tabular(file):
|
||||
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]))
|
||||
tmp.append('\\begin_inset Text')
|
||||
tmp.append('')
|
||||
tmp.append('\\layout %s' % file.default_layout)
|
||||
tmp.append('\\layout %s' % document.default_layout)
|
||||
tmp.append('')
|
||||
|
||||
if cell_info[m][0] != '2':
|
||||
@ -179,8 +181,8 @@ def update_tabular(file):
|
||||
|
||||
|
||||
prop_exp = re.compile(r"\\(\S*)\s*(\S*)")
|
||||
|
||||
def set_paragraph_properties(lines, prop_dict):
|
||||
" Set paragraph properties."
|
||||
# we need to preserve the order of options
|
||||
properties = ["family","series","shape","size",
|
||||
"emph","bar","noun","latex","color"]
|
||||
@ -263,8 +265,10 @@ def set_paragraph_properties(lines, prop_dict):
|
||||
return result[:]
|
||||
|
||||
|
||||
def update_language(file):
|
||||
header = file.header
|
||||
def update_language(document):
|
||||
" Update document language, if language is default convert it to
|
||||
english."
|
||||
header = document.header
|
||||
i = find_token(header, "\\language", 0)
|
||||
if i == -1:
|
||||
# no language, should emit a warning
|
||||
@ -276,6 +280,7 @@ def update_language(file):
|
||||
return
|
||||
|
||||
|
||||
supported_versions = ["1.1.6","1.1.6fix1","1.1.6fix2","1.1"]
|
||||
convert = [[217, [update_tabular, update_language]]]
|
||||
revert = []
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -16,11 +16,14 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.1.6fix3"""
|
||||
|
||||
import re
|
||||
import string
|
||||
from parser_tools import find_token, find_re
|
||||
|
||||
def bool_table(item):
|
||||
" Convert 0, 1 to false, true."
|
||||
if item == "0":
|
||||
return "false"
|
||||
# should emit a warning if item != "1"
|
||||
@ -32,9 +35,10 @@ align_table = {"0": "top", "2": "left", "4": "right", "8": "center"}
|
||||
use_table = {"0": "none", "1": "parbox"}
|
||||
table_meta_re = re.compile(r'<LyXTabular version="?1"? rows="?(\d*)"? columns="?(\d*)"?>')
|
||||
|
||||
def update_tabular(file):
|
||||
def update_tabular(document):
|
||||
" Update tabular format to version 2 (xml like syntax)."
|
||||
regexp = re.compile(r'^\\begin_inset\s+Tabular')
|
||||
lines = file.body
|
||||
lines = document.body
|
||||
i=0
|
||||
while 1:
|
||||
i = find_re(lines, regexp, i)
|
||||
@ -51,7 +55,7 @@ def update_tabular(file):
|
||||
|
||||
j = find_token(lines, '</LyXTabular>', i) + 1
|
||||
if j == 0:
|
||||
file.warning( "Error: Bad lyx format i=%d j=%d" % (i,j))
|
||||
document.warning( "Error: Bad lyx format i=%d j=%d" % (i,j))
|
||||
break
|
||||
|
||||
new_table = table_update(lines[i:j])
|
||||
@ -65,6 +69,7 @@ features_re = re.compile(r'<features rotate="?(\d)"? islongtable="?(\d)"? endhea
|
||||
row_re = re.compile(r'<row topline="?(\d)"? bottomline="?(\d)"? newpage="?(\d)"?>')
|
||||
|
||||
def table_update(lines):
|
||||
" Update table's internal content to format 2."
|
||||
lines[1] = string.replace(lines[1], '<Features', '<features')
|
||||
res = features_re.match( lines[1] )
|
||||
if res:
|
||||
@ -116,6 +121,7 @@ def table_update(lines):
|
||||
return lines[:2] + col_info + lines[2:]
|
||||
|
||||
|
||||
supported_versions = ["1.1.6fix3","1.1.6fix4","1.1"]
|
||||
convert = [[218, [update_tabular]]]
|
||||
revert = []
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2002 Dekel Tsur <dekel@lyx.org>
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -17,11 +17,14 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.2"""
|
||||
|
||||
import string
|
||||
import re
|
||||
|
||||
from parser_tools import find_token, find_token_backwards, \
|
||||
find_tokens, find_tokens_backwards, find_beginning_of, find_end_of, find_re, \
|
||||
find_tokens, find_tokens_backwards,
|
||||
find_beginning_of, find_end_of, find_re, \
|
||||
is_nonempty_line, find_nonempty_line, \
|
||||
get_value, check_token
|
||||
|
||||
@ -29,14 +32,15 @@ from parser_tools import find_token, find_token_backwards, \
|
||||
# Private helper functions
|
||||
|
||||
def get_layout(line, default_layout):
|
||||
" Get layout, if empty return the default layout."
|
||||
tokens = string.split(line)
|
||||
if len(tokens) > 1:
|
||||
return tokens[1]
|
||||
return default_layout
|
||||
|
||||
|
||||
# Finds the paragraph that contains line i.
|
||||
def get_paragraph(lines, i, format):
|
||||
" Finds the paragraph that contains line i."
|
||||
begin_layout = "\\layout"
|
||||
|
||||
while i != -1:
|
||||
@ -48,8 +52,8 @@ def get_paragraph(lines, i, format):
|
||||
return -1
|
||||
|
||||
|
||||
# Finds the paragraph after the paragraph that contains line i.
|
||||
def get_next_paragraph(lines, i, format):
|
||||
" Finds the paragraph after the paragraph that contains line i."
|
||||
tokens = ["\\begin_inset", "\\layout", "\\end_float", "\\the_end"]
|
||||
|
||||
while i != -1:
|
||||
@ -61,19 +65,22 @@ def get_next_paragraph(lines, i, format):
|
||||
|
||||
|
||||
def find_beginning_of_inset(lines, i):
|
||||
" Find beginning of inset, where lines[i] is included."
|
||||
return find_beginning_of(lines, i, "\\begin_inset", "\\end_inset")
|
||||
|
||||
|
||||
# Finds the matching \end_inset
|
||||
def find_end_of_inset(lines, i):
|
||||
" Finds the matching \end_inset"
|
||||
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
|
||||
|
||||
|
||||
def find_end_of_tabular(lines, i):
|
||||
" Finds the matching end of tabular."
|
||||
return find_end_of(lines, i, "<lyxtabular", "</lyxtabular")
|
||||
|
||||
|
||||
def get_tabular_lines(lines, i):
|
||||
" Returns a lists of tabular lines."
|
||||
result = []
|
||||
i = i+1
|
||||
j = find_end_of_tabular(lines, i)
|
||||
@ -126,6 +133,7 @@ pextra_rexp = re.compile(r"\\pextra_type\s+(\S+)"+\
|
||||
|
||||
|
||||
def get_width(mo):
|
||||
" Get width from a regular expression. "
|
||||
if mo.group(10):
|
||||
if mo.group(9) == "\\pextra_widthp":
|
||||
return mo.group(10)+"col%"
|
||||
@ -135,11 +143,9 @@ def get_width(mo):
|
||||
return "100col%"
|
||||
|
||||
|
||||
#
|
||||
# Change \begin_float .. \end_float into \begin_inset Float .. \end_inset
|
||||
#
|
||||
def remove_oldfloat(file):
|
||||
lines = file.body
|
||||
def remove_oldfloat(document):
|
||||
" Change \begin_float .. \end_float into \begin_inset Float .. \end_inset"
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_float", i)
|
||||
@ -150,7 +156,7 @@ def remove_oldfloat(file):
|
||||
|
||||
floattype = string.split(lines[i])[1]
|
||||
if not floats.has_key(floattype):
|
||||
file.warning("Error! Unknown float type " + floattype)
|
||||
document.warning("Error! Unknown float type " + floattype)
|
||||
floattype = "fig"
|
||||
|
||||
# skip \end_deeper tokens
|
||||
@ -158,7 +164,7 @@ def remove_oldfloat(file):
|
||||
while check_token(lines[i2], "\\end_deeper"):
|
||||
i2 = i2+1
|
||||
if i2 > i+1:
|
||||
j2 = get_next_paragraph(lines, j + 1, file.format + 1)
|
||||
j2 = get_next_paragraph(lines, j + 1, document.format + 1)
|
||||
lines[j2:j2] = ["\\end_deeper "]*(i2-(i+1))
|
||||
|
||||
new = floats[floattype]+[""]
|
||||
@ -183,7 +189,7 @@ def remove_oldfloat(file):
|
||||
# as extra '\foo default' commands are ignored.
|
||||
# In fact, it might be safer to output '\foo default' for all
|
||||
# font attributes.
|
||||
k = get_paragraph(lines, i, file.format + 1)
|
||||
k = get_paragraph(lines, i, document.format + 1)
|
||||
flag = 0
|
||||
for token in font_tokens:
|
||||
if find_token(lines, token, k, i) != -1:
|
||||
@ -193,7 +199,7 @@ def remove_oldfloat(file):
|
||||
flag = 1
|
||||
new.append("")
|
||||
if token == "\\lang":
|
||||
new.append(token+" "+ file.language)
|
||||
new.append(token+" "+ document.language)
|
||||
else:
|
||||
new.append(token+" default ")
|
||||
|
||||
@ -205,8 +211,9 @@ pextra_type2_rexp = re.compile(r".*\\pextra_type\s+[12]")
|
||||
pextra_type2_rexp2 = re.compile(r".*(\\layout|\\pextra_type\s+2)")
|
||||
pextra_widthp = re.compile(r"\\pextra_widthp")
|
||||
|
||||
def remove_pextra(file):
|
||||
lines = file.body
|
||||
def remove_pextra(document):
|
||||
" Remove pextra token."
|
||||
lines = document.body
|
||||
i = 0
|
||||
flag = 0
|
||||
while 1:
|
||||
@ -246,10 +253,10 @@ def remove_pextra(file):
|
||||
if hfill:
|
||||
start = ["","\hfill",""]+start
|
||||
else:
|
||||
start = ['\\layout %s' % file.default_layout,''] + start
|
||||
start = ['\\layout %s' % document.default_layout,''] + start
|
||||
|
||||
j0 = find_token_backwards(lines,"\\layout", i-1)
|
||||
j = get_next_paragraph(lines, i, file.format + 1)
|
||||
j = get_next_paragraph(lines, i, document.format + 1)
|
||||
|
||||
count = 0
|
||||
while 1:
|
||||
@ -277,6 +284,7 @@ def remove_pextra(file):
|
||||
|
||||
|
||||
def is_empty(lines):
|
||||
" Are all the lines empty?"
|
||||
return filter(is_nonempty_line, lines) == []
|
||||
|
||||
|
||||
@ -285,13 +293,14 @@ ert_rexp = re.compile(r"\\begin_inset|\\hfill|.*\\SpecialChar")
|
||||
spchar_rexp = re.compile(r"(.*)(\\SpecialChar.*)")
|
||||
|
||||
|
||||
def remove_oldert(file):
|
||||
def remove_oldert(document):
|
||||
" Remove old ERT inset."
|
||||
ert_begin = ["\\begin_inset ERT",
|
||||
"status Collapsed",
|
||||
"",
|
||||
'\\layout %s' % file.default_layout,
|
||||
'\\layout %s' % document.default_layout,
|
||||
""]
|
||||
lines = file.body
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_tokens(lines, ["\\latex latex", "\\layout LaTeX"], i)
|
||||
@ -316,7 +325,7 @@ def remove_oldert(file):
|
||||
new = []
|
||||
new2 = []
|
||||
if check_token(lines[i], "\\layout LaTeX"):
|
||||
new = ['\layout %s' % file.default_layout, "", ""]
|
||||
new = ['\layout %s' % document.default_layout, "", ""]
|
||||
|
||||
k = i+1
|
||||
while 1:
|
||||
@ -398,9 +407,9 @@ def remove_oldert(file):
|
||||
del lines[i]
|
||||
|
||||
|
||||
# ERT insert are hidden feature of lyx 1.1.6. This might be removed in the future.
|
||||
def remove_oldertinset(file):
|
||||
lines = file.body
|
||||
def remove_oldertinset(document):
|
||||
" ERT insert are hidden feature of lyx 1.1.6. This might be removed in the future."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset ERT", i)
|
||||
@ -408,7 +417,7 @@ def remove_oldertinset(file):
|
||||
break
|
||||
j = find_end_of_inset(lines, i)
|
||||
k = find_token(lines, "\\layout", i+1)
|
||||
l = get_paragraph(lines, i, file.format + 1)
|
||||
l = get_paragraph(lines, i, document.format + 1)
|
||||
if lines[k] == lines[l]: # same layout
|
||||
k = k+1
|
||||
new = lines[k:j]
|
||||
@ -416,11 +425,12 @@ def remove_oldertinset(file):
|
||||
i = i+1
|
||||
|
||||
|
||||
def is_ert_paragraph(file, i):
|
||||
lines = file.body
|
||||
def is_ert_paragraph(document, i):
|
||||
" Is this a ert paragraph? "
|
||||
lines = document.body
|
||||
if not check_token(lines[i], "\\layout"):
|
||||
return 0
|
||||
if not file.is_default_layout(get_layout(lines[i], file.default_layout)):
|
||||
if not document.is_default_layout(get_layout(lines[i], document.default_layout)):
|
||||
return 0
|
||||
|
||||
i = find_nonempty_line(lines, i+1)
|
||||
@ -432,17 +442,18 @@ def is_ert_paragraph(file, i):
|
||||
return check_token(lines[k], "\\layout")
|
||||
|
||||
|
||||
def combine_ert(file):
|
||||
lines = file.body
|
||||
def combine_ert(document):
|
||||
" Combine ERT paragraphs."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset ERT", i)
|
||||
if i == -1:
|
||||
break
|
||||
j = get_paragraph(lines, i, file.format + 1)
|
||||
j = get_paragraph(lines, i, document.format + 1)
|
||||
count = 0
|
||||
text = []
|
||||
while is_ert_paragraph(file, j):
|
||||
while is_ert_paragraph(document, j):
|
||||
|
||||
count = count+1
|
||||
i2 = find_token(lines, "\\layout", j+1)
|
||||
@ -462,6 +473,7 @@ def combine_ert(file):
|
||||
oldunits = ["pt", "cm", "in", "text%", "col%"]
|
||||
|
||||
def get_length(lines, name, start, end):
|
||||
" Get lenght."
|
||||
i = find_token(lines, name, start, end)
|
||||
if i == -1:
|
||||
return ""
|
||||
@ -470,12 +482,14 @@ def get_length(lines, name, start, end):
|
||||
|
||||
|
||||
def write_attribute(x, token, value):
|
||||
" Write attribute."
|
||||
if value != "":
|
||||
x.append("\t"+token+" "+value)
|
||||
|
||||
|
||||
def remove_figinset(file):
|
||||
lines = file.body
|
||||
def remove_figinset(document):
|
||||
" Remove figinset."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset Figure", i)
|
||||
@ -543,15 +557,13 @@ def remove_figinset(file):
|
||||
lines[i:j+1] = new
|
||||
|
||||
|
||||
##
|
||||
# Convert tabular format 2 to 3
|
||||
#
|
||||
attr_re = re.compile(r' \w*="(false|0|)"')
|
||||
line_re = re.compile(r'<(features|column|row|cell)')
|
||||
|
||||
def update_tabular(file):
|
||||
def update_tabular(document):
|
||||
" Convert tabular format 2 to 3."
|
||||
regexp = re.compile(r'^\\begin_inset\s+Tabular')
|
||||
lines = file.body
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_re(lines, regexp, i)
|
||||
@ -587,8 +599,8 @@ def update_tabular(file):
|
||||
false = 0
|
||||
true = 1
|
||||
|
||||
# simple data structure to deal with long table info
|
||||
class row:
|
||||
" Simple data structure to deal with long table info."
|
||||
def __init__(self):
|
||||
self.endhead = false # header row
|
||||
self.endfirsthead = false # first header row
|
||||
@ -597,6 +609,7 @@ class row:
|
||||
|
||||
|
||||
def haveLTFoot(row_info):
|
||||
" Does row has LTFoot?"
|
||||
for row_ in row_info:
|
||||
if row_.endfoot:
|
||||
return true
|
||||
@ -604,6 +617,7 @@ def haveLTFoot(row_info):
|
||||
|
||||
|
||||
def setHeaderFooterRows(hr, fhr, fr, lfr, rows_, row_info):
|
||||
" Set Header/Footer rows."
|
||||
endfirsthead_empty = false
|
||||
endlastfoot_empty = false
|
||||
# set header info
|
||||
@ -670,6 +684,7 @@ def setHeaderFooterRows(hr, fhr, fr, lfr, rows_, row_info):
|
||||
|
||||
|
||||
def insert_attribute(lines, i, attribute):
|
||||
" Insert attribute in lines[i]."
|
||||
last = string.find(lines[i],'>')
|
||||
lines[i] = lines[i][:last] + ' ' + attribute + lines[i][last:]
|
||||
|
||||
@ -678,9 +693,10 @@ rows_re = re.compile(r'rows="(\d*)"')
|
||||
longtable_re = re.compile(r'islongtable="(\w)"')
|
||||
ltvalues_re = re.compile(r'endhead="(-?\d*)" endfirsthead="(-?\d*)" endfoot="(-?\d*)" endlastfoot="(-?\d*)"')
|
||||
lt_features_re = re.compile(r'(endhead="-?\d*" endfirsthead="-?\d*" endfoot="-?\d*" endlastfoot="-?\d*")')
|
||||
def update_longtables(file):
|
||||
def update_longtables(document):
|
||||
" Update longtables to new format."
|
||||
regexp = re.compile(r'^\\begin_inset\s+Tabular')
|
||||
body = file.body
|
||||
body = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_re(body, regexp, i)
|
||||
@ -747,9 +763,9 @@ def update_longtables(file):
|
||||
i = i + 1
|
||||
|
||||
|
||||
# Figure insert are hidden feature of lyx 1.1.6. This might be removed in the future.
|
||||
def fix_oldfloatinset(file):
|
||||
lines = file.body
|
||||
def fix_oldfloatinset(document):
|
||||
" Figure insert are hidden feature of lyx 1.1.6. This might be removed in the future."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset Float ", i)
|
||||
@ -761,8 +777,9 @@ def fix_oldfloatinset(file):
|
||||
i = i+1
|
||||
|
||||
|
||||
def change_listof(file):
|
||||
lines = file.body
|
||||
def change_listof(document):
|
||||
" Change listof insets."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset LatexCommand \\listof", i)
|
||||
@ -773,8 +790,9 @@ def change_listof(file):
|
||||
i = i+1
|
||||
|
||||
|
||||
def change_infoinset(file):
|
||||
lines = file.body
|
||||
def change_infoinset(document):
|
||||
" Change info inset."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset Info", i)
|
||||
@ -791,7 +809,7 @@ def change_infoinset(file):
|
||||
note_lines = [txt]+note_lines
|
||||
|
||||
for line in note_lines:
|
||||
new = new + ['\layout %s' % file.default_layout, ""]
|
||||
new = new + ['\layout %s' % document.default_layout, ""]
|
||||
tmp = string.split(line, '\\')
|
||||
new = new + [tmp[0]]
|
||||
for x in tmp[1:]:
|
||||
@ -800,8 +818,9 @@ def change_infoinset(file):
|
||||
i = i+5
|
||||
|
||||
|
||||
def change_header(file):
|
||||
lines = file.header
|
||||
def change_header(document):
|
||||
" Update header."
|
||||
lines = document.header
|
||||
i = find_token(lines, "\\use_amsmath", 0)
|
||||
if i == -1:
|
||||
return
|
||||
@ -809,6 +828,7 @@ def change_header(file):
|
||||
"\use_numerical_citations 0"]
|
||||
|
||||
|
||||
supported_versions = ["1.2.%d" % i for i in range(5)] + ["1.2"]
|
||||
convert = [[220, [change_header, change_listof, fix_oldfloatinset,
|
||||
update_tabular, update_longtables, remove_pextra,
|
||||
remove_oldfloat, remove_figinset, remove_oldertinset,
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2002 Dekel Tsur <dekel@lyx.org>
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -17,6 +17,8 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.3"""
|
||||
|
||||
import string
|
||||
import re
|
||||
from parser_tools import find_token, find_end_of, get_value,\
|
||||
@ -33,8 +35,9 @@ def find_end_of_inset(lines, i):
|
||||
####################################################################
|
||||
|
||||
|
||||
def change_insetgraphics(file):
|
||||
lines = file.body
|
||||
def change_insetgraphics(document):
|
||||
" Change inset Graphics."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "\\begin_inset Graphics", i)
|
||||
@ -91,8 +94,9 @@ def change_insetgraphics(file):
|
||||
i = i+1
|
||||
|
||||
|
||||
def change_tabular(file):
|
||||
lines = file.body
|
||||
def change_tabular(document):
|
||||
" Change tabular."
|
||||
lines = document.body
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(lines, "<column", i)
|
||||
@ -103,6 +107,7 @@ def change_tabular(file):
|
||||
i = i+1
|
||||
|
||||
|
||||
supported_versions = ["1.3.%d" % i for i in range(8)] + ["1.3"]
|
||||
convert = [[221, [change_insetgraphics, change_tabular]]]
|
||||
revert = []
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
# This file is part of lyx2lyx
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2006 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2006 José Matos <jamatos@lyx.org>
|
||||
# Copyright (C) 2004-2006 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
@ -17,6 +17,8 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
""" Convert files to the file format generated by lyx 1.5"""
|
||||
|
||||
import re
|
||||
from parser_tools import find_token, find_token_exact, find_tokens, find_end_of, get_value
|
||||
from string import replace
|
||||
@ -26,6 +28,7 @@ from string import replace
|
||||
# Private helper functions
|
||||
|
||||
def find_end_of_inset(lines, i):
|
||||
" Find beginning of inset, where lines[i] is included."
|
||||
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
|
||||
|
||||
# End of helper functions
|
||||
@ -36,14 +39,15 @@ def find_end_of_inset(lines, i):
|
||||
# Notes: Framed/Shaded
|
||||
#
|
||||
|
||||
def revert_framed(file):
|
||||
def revert_framed(document):
|
||||
"Revert framed notes. "
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_tokens(file.body, ["\\begin_inset Note Framed", "\\begin_inset Note Shaded"], i)
|
||||
i = find_tokens(document.body, ["\\begin_inset Note Framed", "\\begin_inset Note Shaded"], i)
|
||||
|
||||
if i == -1:
|
||||
return
|
||||
file.body[i] = "\\begin_inset Note"
|
||||
document.body[i] = "\\begin_inset Note"
|
||||
i = i + 1
|
||||
|
||||
|
||||
@ -67,20 +71,21 @@ typewriter_fonts = {'default' : 'default', 'ae' : 'default',
|
||||
'newcent' : 'default', 'bookman' : 'default',
|
||||
'pslatex' : 'courier'}
|
||||
|
||||
def convert_font_settings(file):
|
||||
def convert_font_settings(document):
|
||||
" Convert font settings. "
|
||||
i = 0
|
||||
i = find_token_exact(file.header, "\\fontscheme", i)
|
||||
i = find_token_exact(document.header, "\\fontscheme", i)
|
||||
if i == -1:
|
||||
file.warning("Malformed LyX file: Missing `\\fontscheme'.")
|
||||
document.warning("Malformed LyX document: Missing `\\fontscheme'.")
|
||||
return
|
||||
font_scheme = get_value(file.header, "\\fontscheme", i, i + 1)
|
||||
font_scheme = get_value(document.header, "\\fontscheme", i, i + 1)
|
||||
if font_scheme == '':
|
||||
file.warning("Malformed LyX file: Empty `\\fontscheme'.")
|
||||
document.warning("Malformed LyX document: Empty `\\fontscheme'.")
|
||||
font_scheme = 'default'
|
||||
if not font_scheme in roman_fonts.keys():
|
||||
file.warning("Malformed LyX file: Unknown `\\fontscheme' `%s'." % font_scheme)
|
||||
document.warning("Malformed LyX document: Unknown `\\fontscheme' `%s'." % font_scheme)
|
||||
font_scheme = 'default'
|
||||
file.header[i:i+1] = ['\\font_roman %s' % roman_fonts[font_scheme],
|
||||
document.header[i:i+1] = ['\\font_roman %s' % roman_fonts[font_scheme],
|
||||
'\\font_sans %s' % sans_fonts[font_scheme],
|
||||
'\\font_typewriter %s' % typewriter_fonts[font_scheme],
|
||||
'\\font_default_family default',
|
||||
@ -90,124 +95,125 @@ def convert_font_settings(file):
|
||||
'\\font_tt_scale 100']
|
||||
|
||||
|
||||
def revert_font_settings(file):
|
||||
def revert_font_settings(document):
|
||||
" Revert font settings. "
|
||||
i = 0
|
||||
insert_line = -1
|
||||
fonts = {'roman' : 'default', 'sans' : 'default', 'typewriter' : 'default'}
|
||||
for family in 'roman', 'sans', 'typewriter':
|
||||
name = '\\font_%s' % family
|
||||
i = find_token_exact(file.header, name, i)
|
||||
i = find_token_exact(document.header, name, i)
|
||||
if i == -1:
|
||||
file.warning("Malformed LyX file: Missing `%s'." % name)
|
||||
document.warning("Malformed LyX document: Missing `%s'." % name)
|
||||
i = 0
|
||||
else:
|
||||
if (insert_line < 0):
|
||||
insert_line = i
|
||||
fonts[family] = get_value(file.header, name, i, i + 1)
|
||||
del file.header[i]
|
||||
i = find_token_exact(file.header, '\\font_default_family', i)
|
||||
fonts[family] = get_value(document.header, name, i, i + 1)
|
||||
del document.header[i]
|
||||
i = find_token_exact(document.header, '\\font_default_family', i)
|
||||
if i == -1:
|
||||
file.warning("Malformed LyX file: Missing `\\font_default_family'.")
|
||||
document.warning("Malformed LyX document: Missing `\\font_default_family'.")
|
||||
font_default_family = 'default'
|
||||
else:
|
||||
font_default_family = get_value(file.header, "\\font_default_family", i, i + 1)
|
||||
del file.header[i]
|
||||
i = find_token_exact(file.header, '\\font_sc', i)
|
||||
font_default_family = get_value(document.header, "\\font_default_family", i, i + 1)
|
||||
del document.header[i]
|
||||
i = find_token_exact(document.header, '\\font_sc', i)
|
||||
if i == -1:
|
||||
file.warning("Malformed LyX file: Missing `\\font_sc'.")
|
||||
document.warning("Malformed LyX document: Missing `\\font_sc'.")
|
||||
font_sc = 'false'
|
||||
else:
|
||||
font_sc = get_value(file.header, '\\font_sc', i, i + 1)
|
||||
del file.header[i]
|
||||
font_sc = get_value(document.header, '\\font_sc', i, i + 1)
|
||||
del document.header[i]
|
||||
if font_sc != 'false':
|
||||
file.warning("Conversion of '\\font_sc' not yet implemented.")
|
||||
i = find_token_exact(file.header, '\\font_osf', i)
|
||||
document.warning("Conversion of '\\font_sc' not yet implemented.")
|
||||
i = find_token_exact(document.header, '\\font_osf', i)
|
||||
if i == -1:
|
||||
file.warning("Malformed LyX file: Missing `\\font_osf'.")
|
||||
document.warning("Malformed LyX document: Missing `\\font_osf'.")
|
||||
font_osf = 'false'
|
||||
else:
|
||||
font_osf = get_value(file.header, '\\font_osf', i, i + 1)
|
||||
del file.header[i]
|
||||
i = find_token_exact(file.header, '\\font_sf_scale', i)
|
||||
font_osf = get_value(document.header, '\\font_osf', i, i + 1)
|
||||
del document.header[i]
|
||||
i = find_token_exact(document.header, '\\font_sf_scale', i)
|
||||
if i == -1:
|
||||
file.warning("Malformed LyX file: Missing `\\font_sf_scale'.")
|
||||
document.warning("Malformed LyX document: Missing `\\font_sf_scale'.")
|
||||
font_sf_scale = '100'
|
||||
else:
|
||||
font_sf_scale = get_value(file.header, '\\font_sf_scale', i, i + 1)
|
||||
del file.header[i]
|
||||
font_sf_scale = get_value(document.header, '\\font_sf_scale', i, i + 1)
|
||||
del document.header[i]
|
||||
if font_sf_scale != '100':
|
||||
file.warning("Conversion of '\\font_sf_scale' not yet implemented.")
|
||||
i = find_token_exact(file.header, '\\font_tt_scale', i)
|
||||
document.warning("Conversion of '\\font_sf_scale' not yet implemented.")
|
||||
i = find_token_exact(document.header, '\\font_tt_scale', i)
|
||||
if i == -1:
|
||||
file.warning("Malformed LyX file: Missing `\\font_tt_scale'.")
|
||||
document.warning("Malformed LyX document: Missing `\\font_tt_scale'.")
|
||||
font_tt_scale = '100'
|
||||
else:
|
||||
font_tt_scale = get_value(file.header, '\\font_tt_scale', i, i + 1)
|
||||
del file.header[i]
|
||||
font_tt_scale = get_value(document.header, '\\font_tt_scale', i, i + 1)
|
||||
del document.header[i]
|
||||
if font_tt_scale != '100':
|
||||
file.warning("Conversion of '\\font_tt_scale' not yet implemented.")
|
||||
document.warning("Conversion of '\\font_tt_scale' not yet implemented.")
|
||||
for font_scheme in roman_fonts.keys():
|
||||
if (roman_fonts[font_scheme] == fonts['roman'] and
|
||||
sans_fonts[font_scheme] == fonts['sans'] and
|
||||
typewriter_fonts[font_scheme] == fonts['typewriter']):
|
||||
file.header.insert(insert_line, '\\fontscheme %s' % font_scheme)
|
||||
document.header.insert(insert_line, '\\fontscheme %s' % font_scheme)
|
||||
if font_default_family != 'default':
|
||||
file.preamble.append('\\renewcommand{\\familydefault}{\\%s}' % font_default_family)
|
||||
document.preamble.append('\\renewcommand{\\familydefault}{\\%s}' % font_default_family)
|
||||
if font_osf == 'true':
|
||||
file.warning("Ignoring `\\font_osf = true'")
|
||||
document.warning("Ignoring `\\font_osf = true'")
|
||||
return
|
||||
font_scheme = 'default'
|
||||
file.header.insert(insert_line, '\\fontscheme %s' % font_scheme)
|
||||
document.header.insert(insert_line, '\\fontscheme %s' % font_scheme)
|
||||
if fonts['roman'] == 'cmr':
|
||||
file.preamble.append('\\renewcommand{\\rmdefault}{cmr}')
|
||||
document.preamble.append('\\renewcommand{\\rmdefault}{cmr}')
|
||||
if font_osf == 'true':
|
||||
file.preamble.append('\\usepackage{eco}')
|
||||
document.preamble.append('\\usepackage{eco}')
|
||||
font_osf = 'false'
|
||||
for font in 'lmodern', 'charter', 'utopia', 'beraserif', 'ccfonts', 'chancery':
|
||||
if fonts['roman'] == font:
|
||||
file.preamble.append('\\usepackage{%s}' % font)
|
||||
document.preamble.append('\\usepackage{%s}' % font)
|
||||
for font in 'cmss', 'lmss', 'cmbr':
|
||||
if fonts['sans'] == font:
|
||||
file.preamble.append('\\renewcommand{\\sfdefault}{%s}' % font)
|
||||
document.preamble.append('\\renewcommand{\\sfdefault}{%s}' % font)
|
||||
for font in 'berasans':
|
||||
if fonts['sans'] == font:
|
||||
file.preamble.append('\\usepackage{%s}' % font)
|
||||
document.preamble.append('\\usepackage{%s}' % font)
|
||||
for font in 'cmtt', 'lmtt', 'cmtl':
|
||||
if fonts['typewriter'] == font:
|
||||
file.preamble.append('\\renewcommand{\\ttdefault}{%s}' % font)
|
||||
document.preamble.append('\\renewcommand{\\ttdefault}{%s}' % font)
|
||||
for font in 'courier', 'beramono', 'luximono':
|
||||
if fonts['typewriter'] == font:
|
||||
file.preamble.append('\\usepackage{%s}' % font)
|
||||
document.preamble.append('\\usepackage{%s}' % font)
|
||||
if font_default_family != 'default':
|
||||
file.preamble.append('\\renewcommand{\\familydefault}{\\%s}' % font_default_family)
|
||||
document.preamble.append('\\renewcommand{\\familydefault}{\\%s}' % font_default_family)
|
||||
if font_osf == 'true':
|
||||
file.warning("Ignoring `\\font_osf = true'")
|
||||
document.warning("Ignoring `\\font_osf = true'")
|
||||
|
||||
|
||||
def revert_booktabs(file):
|
||||
# we just remove the booktabs flag, everything else will become a mess.
|
||||
def revert_booktabs(document):
|
||||
" We remove the booktabs flag or everything else will become a mess. "
|
||||
re_row = re.compile(r'^<row.*space="[^"]+".*>$')
|
||||
re_tspace = re.compile(r'\s+topspace="[^"]+"')
|
||||
re_bspace = re.compile(r'\s+bottomspace="[^"]+"')
|
||||
re_ispace = re.compile(r'\s+interlinespace="[^"]+"')
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(file.body, "\\begin_inset Tabular", i)
|
||||
i = find_token(document.body, "\\begin_inset Tabular", i)
|
||||
if i == -1:
|
||||
return
|
||||
j = find_end_of_inset(file.body, i + 1)
|
||||
j = find_end_of_inset(document.body, i + 1)
|
||||
if j == -1:
|
||||
file.warning("Malformed LyX file: Could not find end of tabular.")
|
||||
document.warning("Malformed LyX document: Could not find end of tabular.")
|
||||
continue
|
||||
for k in range(i, j):
|
||||
if re.search('^<features.* booktabs="true".*>$', file.body[k]):
|
||||
file.warning("Converting 'booktabs' table to normal table.")
|
||||
file.body[k] = replace(file.body[k], ' booktabs="true"', '')
|
||||
if re.search(re_row, file.body[k]):
|
||||
file.warning("Removing extra row space.")
|
||||
file.body[k] = re_tspace.sub('', file.body[k])
|
||||
file.body[k] = re_bspace.sub('', file.body[k])
|
||||
file.body[k] = re_ispace.sub('', file.body[k])
|
||||
if re.search('^<features.* booktabs="true".*>$', document.body[k]):
|
||||
document.warning("Converting 'booktabs' table to normal table.")
|
||||
document.body[k] = replace(document.body[k], ' booktabs="true"', '')
|
||||
if re.search(re_row, document.body[k]):
|
||||
document.warning("Removing extra row space.")
|
||||
document.body[k] = re_tspace.sub('', document.body[k])
|
||||
document.body[k] = re_bspace.sub('', document.body[k])
|
||||
document.body[k] = re_ispace.sub('', document.body[k])
|
||||
i = i + 1
|
||||
|
||||
|
||||
@ -215,6 +221,7 @@ def revert_booktabs(file):
|
||||
# Conversion hub
|
||||
#
|
||||
|
||||
supported_versions = ["1.5.0svn","1.5"]
|
||||
convert = [[246, []],
|
||||
[247, [convert_font_settings]],
|
||||
[248, []]]
|
||||
|
@ -1,6 +1,6 @@
|
||||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004 José Matos <jamatos@lyx.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
Loading…
Reference in New Issue
Block a user