Move generally useful parser routines to parser_tools.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36065 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-11-04 15:44:32 +00:00
parent 5d0a284ea9
commit 5e4493d97b
2 changed files with 12 additions and 11 deletions

View File

@ -23,7 +23,8 @@ import re, string
import unicodedata
import sys, os
from parser_tools import find_token, find_end_of, find_tokens, get_value, get_value_string
from parser_tools import find_token, find_end_of, find_tokens, \
find_end_of_inset, find_end_of_layout, get_value, get_value_string
####################################################################
# Private helper functions
@ -38,16 +39,6 @@ def remove_option(document, m, option):
return True
def find_end_of_inset(lines, i):
" Find end of inset, where lines[i] is included."
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
def find_end_of_layout(lines, i):
" Find end of layout, where lines[i] is included."
return find_end_of(lines, i, "\\begin_layout", "\\end_layout")
# Note that text can be either a list of lines or a single line.
def add_to_preamble(document, text):
""" Add text to the preamble if it is not already there.

View File

@ -231,3 +231,13 @@ def find_nonempty_line(lines, start, end = 0):
if is_nonempty_line(lines[i]):
return i
return -1
def find_end_of_inset(lines, i):
" Find end of inset, where lines[i] is included."
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
def find_end_of_layout(lines, i):
" Find end of layout, where lines[i] is included."
return find_end_of(lines, i, "\\begin_layout", "\\end_layout")