I'm trying to write a word counter for LyX files.
Life is almost very simple as most lines that need to be ignored begin with a \
(I'm prepared to make the assumption that no textual lines begin with backslashes) - however there are some lines that look like real text that aren't, but they are enclosed by \begin_inset
and \end_inset
:
I'm genuine text.
\begin_inset something
I'm not real text
Perhaps there will be more than one line! Or none at all! Who knows.
\end_inset
/begin_layout
I also need to be counted, and thus not removed
/end_layout
Is there a quick way in ruby to strip the (smallest amount of) text between two markers? I'm imagining Regular Expressions are the way forward, but I can't figure out what they'd have to be.
Thanks in advance