Skip to content

fix: allow unclosed single quotes in php-template (fixes #4152)#4374

Open
KJyang-0114 wants to merge 1 commit into
highlightjs:mainfrom
KJyang-0114:fix/issue-4152-php-template-apostrophe
Open

fix: allow unclosed single quotes in php-template (fixes #4152)#4374
KJyang-0114 wants to merge 1 commit into
highlightjs:mainfrom
KJyang-0114:fix/issue-4152-php-template-apostrophe

Conversation

@KJyang-0114

Copy link
Copy Markdown
Contributor

Description

Fixes issue #4152 where a single apostrophe (unclosed quote) in php-template breaks highlighting for everything after it.

Problem

In php-template, an unclosed single quote like causes the entire remainder of the document to not be highlighted correctly. The issue does not occur in regular PHP mode.

Solution

Removed the skip: true property from the inherited APOS_STRING_MODE and QUOTE_STRING_MODE in php-template.js. This allows the parser to handle unclosed quotes more gracefully without breaking subsequent highlighting.

Testing

Added a test case in test/markup/php-template-apostrophe/default.txt that reproduces the issue from the bug report.

Reproduction

<?php
// This won\'t be highlighted unless there is another 
// single apostrophe later.
?>
<p>Some HTML <?= '\code' ?></p>

@joshgoebel

Copy link
Copy Markdown
Member

skip is important so that entire chunks of skipped code are correctly handed to php for it's own subprocessing. Perhaps if there was another simple way to fix this without touching skip...

As a general policy though we don't care a lot about incomplete/invalid code chunks (which often carry all sorts of challenges to get right)... we are optimized for highlighting syntactically valid code..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants