Found a minor defect while beautifying markup jsp and asp like template delimiters (i.e., <% .. %>), the parse is interpreting <% do %> as template_start and it causes the beautifier to indent one extra level when sometimes it shouldn't do this. I believe the reason for this feature to exist is to support <% do %> like loops or something similar, but it's matching every template that has a do within the delimiters.
For example, this:
<%
int i = 0;
do {
i++;
}while(i < 3);
%>
<!DOCTYPE html>
<html>
...
</html>
Is beautified to:
<%
int i = 0;
do {
i++;
}while(i < 3);
%>
<!DOCTYPE html>
<html>
...
</html>
The example above describe the do while case, but it can also be triggered if you have any "\sdo\s" within the template.
<%
// do the harlem shake
%>
<!DOCTYPE html>
<html> ...</html>
I found out which part of the code is doing this, check the code below:
...
else if ((/\sdo\s/).test(element) === true || (/^(<%(%|-)?\s*if)/).test(element) === true) {
types[types.length - 1] = "template_start";
}
....
I managed to solve this by changing the regex to /^<%\s*do\s so that the do will match the beginning of a template but not every word in the template.
Found a minor defect while beautifying markup jsp and asp like template delimiters (i.e.,
<% .. %>), the parse is interpreting<% do %>astemplate_startand it causes the beautifier to indent one extra level when sometimes it shouldn't do this. I believe the reason for this feature to exist is to support<% do %>like loops or something similar, but it's matching every template that has adowithin the delimiters.For example, this:
Is beautified to:
The example above describe the
do whilecase, but it can also be triggered if you have any"\sdo\s"within the template.I found out which part of the code is doing this, check the code below:
I managed to solve this by changing the regex to
/^<%\s*do\sso that thedowill match the beginning of a template but not every word in the template.