[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: Review Request 117571: For syntax highlighting, allow .js-files to start with a shebang
From:       "Magnus Hoff" <maghoff () gmail ! com>
Date:       2014-04-15 9:25:58
Message-ID: 20140415092558.4597.95534 () probe ! kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


> On April 14, 2014, 9:43 p.m., Joseph Wenninger wrote:
> > Please check/adapt other highligtings that include the Javascript one. I think \
> > this change alone could break eg. html, since html.xml has <IncludeRules \
> > context="##JavaScript" includeAttrib="true"/> which includes the first context \
> > (if I remember correctly), so the #! would also be highlighted there. I didn't \
> > test your change, this review is just a heads up, that there might be some \
> > additional highlightings in need of testing.

Spot on. The shebang is also highlighted inside of .html files. 

Additionally, and even worse, JavaScript-highlighting inside .html files is entirely \
broken with this patch, presumably because the highlighter ends up in the wrong state \
after the (optional) shebang line.

It seems that these problems go away if I change the include directive in html.xml \
from <IncludeRules context="##JavaScript" includeAttrib="true"/> to <IncludeRules \
context="Normal##JavaScript" includeAttrib="true"/>

There are a few cases of inclusion of the JavaScript rules. Do you have some kind of \
automatic testing tools for this to ensure that what I check in doesn't break stuff, \
or do I have to interactively test each syntax highlighting scheme?

kate/part/syntax/data$ grep '##JavaScript' *
coffee.xml:        <IncludeRules context="##JavaScript" includeAttrib="true"/>
djangotemplate.xml:    <IncludeRules context="##JavaScript" includeAttrib="true"/>
html.xml:    <IncludeRules context="##JavaScript" includeAttrib="true"/>
mako.xml:               <IncludeRules context="##JavaScript" includeAttrib="true"/>
mako.xml:               <IncludeRules context="##JavaScript" includeAttrib="true"/>
mediawiki.xml:        <IncludeRules context="##JavaScript" />
mediawiki.xml:        <IncludeRules context="##JavaScript" />
php.xml:        <IncludeRules context="##JavaScript" />
php.xml:        <IncludeRules context="##JavaScript" />
qml.xml:        <IncludeRules context="##JavaScript" />
rhtml.xml:                              <IncludeRules context="##JavaScript" \
includeAttrib="true"/>


- Magnus


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/117571/#review55780
-----------------------------------------------------------


On April 14, 2014, 9:02 p.m., Magnus Hoff wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/117571/
> -----------------------------------------------------------
> 
> (Updated April 14, 2014, 9:02 p.m.)
> 
> 
> Review request for Kate.
> 
> 
> Bugs: 325805
> http://bugs.kde.org/show_bug.cgi?id=325805
> 
> 
> Repository: kate
> 
> 
> Description
> -------
> 
> When writing node.js scripts it is common to include a shebang at the top, like \
> `#!/usr/bin/env node`, and save it in a .js-file. However, the syntax highlighter \
> for JavaScript does not understand the shebang, and tries to highlight it as \
> JavaScript. 
> It is understood as two literal regular expressions (/usr/bin and /env node), the \
> last of which is not closed, meaning that the rest of the file is attempted \
> understood as part of the last regular expression. 
> This defeats syntax highlighting for .js-files that start with a shebang.
> 
> This patch allows .js files to start with a shebang.
> 
> This fixes https://bugs.kde.org/show_bug.cgi?id=325805
> 
> 
> Diffs
> -----
> 
> part/syntax/data/javascript.xml 260aa72 
> 
> Diff: https://git.reviewboard.kde.org/r/117571/diff/
> 
> 
> Testing
> -------
> 
> I've been using this patch locally, and it works.
> 
> 
> Thanks,
> 
> Magnus Hoff
> 
> 


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/117571/">https://git.reviewboard.kde.org/r/117571/</a>
  </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <p style="margin-top: 0;">On April 14th, 2014, 9:43 p.m. UTC, <b>Joseph \
Wenninger</b> wrote:</p>  <blockquote style="margin-left: 1em; border-left: 2px solid \
#d0d0d0; padding-left: 10px;">  <pre style="white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Please check/adapt other highligtings that include the Javascript one. I \
think this change alone could break eg. html, since html.xml has &lt;IncludeRules \
context=&quot;##JavaScript&quot; includeAttrib=&quot;true&quot;/&gt; which includes \
the first context (if I remember correctly), so the #! would also be highlighted \
there. I didn&#39;t test your change, this review is just a heads up, that there \
might be some additional highlightings in need of testing.</pre>  </blockquote>







</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Spot on. The shebang is \
also highlighted inside of .html files. 

Additionally, and even worse, JavaScript-highlighting inside .html files is entirely \
broken with this patch, presumably because the highlighter ends up in the wrong state \
after the (optional) shebang line.

It seems that these problems go away if I change the include directive in html.xml \
from &lt;IncludeRules context=&quot;##JavaScript&quot; \
includeAttrib=&quot;true&quot;/&gt; to &lt;IncludeRules \
context=&quot;Normal##JavaScript&quot; includeAttrib=&quot;true&quot;/&gt;

There are a few cases of inclusion of the JavaScript rules. Do you have some kind of \
automatic testing tools for this to ensure that what I check in doesn&#39;t break \
stuff, or do I have to interactively test each syntax highlighting scheme?

kate/part/syntax/data$ grep &#39;##JavaScript&#39; *
coffee.xml:        &lt;IncludeRules context=&quot;##JavaScript&quot; \
                includeAttrib=&quot;true&quot;/&gt;
djangotemplate.xml:    &lt;IncludeRules context=&quot;##JavaScript&quot; \
                includeAttrib=&quot;true&quot;/&gt;
html.xml:    &lt;IncludeRules context=&quot;##JavaScript&quot; \
                includeAttrib=&quot;true&quot;/&gt;
mako.xml:               &lt;IncludeRules context=&quot;##JavaScript&quot; \
                includeAttrib=&quot;true&quot;/&gt;
mako.xml:               &lt;IncludeRules context=&quot;##JavaScript&quot; \
                includeAttrib=&quot;true&quot;/&gt;
mediawiki.xml:        &lt;IncludeRules context=&quot;##JavaScript&quot; /&gt;
mediawiki.xml:        &lt;IncludeRules context=&quot;##JavaScript&quot; /&gt;
php.xml:        &lt;IncludeRules context=&quot;##JavaScript&quot; /&gt;
php.xml:        &lt;IncludeRules context=&quot;##JavaScript&quot; /&gt;
qml.xml:        &lt;IncludeRules context=&quot;##JavaScript&quot; /&gt;
rhtml.xml:                              &lt;IncludeRules \
context=&quot;##JavaScript&quot; includeAttrib=&quot;true&quot;/&gt;</pre> <br />










<p>- Magnus</p>


<br />
<p>On April 14th, 2014, 9:02 p.m. UTC, Magnus Hoff wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for Kate.</div>
<div>By Magnus Hoff.</div>


<p style="color: grey;"><i>Updated April 14, 2014, 9:02 p.m.</i></p>







<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="http://bugs.kde.org/show_bug.cgi?id=325805">325805</a>


</div>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kate
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">When writing node.js scripts it is common to include a shebang at the \
top, like `#!/usr/bin/env node`, and save it in a .js-file. However, the syntax \
highlighter for JavaScript does not understand the shebang, and tries to highlight it \
as JavaScript.

It is understood as two literal regular expressions (/usr/bin and /env node), the \
last of which is not closed, meaning that the rest of the file is attempted \
understood as part of the last regular expression.

This defeats syntax highlighting for .js-files that start with a shebang.

This patch allows .js files to start with a shebang.

This fixes https://bugs.kde.org/show_bug.cgi?id=325805</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">I&#39;ve been using this patch locally, and it works.</pre>  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>part/syntax/data/javascript.xml <span style="color: grey">(260aa72)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/117571/diff/" style="margin-left: \
3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>



_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic