]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_1_6.py
booktabs: support for \cmidrule trimming
[lyx.git] / lib / lyx2lyx / lyx_1_6.py
index f8409a0c7b3a0258d653040f2393000ef3dd236d..c022b875aace420de486f41791ee2e74988c797e 100644 (file)
@@ -23,12 +23,7 @@ import unicodedata
 import sys, os
 
 from parser_tools import find_token, find_end_of, find_tokens, get_value
-
-# Provide support for both python 2 and 3
-PY2 = sys.version_info[0] == 2
-if not PY2:
-    unichr = chr
-# End of code to support for both python 2 and 3
+from unicode_symbols import unicode_reps
 
 ####################################################################
 # Private helper functions
@@ -151,45 +146,6 @@ def set_option(document, m, option, value):
     return l
 
 
-# FIXME: Use the version in unicode_symbols.py which has some bug fixes
-def read_unicodesymbols():
-    " Read the unicodesymbols list of unicode characters and corresponding commands."
-    pathname = os.path.abspath(os.path.dirname(sys.argv[0]))
-    fp = open(os.path.join(pathname.strip('lyx2lyx'), 'unicodesymbols'))
-    spec_chars = []
-    # Two backslashes, followed by some non-word character, and then a character
-    # in brackets. The idea is to check for constructs like: \"{u}, which is how
-    # they are written in the unicodesymbols file; but they can also be written
-    # as: \"u or even \" u.
-    r = re.compile(r'\\\\(\W)\{(\w)\}')
-    for line in fp.readlines():
-        if line[0] != '#' and line.strip() != "":
-            line=line.replace(' "',' ') # remove all quotation marks with spaces before
-            line=line.replace('" ',' ') # remove all quotation marks with spaces after
-            line=line.replace(r'\"','"') # replace \" by " (for characters with diaeresis)
-            try:
-                [ucs4,command,dead] = line.split(None,2)
-                if command[0:1] != "\\":
-                    continue
-                spec_chars.append([command, unichr(eval(ucs4))])
-            except:
-                continue
-            m = r.match(command)
-            if m != None:
-                command = "\\\\"
-                # If the character is a double-quote, then we need to escape it, too,
-                # since it is done that way in the LyX file.
-                if m.group(1) == "\"":
-                    command += "\\"
-                commandbl = command
-                command += m.group(1) + m.group(2)
-                commandbl += m.group(1) + ' ' + m.group(2)
-                spec_chars.append([command, unichr(eval(ucs4))])
-                spec_chars.append([commandbl, unichr(eval(ucs4))])
-    fp.close()
-    return spec_chars
-
-
 def extract_argument(line):
     'Extracts a LaTeX argument from the start of line. Returns (arg, rest).'
 
@@ -276,8 +232,6 @@ def latex2ert(line, isindex):
     return retval
 
 
-unicode_reps = read_unicodesymbols()
-
 #Bug 5022....
 #Might should do latex2ert first, then deal with stuff that DOESN'T
 #end up inside ERT. That routine could be modified so that it returned
@@ -430,7 +384,7 @@ def lyx2latex(document, lines):
             continue
         inert = ert_end >= curline
         content += lyxline2latex(document, lines[curline], inert)
-      
+
     return content
 
 
@@ -1109,7 +1063,7 @@ def revert_wrapfig_options(document):
 
 
 def convert_latexcommand_index(document):
-    "Convert from LatexCommand form to collapsable form."
+    "Convert from LatexCommand form to collapsible form."
     i = 0
     r1 = re.compile('name "(.*)"')
     while True:
@@ -1141,7 +1095,7 @@ def convert_latexcommand_index(document):
 
 
 def revert_latexcommand_index(document):
-    "Revert from collapsable form to LatexCommand form."
+    "Revert from collapsible form to LatexCommand form."
     i = 0
     while True:
         i = find_token(document.body, "\\begin_inset Index", i)