- if prop == "color":
- aux.append("\\%s %s" % (prop, prop_value[prop]))
- elif prop == "family":
- if prop_value[prop] != "roman":
- aux.append("\\%s %s " % (prop, prop_value[prop]))
- else:
- aux.append("\\%s %s " % (prop, prop_value[prop]))
-
-
- return lines[:start] + aux[:] + lines[end:]
+ if prop_dict[prop] != 'default':
+ insert = 1
+ if prop == "color":
+ aux.append("\\%s %s" % (prop, prop_dict[prop]))
+ elif prop != "family" or prop_dict[prop] != "roman":
+ aux.append("\\%s %s " % (prop, prop_dict[prop]))
+
+ # remove final char properties
+ n = len(lines)
+ while n:
+ n = n - 1
+ if not lines[n]:
+ del lines[n]
+ continue
+
+ if lines[n][:1] == '\\':
+ result = prop_exp.match(lines[n])
+ prop = result.group(1)
+ if prop in properties:
+ prop_dict[prop] = result.group(2)
+ del lines[n]
+ continue
+
+ if check_token(lines[n],'\\end_inset'):
+ # ensure proper newlines after inset end
+ lines.append('')
+ lines.append('')
+ break
+
+ #debug_list('*' * 10 + ' begin ' + '*' * 10, lines[start:])
+ if not lines[start:] and not lines[end:]:
+ return []
+
+ result = lines[:start] + aux[:] + lines[end:]
+ if insert and result[0] != '':
+ return [''] + result[:]
+
+ return result[:]
+
+def debug_list(title, list):
+ sys.stderr.write(title+'\n')
+ for line in list:
+ sys.stderr.write(line+'\n')
+
+def update_language(header):
+ i = find_token(header, "\\language", 0)
+ if i == -1:
+ # no language, should emit a warning
+ header.append('\\language english')
+ return
+ # FIXME: find the document default language in user preferences
+ header[i] = '\\language english'
+ return