Open StevenClontz opened 3 weeks ago
Thanks for reporting this. I suspect a full rebuild should show the error again. A weakness of the CodeChat System is that any change to the document causes a rebuild, so an edit (or even switching windows) clears the last (error) output, rebuilds, and shows the new output (no error, since the erroneous file wasn't rebuilt). Adding a persistent log feature to save these previous outputs would help, but would also require some time and thought.
I'm not sure that's the case - we are looking at the erroneous file here (see line 26).
The CodeChat System only run a build when the source file is older than the output HTML. What you see is probably a non-build -- since the HTML is up to date, no build needs to be run. I assume that performing a trivial edit (space then backspace) causes the error to reappear?
Hard to tell - that screenshot was taken via Zoom from an author! But I think that your theory is still incorrect: I seem to recall the author made an edit (or hit Save), and the document rebuilt with errors, but then the errors flashed off the screen and showed the screenshot above. I'm asking for more details.
So think figured it out... if you have an Xml:id that begins with a number, pretext will throw a very unhelpful warning warning: Failed to map codechat path to xml id; codechat will not work. . believe that is an XML thing, but Pretext should be more helpful
Thanks for tracking this down!
So I think this is a PreTeXt bug. If an xml:id
contains characters other than letters, numbers, hyphens, and underscores, then it will raise a PTX:ERROR, and Codechat will display this. e.g.
[31merror: [0m* PTX:ERROR: The @xml:id "30-def-special right-triangles" is invalid. Use only letters, numbers, hyphens and underscores.
successful application of /home/vscode/.ptx/2.6.2/core/xsl/pretext-html.xsl
[33mwarning: [0mFailed to map codechat path to xml id; codechat will not work.
However, if an xml:id
begins with a number but only contains valid characters otherwise, no PTX:ERROR is raised. It simply issues the warning
[33mwarning: [0mFailed to map codechat path to xml id; codechat will not work.
I believe Codechat is not doing anything since there is no PTX:ERROR, and thus its behavior in this case is unpredictable based on what previous builds have been made. While perhaps Codechat could figure out a way to work around this, it seems like the better fix is to get PreTeXt to throw an error here?
This is possibly a code chat issue, if it's using lxml directly to parse XML IDs to guess file names.
I should also note that even when that Codechat will not work
warning is being raised, Codechat says Build complete.Error(s): 0, warning(s): 0
which is misleading.
Certainly, the messages comes from https://github.com/PreTeXtBook/pretext-cli/blob/03d0641495d728b5d56b9f9d322afbee3c98d1d3/pretext/project/__init__.py#L654, which is produced by CodeChat's lxml processing of the PreTeXt source.
I should also note that even when that
Codechat will not work
warning is being raised, Codechat saysBuild complete.Error(s): 0, warning(s): 0
which is misleading.
I think this is a separate issue -- that errors aren't accumulated across builds/refreshes. (It does need fixing, certainly.)
Does PreTeXt need valid XML IDs? Or can it work fine regardless? That is, should CodeChat be able to tolerate invalid XML IDs, or should this be a "fix me" for the author instead?
Both pretext and code chat should report an error to authors that XML IDs leading with a digit are invalid and should be fixed.
This build flashed the error during the build (XML IDs cannot have spaces), but those errors did not persist after the build.