X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Flyx2lyx%2Flyx_0_12.py;h=b742dd52723dc2ee72265d6d3b67b168b012bce9;hb=69ed8cb89abd291b19ca2a3423d1f368a0d67f71;hp=856b3155805de7afa59e154cc293615e2b8eab03;hpb=26c0f379c7c997b9158ebe6792e62c52e6e21db3;p=lyx.git diff --git a/lib/lyx2lyx/lyx_0_12.py b/lib/lyx2lyx/lyx_0_12.py index 856b315580..b742dd5272 100644 --- a/lib/lyx2lyx/lyx_0_12.py +++ b/lib/lyx2lyx/lyx_0_12.py @@ -14,7 +14,7 @@ # # 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. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """ Convert files to the file format generated by lyx 0.12""" @@ -26,7 +26,7 @@ def space_before_layout(document): " Remove empty line before \\layout. " lines = document.body i = 2 # skip first layout - while 1: + while True: i = find_token(lines, '\\layout', i) if i == -1: break @@ -41,7 +41,7 @@ def formula_inset_space_eat(document): " Remove space after inset formula." lines = document.body i = 0 - while 1: + while True: i = find_token(lines, "\\begin_inset Formula", i) if i == -1: break @@ -56,7 +56,7 @@ def update_tabular(document): lines = document.body lyxtable_re = re.compile(r".*\\LyXTable$") i = 0 - while 1: + while True: i = find_re(lines, lyxtable_re, i) if i == -1: break @@ -108,7 +108,7 @@ def update_inset_label(document): " Update inset Label." lines = document.body i = 0 - while 1: + while True: i = find_token(lines, '\\begin_inset Label', i) if i == -1: return @@ -120,7 +120,7 @@ def update_latexdel(document): " Update inset LatexDel." lines = document.body i = 0 - while 1: + while True: i = find_token(lines, '\\begin_inset LatexDel', i) if i == -1: return @@ -163,7 +163,7 @@ def remove_cursor(document): lines = document.body i = 0 cursor_re = re.compile(r'.*(\\cursor \d*)') - while 1: + while True: i = find_re(lines, cursor_re, i) if i == -1: break @@ -176,7 +176,7 @@ def remove_empty_insets(document): " Remove empty insets." lines = document.body i = 0 - while 1: + while True: i = find_token(lines, '\\begin_inset ', i) if i == -1: break @@ -190,7 +190,7 @@ def remove_formula_latex(document): " Remove formula latex." lines = document.body i = 0 - while 1: + while True: i = find_token(lines, '\\latex formula_latex ', i) if i == -1: break @@ -268,7 +268,7 @@ def update_latexaccents(document): " Update latex accent insets." body = document.body i = 1 - while 1: + while True: i = find_token(body, '\\i ', i) if i == -1: return @@ -297,7 +297,7 @@ def obsolete_latex_title(document): " Replace layout Latex_Title with Title." body = document.body i = 0 - while 1: + while True: i = find_token(body, '\\layout', i) if i == -1: return @@ -308,6 +308,24 @@ def obsolete_latex_title(document): i = i + 1 +def remove_inset_latex(document): + "Replace inset latex with layout LaTeX" + body = document.body + + i = 0 + while True: + i = find_token(body, '\\begin_inset Latex', i) + if i == -1: + return + + body[i] = body[i].replace('\\begin_inset Latex', '\\layout LaTeX') + i = find_token(body, '\\end_inset', i) + if i == -1: + #this should not happen + return + del body[i] + + 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, @@ -315,7 +333,7 @@ convert = [[215, [header_update, add_end_document, remove_cursor, formula_inset_space_eat, update_tabular, update_vfill, remove_empty_insets, remove_formula_latex, update_latexaccents, - obsolete_latex_title]]] + obsolete_latex_title, remove_inset_latex]]] revert = []