José, reLyX doesn't know about these tokens. Should I therefore ignore them? Or should I do as you do and remove the line?
def remove_cursor(lines): i = find_token(lines, '\\cursor', 0) if i != -1: del lines[i] def remove_vcid(lines): i = find_token(lines, '\\lyxvcid', 0) if i != -1: del lines[i] i = find_token(lines, '\\lyxrcsid', 0) if i != -1: del lines[i] This is the last outstanding issue: def update_toc(lines): i = 0 while 1: i = find_token(lines, '\\begin_inset LatexCommand \\tableofcontents', i) if i == -1: break lines[i] = lines[i] + '{}' i = i + 1 Ok, this affects reLyX. It happily outputs: \\begin_inset LatexCommand \\tableofcontents$ Here's the code. Shall I simply append a '{}' after $name for all of them? # Things that LyX translates as "LatexCommand"s # E.g., \ref{foo} ->'\begin_inset LatexCommand \ref{foo}\n\n\end_inset \n' # (Some take arguments, others don't) my @LatexCommands = map {"\\$_"} qw(ref pageref label cite bibliography index printindex tableofcontents listofalgorithms listoftables listoffigures); # Handle tokens that LyX translates as a "LatexCommand" inset } elsif (grep {$_ eq $name} @LatexCommands) { &CheckForNewParagraph; #Start new paragraph if necessary print OUTFILE "$pre_space\n\\begin_inset LatexCommand ", $name, "\n\n\\end_inset \n\n"; -- Angus