Skip to content

Fitb literal strings#2936

Open
dbrianwalton wants to merge 3 commits into
PreTeXtBook:masterfrom
dbrianwalton:fitb-literal-strings
Open

Fitb literal strings#2936
dbrianwalton wants to merge 3 commits into
PreTeXtBook:masterfrom
dbrianwalton:fitb-literal-strings

Conversation

@dbrianwalton

Copy link
Copy Markdown
Contributor

Targeted to address #2460

Description of changes:

  • Added a template in pretext-text-utilities.xsl that takes a string and escapes regular expression token characters so that they would match literally in a regular expression comparison. \ . ^ $ * + ? { } [ ] ( ) |
  • When a FITB answer checker for a string involves @use-answer="yes", it compares with the regex-escaped answer string instead of the answer string itself
  • The original code used xsl:choose for a case that no answer checker was provided for the correct response so that it used the provided answer. This introduced a second area that would have needed the correction, so instead we used the mode="exercise" during assembly-stage to insert a missing <test correct="yes"> element so that the same branch of logic is followed whether the author provided the element or not.

Although I originally expected I needed exslt for regular expressions, the standard str:replace method using search/replace pairs did the job fine.

@dbrianwalton

Copy link
Copy Markdown
Contributor Author

sec-fitb-string-tests.xml

This file contains example exercises that would not have worked previously that now work. (Claude helped construct the examples.)

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.

1 participant