Skip to content

Commit

Permalink
PHP: Add support for multi-line strings. Fix #1233
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Nov 28, 2017
1 parent de6de45 commit 9a542a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
*/

Prism.languages.php = Prism.languages.extend('clike', {
'string': {
pattern: /(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
greedy: true
},
'keyword': /\b(?:and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,
'constant': /\b[A-Z0-9_]{2,}\b/,
'comment': {
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.

8 changes: 7 additions & 1 deletion tests/languages/php/string_feature.test
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
"https://example.com"
" /* not a comment */ "
"multi-line
string"
'multi-line
string'

----------------------------------------------------

[
["string", "\"https://example.com\""],
["string", "\" /* not a comment */ \""]
["string", "\" /* not a comment */ \""],
["string", "\"multi-line\r\nstring\""],
["string", "'multi-line\r\nstring'"]
]

----------------------------------------------------
Expand Down

0 comments on commit 9a542a0

Please sign in to comment.