- return ""
- return string.split(lines[i])[1]
-
-# Finds the paragraph that contains line i.
-import sys
-def get_paragraph(lines, i):
- while 1:
- i = find_tokens_backwards(lines, ["\\end_inset", "\\layout"], i)
- if check_token(lines[i], "\\layout"):
- return i
- count = 1
- while count > 0:
- i = find_tokens_backwards(lines, ["\\end_inset", "\\begin_inset"], i-1)
- if check_token(lines[i], "\\end_inset"):
- count = count+1
- else:
- count = count-1
-
-# Finds the matching \end_inset
-def find_end_of_inset(lines, i):
+ return default
+ if len(lines[i].split()) > 1:
+ return lines[i].split()[1]
+ else:
+ return default
+
+
+def get_value_string(lines, token, start, end = 0, trim = False, default = ""):
+ """ get_value_string(lines, token, start[[, end], trim, default]) -> string
+
+ Return tokens after token as string, in lines, where
+ token is the first element. When trim is used, the first and last character
+ of the string is trimmed."""
+
+ i = find_token_exact(lines, token, start, end)
+ if i == -1:
+ return default
+ if len(lines[i].split()) > 1:
+ for k in range (0, len(lines[i])):
+ if lines[i][k] == ' ':
+ if trim ==False:
+ return lines[i][k+1:len(lines[i])]
+ else:
+ return lines[i][k+2:len(lines[i])-1]
+ else:
+ return default
+
+
+def del_token(lines, token, start, end):
+ """ del_token(lines, token, start, end) -> int
+
+ Find the lower line in lines where token is the first element and
+ delete that line.
+
+ Returns the number of lines remaining."""
+
+ k = find_token_exact(lines, token, start, end)
+ if k == -1:
+ return end
+ else:
+ del lines[k]
+ return end - 1
+
+
+def find_beginning_of(lines, i, start_token, end_token):