11 years, 5 months ago
(2012-10-06 04:33:26 UTC)
#3
http://codereview.appspot.com/6584073/diff/1/python/book_latex.py
File python/book_latex.py (right):
http://codereview.appspot.com/6584073/diff/1/python/book_latex.py#newcode88
python/book_latex.py:88: \\iffalse.*\\fi))''',
On 2012/10/06 02:12:41, Julien Rioux wrote:
> .* should be replaced by the non-greedy .*?
Yes :-)
http://codereview.appspot.com/6584073/diff/1/python/book_latex.py#newcode88
python/book_latex.py:88: \\iffalse.*\\fi))''',
As David has commented on the list, I would prefer if you replaced the \iffalse
... \fi with a higher-level command, namely \begin{comment} ... \end{comment}
(from the `comment' package). First of all, this syntax suits LaTeX better
since it resembles normal environments. Second, it is a bad idea in general to
expose \ifXXX to the top level; in other words, users should never do that.
Reason is that \ifXXX is handled very special in TeX since you can define, say,
\ifFoo which also pairs with the next \fi, making correct balancing of nested
\ifXXX commands quite delicate and very hard to debug.
11 years, 5 months ago
(2012-10-06 12:05:42 UTC)
#4
On 2012-10-06 06:33, lemzwerg@googlemail.com wrote:
>
> http://codereview.appspot.com/6584073/diff/1/python/book_latex.py
> File python/book_latex.py (right):
>
> http://codereview.appspot.com/6584073/diff/1/python/book_latex.py#newcode88
> python/book_latex.py:88: \\iffalse.*\\fi))''',
> On 2012/10/06 02:12:41, Julien Rioux wrote:
>> .* should be replaced by the non-greedy .*?
>
> Yes :-)
Absolutely, was my mistake.
> http://codereview.appspot.com/6584073/diff/1/python/book_latex.py#newcode88
> python/book_latex.py:88: \\iffalse.*\\fi))''',
> As David has commented on the list, I would prefer if you replaced the
> \iffalse ... \fi with a higher-level command, namely \begin{comment} ...
> \end{comment} (from the `comment' package).
So, your opinion is that lilypond-book SHOULD process the \lilypond{...}
code inside the \iffalse section and spectacularly fail. If users are
using \iffalse -- I am for example one of those who use \iffalse to
quickly comment out some parts temporarily -- then lilypond-book would
still require everything between \iffalse and \fi to be in correct
lilypond syntax and will create snippet images for all those snippets:
\documentclass[a4paper, 12pt]{article}
\begin{document}
TODO
\iffalse
This is a template for my future snippets:
\lilypond{Code comes here}
\fi
\end{document}
Shall lilypond-book really fail for (and process) snippets that will NOT
be included by latex???
> First of all, this syntax
> suits LaTeX better since it resembles normal environments. Second, it
> is a bad idea in general to expose \ifXXX to the top level; in other
> words, users should never do that.
But fact is, people ARE using \iffalse to temporarily comment out larger
parts of latex files. With my colleagues, I have never seen
\begin{comment} for comments, all the researchers I have worked with so
far were using \iffalse.
Also, this is not about advocating what latex users should use, but
handling whare users are using currently. So, I will add \begin{comment}
to the pattern, too, but I still think that lilypond-book SHOULD ignore
everything inside \iffalse.
> Reason is that \ifXXX is handled
> very special in TeX since you can define, say, \ifFoo which also pairs
> with the next \fi, making correct balancing of nested \ifXXX commands
> quite delicate and very hard to debug.
Sure, it's not the perfect way, but it's the quick-and-dirty way.
I'm also aware that lilypond-book will not be able to handle nested
\ifXXX correctly. However, in the worst case, it will process some code
after the first \fi and before the final \fi of the \iffalse. But that's
still better than the current situation, where it processes everything
between \iffalse and \fi.
Cheers,
Reinhold
--
------------------------------------------------------------------
Reinhold Kainhofer, reinhold@kainhofer.com, http://www.kainhofer.com
* Financial & Actuarial Math., Vienna Univ. of Technology, Austria
* http://www.fam.tuwien.ac.at/, DVR: 0005886
* Edition Kainhofer, Music Publisher, http://www.edition-kainhofer.com
Reinhold Kainhofer <reinhold@fam.tuwien.ac.at> writes: > On 2012-10-06 06:33, lemzwerg@googlemail.com wrote: > >> http://codereview.appspot.com/6584073/diff/1/python/book_latex.py#newcode88 >> python/book_latex.py:88: ...
11 years, 5 months ago
(2012-10-06 12:59:00 UTC)
#5
Reinhold Kainhofer <reinhold@fam.tuwien.ac.at> writes:
> On 2012-10-06 06:33, lemzwerg@googlemail.com wrote:
>
>> http://codereview.appspot.com/6584073/diff/1/python/book_latex.py#newcode88
>> python/book_latex.py:88: \\iffalse.*\\fi))''',
>> As David has commented on the list, I would prefer if you replaced the
>> \iffalse ... \fi with a higher-level command, namely \begin{comment} ...
>> \end{comment} (from the `comment' package).
>
> So, your opinion is that lilypond-book SHOULD process the
> \lilypond{...} code inside the \iffalse section and spectacularly
> fail.
Reality check: lilypond-book does not "spectacularly fail". It
processes the included snippets which LaTeX then just skips.
lilypond-book just takes unnecessary effort.
> If users are using \iffalse -- I am for example one of those who use
> \iffalse to quickly comment out some parts temporarily -- then
> lilypond-book would still require everything between \iffalse and \fi
> to be in correct lilypond syntax and will create snippet images for
> all those snippets:
Exactly.
> \documentclass[a4paper, 12pt]{article}
> \begin{document}
> TODO
>
> \iffalse
> This is a template for my future snippets:
> \lilypond{Code comes here}
> \fi
>
> \end{document}
>
> Shall lilypond-book really fail for (and process) snippets that will
> NOT be included by latex???
\iffalse\fi is not a LaTeX sequence. If it were, there would be little
excuse _not_ to heed its inherent nesting, like TeX does. If you write
\iffalse
\ifverbose Hey this is nice!. \fi
This is a template for my future snippets:
\lilypond{Code comes here}
\fi
then lilypond-book will spectacularly fail as it, as opposed to
TeX/LaTeX, is not able to properly match \if...\fi.
Using and heeding the comment environment, in contrast, does not suffer
from that problem.
>> First of all, this syntax
>> suits LaTeX better since it resembles normal environments. Second, it
>> is a bad idea in general to expose \ifXXX to the top level; in other
>> words, users should never do that.
>
> But fact is, people ARE using \iffalse to temporarily comment out
> larger parts of latex files. With my colleagues, I have never seen
> \begin{comment} for comments, all the researchers I have worked with
> so far were using \iffalse.
>
> Also, this is not about advocating what latex users should use, but
> handling whare users are using currently. So, I will add
> \begin{comment} to the pattern, too, but I still think that
> lilypond-book SHOULD ignore everything inside \iffalse.
The problem is that lilypond-book has _no_ way to figure out just _what_
is supposed to be "everything inside \iffalse" if you ever actually
start using TeX conditionals for any other purpose than outcommenting
code.
>> Reason is that \ifXXX is handled
>> very special in TeX since you can define, say, \ifFoo which also pairs
>> with the next \fi, making correct balancing of nested \ifXXX commands
>> quite delicate and very hard to debug.
>
> Sure, it's not the perfect way, but it's the quick-and-dirty way.
> I'm also aware that lilypond-book will not be able to handle nested
> \ifXXX correctly. However, in the worst case, it will process some
> code after the first \fi and before the final \fi of the \iffalse. But
> that's still better than the current situation, where it processes
> everything between \iffalse and \fi.
I disagree. lilypond-book is not smart enough to know about the LaTeX
structure of the document. If you want smart processing of typeset
material, the lilypond environment would have to be processed by LaTeX
rather than replaced by lilypond-book acting as a preprocessor.
That would be nice to have and obliterate the need for a separate .lytex
file, but it would also make it unfeasible to use lilypond environments
and commands nested in contexts (like in macro arguments) where LaTeX's
\verb and other "verbatim-like" constructs would also experience
problems.
--
David Kastrup
> So, your opinion is that lilypond-book SHOULD process the > \lilypond{...} code inside the ...
11 years, 5 months ago
(2012-10-06 17:59:29 UTC)
#6
> So, your opinion is that lilypond-book SHOULD process the
> \lilypond{...} code inside the \iffalse section and spectacularly
> fail.
It is debatable how much plain TeX code should be used at all in a
LaTeX document. Just think of a latex->html translation.
> With my colleagues, I have never seen \begin{comment} for comments,
> all the researchers I have worked with so far were using \iffalse.
OK.
> So, I will add \begin{comment} to the pattern, too,
Thanks.
> but I still think that lilypond-book SHOULD ignore everything inside
> \iffalse.
OK.
Werner
Issue 6584073: lilypond-book: treat iffalse sections in latex as block comments
(Closed)
Created 11 years, 6 months ago by Reinhold
Modified 8 years, 1 month ago
Reviewers: janek, Julien Rioux, lemzwerg, reinhold_fam.tuwien.ac.at, dak, wl_gnu.org
Base URL: http://git.savannah.gnu.org/gitweb/?p=lilypond.git/trunk/
Comments: 3