Is ist possible to make a (Perl or whatever running on Mac OS X) script that converts
\section{long text}
\sectionmark{short text}
to
\section[long text]{long text\sectionmark{short text}}
or alternative to
\section{long text}[short text]
I can’t ensure that there are no line breaks in the long text or if there is a break between \section and \sectionmark.
This question is related with a problem discussed here an TeX.SX.
Will do it for you if there are no line breaks in
long textand there is no empty line between\sectionand\sectionmark. If you have any of those, you can still modify it.So to answer your question: yes it is possible.
UPDATE
Here is a working solution, with
awk:Note: it does not handle if anything appears between
long text}and\sectionmarke.g.:You can see it in ACTION HERE!
If you want to get rid of then new lines in
long textjust replace every"\n"with a" "in the script.