WeBWorK Problems

multi-line comments in PGML

multi-line comments in PGML

by Larry Riddle -
Number of replies: 4

I know that [% .... %] is used for a comment in PGML. But it only seems to work when the comment is a single paragaph, not when the intended comment extends over several paragraphs. For example, if I try a pg file that includes

BEGIN_PGML

Line 1

[% line 2

line 3 %]

END_PGML

then everything between the [% and the %] is shown in gray in the editor as is expected for a comment, but when viewing the problem, what is printed is

Line 1

line 3 %]

If I place the [%...%] around both line 2 and line 3, then neither is printed as is expected.

I am editing some problems that have lengthy solutions provided in multiple paragraphs. I don't want to delete those solutions but would rather keep the text of the solutions in the problem for later potential editing. For now I would like to comment them out and replace them with an alternate solution. I'd like to be able to use just one set of [%...%] brackets to comment out the entire original solution rather than have to comment out each separate paragraph. But that doesn't seem to be possible. Is there an alternative?

In reply to Larry Riddle

Re: multi-line comments in PGML

by Larry Riddle -
I found an easy alternative. Move all the text in the solution section to below the ENDDOCUMENT(); line. Then it is ignored, but it is still there if I need to go back and restore the original solution materials at a later time.

Still, something seems to be wrong with the current implementation of comments in PGML if everything between [% and %] is grayed out in the editor as if all of it will be included as comments, but everything after the first paragraph is still displayed when the problem is viewed.
In reply to Larry Riddle

Re: multi-line comments in PGML

by Davide Cervone -
In PGML, block-level commands are ended by a paragraph break. Comments are block-level, and so are terminated by the blank line. This should report a warning message, but warnings are turned off by default. In any case, I've made a pull request that allows comments to include paragraph breaks. You could get a copy of the PGML.pl file from that PR and put it in your course's templates/macros directory until it is included in a release version of PG.
In reply to Davide Cervone

Re: multi-line comments in PGML

by Larry Riddle -

Thanks, Davide. The new version of PGML.pl in the templates/macros directory works to comment out everything I wanted with just the one set of [%...%].