]> git.lyx.org Git - features.git/commitdiff
support for verbatim: step 1: the layout and the lyx2lyx code,;fileformat change...
authorUwe Stöhr <uwestoehr@web.de>
Mon, 20 Feb 2012 02:10:33 +0000 (02:10 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Mon, 20 Feb 2012 02:10:33 +0000 (02:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40784 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/layouts/stdlayouts.inc
lib/lyx2lyx/lyx_2_1.py
src/version.h

index f08041d925a198e229cd5b73709429392856a36c..2e685f4b3f6d74f52cf0ecd5976fb4bf94defe41 100644 (file)
@@ -11,6 +11,15 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
 
 -----------------------
 
+2012-02-20 Uwe Stöhr <uwestoehr@web.de>
+       * Format incremented to 426 (r40784)
+         support for the verbatim environment
+         (added only a layout)
+
+2012-01-23 Uwe Stöhr <uwestoehr@web.de>
+       * Format incremented to 425 (r40663)
+         support for the LaTeX-package cancel (fix bug 6819)
+
 2012-01-09 Julien Rioux <jrioux@lyx.org>
        * Format incremented to 424 (r40592)
          New buffer param \cite_engine_type to specify the type of
index a1a360ba58ccd8185875c48d6d41c17a7adf3d39..40742e586c40062458f68c2210282ec9fef57d7d 100644 (file)
@@ -71,6 +71,30 @@ Style Verse
 End
 
 
+Style Verbatim
+       Category                MainText
+       LatexType               Environment
+       LatexName               verbatim
+       NextNoIndent            1
+       ParbreakIsNewline       1
+       FreeSpacing             1
+       PassThru                1
+       NewLine                 0
+       ParSkip                 0.4
+       TopSep                  0.7
+       BottomSep               0.7
+       ParSep                  0.5
+       Align                   Block
+       AlignPossible           Block
+       LabelType               No_Label
+       Font
+         Family                Typewriter
+       EndFont
+       HTMLTag                 <pre></pre>
+       HTMLItem                p
+End
+
+
 Style --Separator--
        Category              MainText
        KeepEmpty             1
index 5cb4cb941696b29a96402bba4fb3c5a5624076cc..dc755f389d8feab6e2b158db5a398382f5eb46ff 100644 (file)
@@ -26,7 +26,8 @@ import sys, os
 # Uncomment only what you need to import, please.
 
 from parser_tools import del_token, find_token, find_end_of, find_end_of_inset, \
-    find_re, get_option_value, get_value, get_quoted_value, set_option_value
+    find_end_of_layout, find_re, get_option_value, get_value, get_quoted_value, \
+    set_option_value
 
 #from parser_tools import find_token, find_end_of, find_tokens, \
   #find_token_exact, find_end_of_inset, find_end_of_layout, \
@@ -471,6 +472,69 @@ def revert_cancel(document):
         i = j
 
 
+def revert_verbatim(document):
+    " Revert verbatim einvironments completely to TeX-code. "
+    i = 0
+    consecutive = False
+    subst_end = ['\end_layout', '', '\\begin_layout Plain Layout',
+                '\end_layout', '',
+                 '\\begin_layout Plain Layout', '', '',
+                 '\\backslash', '',
+                 'end{verbatim}',
+                 '\\end_layout', '', '\\end_inset',
+                 '', '', '\\end_layout']
+    subst_begin = ['\\begin_layout Standard', '\\noindent',
+                   '\\begin_inset ERT', 'status collapsed', '',
+                   '\\begin_layout Plain Layout', '', '', '\\backslash',
+                   'begin{verbatim}',
+                   '\\end_layout', '', '\\begin_layout Plain Layout', '']
+    while 1:
+        i = find_token(document.body, "\\begin_layout Verbatim", i)
+        if i == -1:
+            return
+        j = find_end_of_layout(document.body, i)
+        if j == -1:
+            document.warning("Malformed lyx document: Can't find end of Verbatim layout")
+            i += 1
+            continue
+        # delete all line breaks insets (there are no other insets)
+        l = i
+        while 1:
+            n = find_token(document.body, "\\begin_inset Newline newline", l)
+            if n == -1:
+                n = find_token(document.body, "\\begin_inset Newline linebreak", l)
+                if n == -1:
+                    break
+            m = find_end_of_inset(document.body, n)
+            del(document.body[m:m+1])
+            document.body[n:n+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
+            l += 1
+            j += 1
+        # consecutive verbatim environments need to be connected
+        k = find_token(document.body, "\\begin_layout Verbatim", j)
+        if k == j + 2 and consecutive == False:
+            consecutive = True
+            document.body[j:j+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
+            document.body[i:i+1] = subst_begin
+            continue
+        if k == j + 2 and consecutive == True:
+            document.body[j:j+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
+            del(document.body[i:i+1])
+            continue
+        if k != j + 2 and consecutive == True:
+            document.body[j:j+1] = subst_end
+            # the next paragraph must not be indented
+            document.body[j+19:j+19] = ['\\noindent']
+            del(document.body[i:i+1])
+            consecutive = False
+            continue
+        else:
+            document.body[j:j+1] = subst_end
+            # the next paragraph must not be indented
+            document.body[j+19:j+19] = ['\\noindent']
+            document.body[i:i+1] = subst_begin
+
+
 ##
 # Conversion hub
 #
@@ -488,10 +552,12 @@ convert = [
            [422, [convert_use_packages]],
            [423, [convert_use_mathtools]],
            [424, [convert_cite_engine_type]],
-           [425, []]
+           [425, []],
+           [426, []]
           ]
 
 revert =  [
+           [425, [revert_verbatim]],
            [424, [revert_cancel]],
            [423, [revert_cite_engine_type]],
            [422, [revert_use_mathtools]],
index 76741f8e017beddabef1cefffc372b730bd50d51..b9bc0da5d595340670af62944c2dec145527c3e5 100644 (file)
@@ -30,7 +30,7 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 425 // uwestoehr: support for the package cancel
+#define LYX_FORMAT_LYX 426 // uwestoehr: support for verbatim
 #define LYX_FORMAT_TEX2LYX 425 // uwestoehr: support for the package cancel
 
 #if LYX_FORMAT_FOR_TEX2LYX != LYX_FORMAT_FOR_LYX