ShaneCunn / syntaxhighlighter

Automatically exported from code.google.com/p/syntaxhighlighter
GNU General Public License v3.0
0 stars 0 forks source link

Suggested Change in New shBrushBash.js #114

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Using shBrushBash.js with '>' or '<' as the html entities (&gt; &lt;)

These will match bash built-in commands (gt, lt etc.) and display wrong as
the span tag will get placed in between.

e.g. &gt; becomes &<span class="keyword">gt</span>;
Should be &gt; (unstyled)

What steps will reproduce the problem?
1. Create highlighted bash script using redirection
  <pre name="code" class="bash">ls > myfile</pre>

Suggested fix...

Remove 'eq ne gt lt ge le' from the keywords variable.

Add Regex:
{ regex: new RegExp('\\-gt|\\-lt|\\-le|\\-eq|\\-ne|\\-ge', 'g'), css:
'keyword' }

The comparison commands are usually used as -eq -gt -lt etc. so the regex
only matches when required.

Original issue reported on code.google.com by mdjwo...@gmail.com on 20 Oct 2008 at 3:49

GoogleCodeExporter commented 8 years ago
sorry
regex should be
{ regex: new RegExp('-gt|-lt|-le|-eq|-ne|-ge', 'g'), css: 'keyword' }

Original comment by mdjwo...@gmail.com on 20 Oct 2008 at 4:01

GoogleCodeExporter commented 8 years ago
Also, you could add the variables regex as well

{ regex: new RegExp('\\$\\w+', 'g'), css: 'vars' }

And there seems to be no styling for the vars class, I'd used (in 
SyntaxHighlighter.css)
.dp-highlighter .vars { color: red; }

Great app btw, thanks for the hard work.

Original comment by mdjwo...@gmail.com on 20 Oct 2008 at 4:07