-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
While working on a language definition file I stubmled upon the following error when building HLJS:
Starting build.
Copying documentation.
Writing documentation.
Generating demo.
Building highlight.js pack file.
Compressing highlight.js pack file.
{ task: 'tasks',
error: { task: 'replaceSkippingStrings', error: 'Unmatched quote' } }
The error was risen by a multiline comments block I've added to the lang file using /* ... */. When I changed the comments to multiple single-line comments (// ...) the error was gone. So I worked to pin down the problem...
I've selectively removed comment lines until I isolated the culprit, but I can't make much sense from what I've found.
The following comment will raise the error:
/*
http://www.someurl.com/
*/
But if I remove the slash / at the end of the line the error dissapears:
/*
http://www.someurl.com
*/
The error also dissapears by adding another slash / at the end of the line:
/*
http://www.someurl.com//
*/
But a third slash bring the problem back again:
/*
http://www.someurl.com///
*/
And it doesn't matter is the slash is the last char on the line or if there are other characters following it — it's the presence of an ODD number of slashes on the line that raises the error!
It seems a problem relating to parsing multiline comments and the way slashes are interpreted — and the presence of two slashes in the URL is what sets into motion. A line with an odd number of slashes seems to raise the error, not so when their number is even. The 'Unmatched quote' error reported is a bit misleading, at the beginning I though it was due to the single quotes, but it wasn't.
The problem doesn't show up when using single line comments:
// http://www.someurl.com/
So we are not talking about an edge-case, similar URLs are common within comment blocks. The error blocks the building process, and doesn't provide much info on where the process failed, so users might need quite some time to isolate the specific line which is causing build failure.