mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
lyx_0_08.py:
lyx_0_10.py LyX.py: add support for UserGuide convertion from lyx-0.8 (and 0.7). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14532 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
958eead216
commit
088bcef87b
@ -48,7 +48,8 @@ original_version = re.compile(r"\#LyX (\S*)")
|
|||||||
##
|
##
|
||||||
# file format information:
|
# file format information:
|
||||||
# file, supported formats, stable release versions
|
# file, supported formats, stable release versions
|
||||||
format_relation = [("0_10", [210], ["0.10.7","0.10"]),
|
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_12", [215], ["0.12","0.12.1","0.12"]),
|
||||||
("1_0_0", [215], ["1.0.0","1.0"]),
|
("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_0_1", [215], ["1.0.1","1.0.2","1.0.3","1.0.4", "1.1.2","1.1"]),
|
||||||
|
27
lib/lyx2lyx/lyx_0_08.py
Normal file
27
lib/lyx2lyx/lyx_0_08.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# This file is part of lyx2lyx
|
||||||
|
# -*- 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
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# 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 = [[210, []]]
|
||||||
|
revert = []
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
pass
|
||||||
|
|
@ -18,7 +18,102 @@
|
|||||||
|
|
||||||
""" Convert files generated by lyx 0.10"""
|
""" Convert files generated by lyx 0.10"""
|
||||||
|
|
||||||
convert = [[210, []]]
|
def regularise_header(document):
|
||||||
|
" Place tokens in their separate line. "
|
||||||
|
i = 0
|
||||||
|
while i < len(document.header):
|
||||||
|
line = document.header[i]
|
||||||
|
if len(line.split('\\')) > 1:
|
||||||
|
tmp = [ '\\'+ token.strip() for token in line.split('\\')][1:]
|
||||||
|
document.header[i: i+1] = tmp
|
||||||
|
i += len(tmp)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
|
def find_next_space(line, j):
|
||||||
|
""" Return position of next space, starting from position k, if
|
||||||
|
not existing return last position in line."""
|
||||||
|
l = line.find(' ', j)
|
||||||
|
if l == -1:
|
||||||
|
l = len(line)
|
||||||
|
k = line.find('\\', j)
|
||||||
|
if k == -1:
|
||||||
|
k = len(line)
|
||||||
|
|
||||||
|
if k < l:
|
||||||
|
return k
|
||||||
|
return l
|
||||||
|
|
||||||
|
|
||||||
|
def regularise_body(document):
|
||||||
|
i = 0
|
||||||
|
while i < len(document.body):
|
||||||
|
line = document.body[i]
|
||||||
|
j = 0
|
||||||
|
tmp = []
|
||||||
|
while j < len(line):
|
||||||
|
k = line.find('\\', j)
|
||||||
|
|
||||||
|
if k == -1:
|
||||||
|
tmp += [line[j:]]
|
||||||
|
break
|
||||||
|
|
||||||
|
if k != j:
|
||||||
|
tmp += [line[j: k]]
|
||||||
|
j = k
|
||||||
|
|
||||||
|
k = find_next_space(line, j+1)
|
||||||
|
|
||||||
|
# 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"]:
|
||||||
|
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"]:
|
||||||
|
tmp += [line[j:k]]
|
||||||
|
j = k
|
||||||
|
continue
|
||||||
|
|
||||||
|
# These tokens take one argument
|
||||||
|
if token in ["bar", "begin_float", "family", "latex", "shape", "size", "series", "cursor"]:
|
||||||
|
k = find_next_space(line, k + 1)
|
||||||
|
tmp += [line[j:k]]
|
||||||
|
j = k
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Special treatment for insets
|
||||||
|
if token in ["begin_inset"]:
|
||||||
|
l = find_next_space(line, k + 1)
|
||||||
|
inset = line[k+1: l]
|
||||||
|
|
||||||
|
if inset == "Latex":
|
||||||
|
tmp += [line[j:l]]
|
||||||
|
j = l
|
||||||
|
continue
|
||||||
|
|
||||||
|
if inset in ["LatexCommand", "LatexDel"]:
|
||||||
|
tmp += [line[j:]]
|
||||||
|
break
|
||||||
|
|
||||||
|
if inset == "Quotes":
|
||||||
|
l = find_next_space(line, l + 1)
|
||||||
|
tmp += [line[j:l]]
|
||||||
|
j = l
|
||||||
|
continue
|
||||||
|
|
||||||
|
assert(False)
|
||||||
|
|
||||||
|
# We are inside a latex inset, pass the text verbatim
|
||||||
|
tmp += [line[j:]]
|
||||||
|
break
|
||||||
|
|
||||||
|
document.body[i: i+1] = tmp
|
||||||
|
i += len(tmp)
|
||||||
|
|
||||||
|
|
||||||
|
convert = [[210, [regularise_header, regularise_body]]]
|
||||||
revert = []
|
revert = []
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user