Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Units/parser-html.r/comment-in-js.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--fields=+l
--extras=+g
5 changes: 5 additions & 0 deletions Units/parser-html.r/comment-in-js.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
simple_anchor input.html /^ <a name="simple_anchor"><\/a>$/;" a language:HTML
unquoted_anchor input.html /^ <a name=unquoted_anchor><\/a>$/;" a language:HTML
prefixed_anchor input.html /^ <a title="Title" name="prefixed_anchor"><\/a>$/;" a language:HTML
postfixed_anchor input.html /^ <a name=postfixed_anchor href="http:\/\/darrenhiebert.com"><\/a>$/;" a language:HTML
message input.html /^function message()$/;" f language:JavaScript
29 changes: 29 additions & 0 deletions Units/parser-html.r/comment-in-js.d/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<html >
<head>
<script language="Javascript" src="./test.js"></script>
<script language="JavaScript">
<!--

// function commented_function1 () {}
/*
function commented_function2 () {}
*/

function message()
{
alert( "Hello.");
}

//-->
</script>
<body>
<a name="simple_anchor"></a>
<a name=unquoted_anchor></a>
<a title="Title" name="prefixed_anchor"></a>
<a name=postfixed_anchor href="http://darrenhiebert.com"></a>
<!-- <a name="commented_anchor"></a> -->
</body>
</html>



33 changes: 18 additions & 15 deletions parsers/html.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,23 +334,26 @@ static void readToken (tokenInfo *const token, bool skipComments, bool asJSX)
d = getcFromInputFile ();
if (d == '-')
{
int e = ' ';
int f = ' ';
do
/* JSX does not support HTML comments, so don't skip
* over them */
if (!asJSX)
{
d = e;
e = f;
f = getcFromInputFile ();
int e = ' ';
int f = ' ';
do
{
d = e;
e = f;
f = getcFromInputFile ();
}
while (f != EOF && ! (d == '-' && e == '-' && f == '>'));

if (skipComments)
goto getNextChar;
}
while (f != EOF && ! (d == '-' && e == '-' && f == '>'));

if (skipComments)
goto getNextChar;
else
{
token->type = TOKEN_COMMENT;
break;
}
token->type = TOKEN_COMMENT;
break;
}
}
ungetcToInputFile (d);
Expand Down Expand Up @@ -843,7 +846,7 @@ extern void htmlParseJSXElement (void)
tokenInfo token;
token.string = vStringNew ();

readToken (&token, true, true);
readToken (&token, false, true);
if (token.type == TOKEN_OPEN_TAG_START)
readTag (&token, NULL, 0, true);

Expand Down
Loading