Open tstenner opened 5 years ago
jgm/doctemplates is the library used for parsing templates, so any improvements would need to go there.
Right, I see. Could you move this issue to jgm/doctemplates or should I open a new issue?
I can move it...
Note: no document is created. Try -o test.out
; you'll see there is no test.out
.
So you're getting an error message about invalid syntax in the template, which points to the line and column where the error is. All this is just right. The only thing that could be improved, as far as I can see, is that it could say unexpected "$endif$"
instead of unexpected "$"
. Am I missing something?
The only thing that could be improved, as far as I can see, is that it could say unexpected "$endif$" instead of unexpected "$"
That's correct. It's great the correct location is indicated, but if the error message indicated that a $
would be allowed, just not a lone $endif$
it'd be easier to correct the mistake in the template.
Tristan Stenner notifications@github.com writes:
The only thing that could be improved, as far as I can see, is that it could say unexpected "$endif$" instead of unexpected "$"
That's correct. It's great the correct location is indicated, but if the error message indicated that a
$
would be allowed, just not a lone$endif$
it'd be easier to correct the mistake in the template.
Well, actually a lone $
would not be allowed.
Literal $
must be escaped as $$
.
Well, actually a lone
$
would not be allowed.
You're right, but a single $
also has a good error message:
$endif$
^ -> error: unexpected "$"
^ maybe "error: $endif$ without $if$"?
$endi$ Ok, evaluates to empty string
Test $foo without closing dollar sign
^ -> error: unexpected " ", expecting "." or "$"
Yes, I agree that the messages could be somewhat better. This is a low priority for me, though, compared to other things. I'll move this to doctemplates and perhaps someone will take it up.
In pandoc 2.5, a template with an unmatched template conditional causes pandoc to fail with an error:
Any non-keyword (e.g.
$endi$
) is replaced by an empty string and a document is created. While the error message indicates the correct position, it should also include the keyword, i.e."template" (line 2, column 7): unexpected "$else$"