php.sugar
php.sugar copied to clipboard
Backslash escaped quotes are closing string
Given this code:
echo '<p>Select the people whose favorites you\'d like to see.</p>';
The apostrophe in "you'd", although backslash escaped, is closing the string (leaving everything else afterward identified as keyword.constant.other
).
Damn. I am thinking I won't be able to keep HTML support in php strings.
The HTML syntax won't go past the ' and the backslash is ignored because it's not seen as a php string technically.
Anything you can think of?
So dig this: look-behinds work (!?):
<zone name="literal.string.html.quoted.single">
<starts-with>
<expression>(')(?=(<)/?([a-zA-Z]))</expression>
<capture number="1" name="delimiter.balanced.quote.single.begin"/>
</starts-with>
<ends-with>
<expression>(?<!\\)(')</expression>
<capture number="1" name="delimiter.balanced.quote.single.end"/>
</ends-with>
<subzones>
<cut-off>[^\\]'</cut-off>
<include syntax="text.html.basic" />
<zone name="literal.escape.brief">
<!-- 'A single-quoted string with \'escape sequences\'' -->
<expression>(\\)('|\\)</expression>
<capture number="1" name="delimiter.seperator.escape"/>
<capture number="2" name="character"/>
</zone>
</subzones>
</zone>
This zone is working perfectly for me with the test file:
<?php
$something = '<p>This is what I\'d like to do.</p>';
?>