Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit 11c71c4

Browse files
committed land...@'s patch for issue 144 : escaped quotes in bash
1 parent 8aa721d commit 11c71c4

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

js-modules/prettify.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ window['PR']
510510
// with an optional modifier like UL for unsigned long
511511
+ '[a-z]*', 'i'),
512512
null, '0123456789'],
513-
[PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#]*/, null]);
513+
// Don't treat escaped quotes in bash as starting strings. See issue 144.
514+
[PR_PLAIN, /^\\[\s\S]?/, null],
515+
[PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#\\]*/, null]);
514516

515517
return createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
516518
}

src/prettify.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,9 @@ window['PR']
838838
// with an optional modifier like UL for unsigned long
839839
+ '[a-z]*', 'i'),
840840
null, '0123456789'],
841-
[PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#]*/, null]);
841+
// Don't treat escaped quotes in bash as starting strings. See issue 144.
842+
[PR_PLAIN, /^\\[\s\S]?/, null],
843+
[PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#\\]*/, null]);
842844

843845
return createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
844846
}

tests/prettify_test_2.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,17 @@ <h1>Tex support</h1>
399399
\setlength{\tabcolsep}{0em}
400400
</pre>
401401

402+
<h1>Issue 144</h1>
403+
Escaped quotes in bash.
404+
<pre id="issue144" class="prettyprint">
405+
#! /bin/bash
406+
# toascii.sh
407+
for i in $(echo $* | fold -w 1);do
408+
printf "%x " \'$i;
409+
done;
410+
echo
411+
</pre>
412+
402413
<h1>Issue 145</h1>
403414
<pre id="issue145" class="prettyprint">
404415
&lt;script type="text/javascript"&gt;
@@ -785,6 +796,16 @@ <h1>Issue 145</h1>
785796
'`END`KWD\\usepackage`END`PUN{`END`PLNtextcomp`END`PUN}`END`PLN\n' +
786797
'`END`KWD\\pagestyle`END`PUN{`END`PLNempty`END`PUN}`END`PLN\n' +
787798
'`END`KWD\\setlength`END`PUN{`END`KWD\\tabcolsep`END`PUN}{`END`LIT0em`END`PUN}`END'
799+
),
800+
issue144: (
801+
'`COM#! /bin/bash`END`PLN\n' +
802+
'`END`COM# toascii.sh`END`PLN\n' +
803+
'`END`KWDfor`END`PLN i `END`KWDin`END`PLN $`END`PUN(`END`PLNecho $`END`PUN*' +
804+
'`END`PLN `END`PUN|`END`PLN fold `END`PUN-`END`PLNw `END`LIT1`END`PUN);`END' +
805+
'`KWDdo`END`PLN\n' +
806+
' printf `END`STR"%x "`END`PLN \\\'$i`END`PUN;`END`PLN\n' +
807+
'`END`KWDdone`END`PUN;`END`PLN\n' +
808+
'echo`END'
788809
)
789810
};
790811
</script>

0 commit comments

Comments
 (0)