Skip to content

Calling into question PGML answer LaTeX parsing #1542

Open

Description

@drgrice1

I want to know why the following line of code exists:

$rule = PGML::LaTeX($rule);

It seems to me that any answer rule method should already create properly formatted output for the current display mode, and should not need further processing of math for TeX.

Looking back through git blame it seems that this was added in 2015, but at that time this was only done for array answers (answers inserted with [_]*{...}). In 2018 this processing was extended to all answers.

In my testing, I haven't seen any answers (array or otherwise) where this is actually needed.

So what type of answer is this really needed for? Could the code for those answer types be updated to properly deal with this in a less intrusive way?

The reason that I ask is because I have increasingly seen this causing problems with certain types of answers, and not helping anywhere. There are many types of answers these days that are rather intensive with what the answer rule includes. Those answers could include many things that are improperly processed by the PGML::LaTeX call. The primary issue with with an image object from the plots.pl macro. For example, if the new parserMatchList.pl macro in #1541 has answers that are images created with the plots.pl macro.

The same thing could happen with answers for parserRadioButtons.pl or parserCheckboxList.pl that have images created with the plots.pl macro in them. Note that there are HTML validity issues if this is done at this point. However, I have a branch that I have been waiting to create a pull request of specifically because of this issue in which a new answer formatting option for those macros is added that places the text for a check box or radio button answer outside of the label, thus making it possible for these types of answers to be valid for these macros.

Activity

  1. dpvc commented on Sep 21, 2026

    @dpvc
    Member

    I want to know why the following line of code exists:

    The comment for the 2018 commit says

    Process LaTeX for all answer blanks, not just array blanks (since things like stretchy braces can be added around answer rules even if not in array form)

    so that suggests that some answers are including LaTeX notation for delimiters around answers. Unfortunately, I no longer remember which objects those were. Maybe if an array answer is part of a MultiAnswer or something like that? These may also have been answer checkers that were pre-MathObjects that expected to be inserted into BEGIN_TEX/END_TEXT where \(...\) and \[...\] would produce match output in the proper output format automatically (through EV3P).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions