X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Flyx2lyx%2Flyx_2_2.py;h=37a26be592b04ab9e8a08a01efc7246c0bbd4ead;hb=d4ca8d74041094f623cc891a30b4dc537137431c;hp=04c32ce7aa6d6d2b813445b5b5640a4de0c0e53c;hpb=b509e072e89e43a4efcefaca079d545c4da2f66c;p=features.git diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py index 04c32ce7aa..37a26be592 100644 --- a/lib/lyx2lyx/lyx_2_2.py +++ b/lib/lyx2lyx/lyx_2_2.py @@ -334,6 +334,46 @@ def revert_separator(document): i = i + 1 +def convert_parbreak(document): + """ + Convert parbreak separators not specifically used to separate + environments to latexpar separators. + """ + parbreakinset = "\\begin_inset Separator parbreak" + i = 0 + while 1: + i = find_token(document.body, parbreakinset, i) + if i == -1: + return + lay = get_containing_layout(document.body, i) + if lay == False: + document.warning("Malformed LyX document: Can't convert separator inset at line " + str(i)) + i += 1 + continue + if lay[0] == "Standard": + # Convert only if not alone in the paragraph + k1 = find_nonempty_line(document.body, lay[1] + 1, i + 1) + k2 = find_nonempty_line(document.body, i + 1, lay[2]) + if (k1 < i) or (k2 > i + 1) or not check_token(document.body[i], parbreakinset): + document.body[i] = document.body[i].replace("parbreak", "latexpar") + else: + document.body[i] = document.body[i].replace("parbreak", "latexpar") + i += 1 + + +def revert_parbreak(document): + """ + Revert latexpar separators to parbreak separators. + """ + i = 0 + while 1: + i = find_token(document.body, "\\begin_inset Separator latexpar", i) + if i == -1: + return + document.body[i] = document.body[i].replace("latexpar", "parbreak") + i += 1 + + def revert_smash(document): " Set amsmath to on if smash commands are used " @@ -2284,10 +2324,12 @@ convert = [ [504, [convert_save_props]], [505, []], [506, [convert_info_tabular_feature]], - [507, [convert_longtable_label]] + [507, [convert_longtable_label]], + [508, [convert_parbreak]] ] revert = [ + [507, [revert_parbreak]], [506, [revert_longtable_label]], [505, [revert_info_tabular_feature]], [504, []],