I came up with a quite nice solution I created based on these two questions on file IO:
Here is the code to put before \begin{document}
:
% create a new file handle
\newwrite\pdfpcnotesfile
% open file on \begin{document}
\AtBeginDocument{%
\immediate\openout\pdfpcnotesfile\jobname.pdfpc\relax
\immediate\write\pdfpcnotesfile{[notes]}
}
% define a # https://tex.stackexchange.com/a/37757/10327
\begingroup
\catcode`\#=12
\gdef\hashchar{#}%
\endgroup
% define command \pnote{} that works exactly like \note but
% additionally writes notes to file in pdfpc readable format
\newcommand{\pnote}[1]{%
% keep normal notes working
\note{#1}%
% write notes to file
\begingroup
\let\#\hashchar
\immediate\write\pdfpcnotesfile{\#\#\# \theframenumber}%
\immediate\write\pdfpcnotesfile{\unexpanded{#1}}%
\endgroup
}
% close file on \end{document}
\AtEndDocument{%
\immediate\closeout\pdfpcnotesfile
}
You can then use the \pnote{}
command like you used \note{}
before.
The behavior will be the same but it will additionally write notes to file in pdfpc readable format.
There are a few thing not yet working:
It does not preserve newlines, so everything in a \pnote
will end up in one line of the output file.
To replace newlines and pars you may use the following commands:
sed -i "s/\\\\\\\\/\n/g" slides.pdfpc
sed -i "s/\\\\par/\n\n/g" slides.pdfpc
Multiple \pnote{}
commands per frame are not working right now.
Grep
(Linux/Windows) can probably handle this with ease.grep
because grep uses regular expressions who are not able to deal with nested brackets like this:\note{\begin{itemize}\item ...\end{itemize}}
you would need a parser to remember the state of nesting while reading the input. Thats why I thought there maybe is a latex way as latex is already parsing this an may be able to just ouput the note content to a file.\\note\{(?:[^}]*?(\{[^}]*?(\{[^}]*?\})?\})?)+\}
--notes
option.