Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the pretty_print method in PGUtil.pm #921

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

drgrice1
Copy link
Member

Currently there are some issues with the method. Undefined variables used in strings cause warnings, and a string containing the word "hash" can cause errors. Furthermore, the formatting of the output is quite bad and uses invalid html (for its HTML display mode).

Also make it possible to override all of the arguments for the PGUtil.pm pretty_print method when calling the PG.pl pretty_print method. Thus you can call pretty_print(output, 'text', 10) instead of $PG->pretty_print(output, 'text', 10) for this anymore. This is useful in debugging when you want to see deeper into a MathObject object. The method still works the same when the additional arguments aren't passed.

I debated on rearranging the last two arguments, but left them for now. The level is the argument that you would typically want to change. It is less likely that you would want to change the display mode.

Attached is a problem to test this. This problem does not work for hardcopy on the develop branch, but does with this pull request. It looks much better in html with this pull request than without.
pretty-print.pg.txt

You can also test this with an admin user in webwork2 using the various checkboxes like "Answer Group Info" and such.

Currently there are some issues with the method. Undefined variables
used in strings cause warnings, and a string containing the word "hash"
can cause errors. Furthermore, the formatting of the output is quite bad
and uses invalid html (for its HTML display mode).

Also make it possible to override all of the arguments for the
`PGUtil.pm` `pretty_print` method when calling the `PG.pl` pretty_print
method. Thus you can call `pretty_print(output, 'text', 10)` instead of
`$PG->pretty_print(output, 'text', 10)` for this anymore. This is useful
in debugging when you want to see deeper into a MathObject object. The
method still works the same when the additional arguments aren't passed.

I debated on rearranging the last two arguments, but left them for now.
The level is the argument that you would typically want to change. It is
less likely that you would want to change the display mode.
@pstaabp pstaabp merged commit 0b1f3ac into openwebwork:develop Oct 2, 2023
2 checks passed
@drgrice1 drgrice1 deleted the pretty-print-cleanup branch October 2, 2023 21:33
drgrice1 added a commit to drgrice1/pg that referenced this pull request Oct 2, 2023
This was mentioned by @drdrew42 a couple of weeks ago, and I forgot to
do it.  The argument name of the `pretty_print` method was incorrect.
Although it doesn't affect the usage it is misleading as to what it does.

Also remove the warning I added in PGUtil.pm that is no longer pertinent
with the addition of the two arguments to the method in PG.pl.
pstaabp added a commit that referenced this pull request Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants