Skip to content

Commit

Permalink
PHP: Fix shell-comment failure now that strings are greedy
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Mar 3, 2018
1 parent 5d7223c commit ad25d22
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
4 changes: 1 addition & 3 deletions components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ Prism.languages.php = Prism.languages.extend('clike', {
}
});

// Shell-like comments are matched after strings, because they are less
// common than strings containing hashes...
Prism.languages.insertBefore('php', 'class-name', {
Prism.languages.insertBefore('php', 'string', {
'shell-comment': {
pattern: /(^|[^\\])#.*/,
lookbehind: true,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-php.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions examples/prism-php.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,4 @@ <h2>String interpolation</h2>
FOO;
$b = &lt;&lt;&lt;"FOOBAR"
Interpolation inside Heredoc strings {$obj->values[3]->name}
FOOBAR;</code></pre>

<h2>Known failures</h2>
<p>There are certain edge cases where Prism will fail.
There are always such cases in every regex-based syntax highlighter.
However, Prism dares to be open and honest about them.
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
</p>

<h3>Shell-like comments containing two quotes of the same type</h3>
<pre><code># Shell-like comment "with quotes" inside
# Shell-like comment 'with quotes' inside</code></pre>

FOOBAR;</code></pre>

0 comments on commit ad25d22

Please sign in to comment.