I'm looking for a way to compile only what's inside a given command (or an environment). I'm doing a PhD and this way, I'll be able to have a full document with some poorly written sections, for myself, and a version with only the proper sections, for my advisor.
In the beginning, I started with
\newcommand{\blank}[1]{}
but it would be far more practical to specify what's fine rather than the opposite.
I had two ideas.
The first one was:
\documentclass{article}
\long\def\blank#1\endblank{}
\long\def\keep#1{\endblank#1\blank}
\begin{document}
\blank
XXX
\keep{AAA}
XXX
\endblank
\end{document}
But it seems that LaTex don't expand \keep when it looks for \endblank and eventually everything is avoided and there is nothing to print.
The second idea I had was:
\documentclass{article}
\long\def\blank#1\keep{\next}
\long\def\next#1{
\def\foo{#1}
\ifx\foo\empty\else
#1\blank
\fi
}
\begin{document}
\blank
XXX
\keep{AAA}
XXX
\keep{}
\end{document}
This one seems to work, but because \keep is supposed to work with pretty big chunks of text, I'm afraid I have done something really wrong.
So my questions are:
Is there a way to make the first idea work and ask LaTeX to expand some commands to look for the delimiters?
Is the second solution "stable" and proper to use in large files?
Is there a better/proper way to do that or is it something I'll have to do with some external preprocessing?
A bonus question: Is there a simple way I can make the second idea work with an environment
\begin{keep}?
After writing this, I notice I should maybe have divided this question in two parts, sorry for that... Please, tell me if I should do it!
\inputand to comment out for your advisor all the drafts. – Keks Dose Aug 26 '18 at 16:38