X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Flyx2lyx%2Flyx_1_6.py;h=7a3710e47e46f1f3e9be95d77afc47a90ec424b7;hb=c52808ce1a804a875514713eb6f5dcd6f05dd6c8;hp=071280836b670f61213117e800e25e9764eedaaa;hpb=648ddd25eca045f34569405aca15c5d638bbb723;p=features.git diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 071280836b..7a3710e47e 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -23,7 +23,7 @@ import unicodedata import sys, os from parser_tools import find_token, find_end_of, find_tokens, get_value -from unicode_symbols import read_unicodesymbols +from unicode_symbols import unicode_reps #################################################################### # Private helper functions @@ -146,61 +146,13 @@ def set_option(document, m, option, value): return l -# FIXME: Remove this function if the version imported from unicode_symbols works. -# This function was the predecessor from that function, that in the meanwhile got -# new fixes. -def read_unicodesymbols2(): - " Read the unicodesymbols list of unicode characters and corresponding commands." - - # 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 - - 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).' if not line: return (None, "") - bracere = re.compile("(\s*)(.*)") + bracere = re.compile(r"(\s*)(.*)") n = bracere.match(line) whitespace = n.group(1) stuff = n.group(2) @@ -280,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 @@ -327,7 +277,7 @@ def latex2lyx(data, isindex): data = data.replace('\\\\', '\\') # Math: - mathre = re.compile('^(.*?)(\$.*?\$)(.*)') + mathre = re.compile(r'^(.*?)(\$.*?\$)(.*)') lines = data.split('\n') for line in lines: #document.warning("LINE: " + line) @@ -996,7 +946,7 @@ def remove_inzip_options(document): def convert_inset_command(document): - """ + r""" Convert: \begin_inset LatexCommand cmd to @@ -1033,7 +983,7 @@ def convert_inset_command(document): def revert_inset_command(document): - """ + r""" Convert: \begin_inset CommandInset InsetType LatexCommand cmd @@ -1608,7 +1558,7 @@ def convert_usorbian(document): def convert_macro_global(document): - "Remove TeX code command \global when it is in front of a macro" + r"Remove TeX code command \global when it is in front of a macro" # math macros are nowadays already defined \global, so that an additional # \global would make the document uncompilable, see # http://www.lyx.org/trac/ticket/5371 @@ -2389,7 +2339,7 @@ def revert_wrapplacement(document): def remove_extra_embedded_files(document): - " Remove \extra_embedded_files from buffer params " + r" Remove \extra_embedded_files from buffer params " i = find_token(document.header, '\\extra_embedded_files', 0) if i == -1: return