convert-to-pgml.pl -- Convert pg problem with non-pgml structure to PGML structure.
convert-to-pgml -b -s pgml file1.pg file2.pg ...
This converts each pg file to PGML formatting. In particular, text blocks are converted to their PGML forms. This includes BEGIN_TEXT/END_TEXT, BEGIN_HINT/END_HINT, BEGIN_SOLUTION/END_SOLUTION.
Within each block, the following are converted: math modes to their PGML version, $BR and $PAR to line breaks or empty lines, $HR
to ---
, bold and italics pairs, any variables of the form $var
to [$var]
, scripts from \{ \} to [@ @], and ans_rule
to the form [_]{}
Many code features that are no longer needed are removed including TEXT(beginproblem())
, <Context()-
texStrings;>> and <Context()-
normalStrings;>>. Any ANS
commands are commented out.
The loadMacros
command is parsed, the PGML.pl
is included and MathObjects.pl
is removed (because it is loaded by PGML.pl
) and PGcourse.pl
is added to the end of the list.
Note: many of the features are converted correctly, but often there will be errors after the conversion. Generally after using this script, the PGML style answers will need to have their corresponding variable added.
The option -b
or --backup
will create a .bak
file with the original code and replace the current file with the converted code.
The option -s xyz
or --suffix=xyz
will convert the code and write the results in a file with the given suffix xyz
appended to the file name. If this is not given pgml
is used. If the -b
flag is used, this option will be ignored.