From ff66614d1ac67fcfeec297f19d451b997cda5828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Sun, 27 Jul 2003 12:08:53 +0000 Subject: [PATCH] remove layout Comment, fix bug 1280 critical for 1.4 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7380 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 4 ++ lib/layouts/db_lyxmacros.inc | 8 +--- lib/layouts/heb-article.layout | 4 -- lib/layouts/lyxmacros.inc | 31 ---------------- lib/layouts/obsolete.inc | 4 ++ lib/layouts/scrlttr2.layout | 31 +--------------- lib/lyx2lyx/lyxconvert_223.py | 68 +++++++++++++++++++++++++++++++++- 7 files changed, 78 insertions(+), 72 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 6ffe3c5fbf..d7c26e5620 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2003-07-27 José Matos + + * lyx2lyx/lyxconvert_223.py (convert_comment): remove layout Comment. + 2003-07-27 Lars Gullik Bjønnes * reLyX/configure.ac: new file diff --git a/lib/layouts/db_lyxmacros.inc b/lib/layouts/db_lyxmacros.inc index 6b508cc50b..0adb39830e 100644 --- a/lib/layouts/db_lyxmacros.inc +++ b/lib/layouts/db_lyxmacros.inc @@ -16,12 +16,6 @@ Style Code PassThru 1 End -# Comment style definition -Style Comment - LatexType Paragraph - LatexName remark -End - Style LyX-Code ObsoletedBy Code End @@ -30,4 +24,4 @@ NoStyle LyX-Code NoStyle Address -NoStyle Right_Address \ No newline at end of file +NoStyle Right_Address diff --git a/lib/layouts/heb-article.layout b/lib/layouts/heb-article.layout index 98b450b8ee..1feabb6d0b 100644 --- a/lib/layouts/heb-article.layout +++ b/lib/layouts/heb-article.layout @@ -13,10 +13,6 @@ Preamble \AtBeginDocument{\make@lr\thetheorem} EndPreamble -Style Comment - LabelString ":äøòä" -End - Style Abstract LabelString "øéö÷ú" End diff --git a/lib/layouts/lyxmacros.inc b/lib/layouts/lyxmacros.inc index cec4d1e4bf..078120e811 100644 --- a/lib/layouts/lyxmacros.inc +++ b/lib/layouts/lyxmacros.inc @@ -43,37 +43,6 @@ Style LyX-Code End -# Comment style definition -Style Comment - Margin Dynamic - LatexType Environment - LatexName comment - NextNoIndent 1 - LeftMargin MMM - RightMargin MMM - Align Block - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep :x - Labelstring "Comment:" - - LabelFont - Shape Italic - Series Bold - Color black - EndFont - - TextFont - Color magenta - Shape Italic - EndFont - - Preamble - \usepackage{verbatim} - EndPreamble - -End - # Address style definition Style Address Margin Static diff --git a/lib/layouts/obsolete.inc b/lib/layouts/obsolete.inc index 5957f416e6..403bf96393 100644 --- a/lib/layouts/obsolete.inc +++ b/lib/layouts/obsolete.inc @@ -14,3 +14,7 @@ End Style LaTeX ObsoletedBy Standard End + +Style Comment + ObsoletedBy Standard +End diff --git a/lib/layouts/scrlttr2.layout b/lib/layouts/scrlttr2.layout index b53f9fdad5..ca163a4e7c 100644 --- a/lib/layouts/scrlttr2.layout +++ b/lib/layouts/scrlttr2.layout @@ -341,33 +341,6 @@ Style Invoice LabelString "Invoice no.:" End -# Comment style definition -Style Comment - Margin Dynamic - LatexType Environment - LatexName comment - NextNoIndent 1 - LeftMargin MMM - RightMargin MMM - Align Block - AlignPossible Block, Left, Right, Center - LabelType Static - LabelSep :x - Labelstring "Comment:" +### Finally a few obsolete definitions for compatibility +Input obsolete.inc - LabelFont - Shape Italic - Series Bold - Color black - EndFont - - TextFont - Color magenta - Shape Italic - EndFont - - Preamble - \usepackage{verbatim} - EndPreamble - -End diff --git a/lib/lyx2lyx/lyxconvert_223.py b/lib/lyx2lyx/lyxconvert_223.py index 9cbbcc625a..8a875b5076 100644 --- a/lib/lyx2lyx/lyxconvert_223.py +++ b/lib/lyx2lyx/lyxconvert_223.py @@ -17,7 +17,7 @@ import string import re -from parser_tools import find_token +from parser_tools import find_token, find_end_of def convert_external(lines): external_rexp = re.compile(r'\\begin_inset External ([^,]*),"([^"]*)",') @@ -53,8 +53,74 @@ def convert_external(lines): lines[i:i+1] = [top, template] i = i + 1 + +def convert_comment(lines): + i = 0 + comment = "\\layout Comment" + while 1: + i = find_token(lines, comment, i) + if i == -1: + return + + lines[i:i+1] = ["\\layout Standard","","", + "\\begin_inset Comment", + "collapsed true","", + "\\layout Standard"] + i = i + 7 + + while 1: + old_i = i + i = find_token(lines, "\\layout", i) + if i == -1: + i = len(lines) - 1 + lines[i:i] = ["\\end_inset ","",""] + return + + j = find_token(lines, '\\begin_deeper', old_i, i) + if j == -1: j = i + 1 + k = find_token(lines, '\\begin_inset', old_i, i) + if k == -1: k = i + 1 + + if j < i and j < k: + i = j + del lines[i] + i = find_end_of( lines, i, "\\begin_deeper","\\end_deeper") + if i == -1: + #This case should not happen + #but if this happens deal with it greacefully adding + #the missing \end_deeper. + i = len(lines) - 1 + lines[i:i] = ["\end_deeper","","","\\end_inset ","",""] + return + else: + del lines[i] + continue + + if k < i: + i = k + i = find_end_of( lines, i, "\\begin_inset","\\end_inset") + if i == -1: + #This case should not happen + #but if this happens deal with it greacefully adding + #the missing \end_inset. + i = len(lines) - 1 + lines[i:i] = ["\\end_inset ","","","\\end_inset ","",""] + return + else: + i = i + 1 + continue + + if string.find(lines[i], comment) == -1: + lines[i:i] = ["\\end_inset"] + i = i + 1 + break + lines[i:i+1] = ["\\layout Standard"] + i = i + 1 + + def convert(header, body): convert_external(body) + convert_comment(body) if __name__ == "__main__": pass