highlightjs / highlightjs/highlight.js

(php) Semicolon inside string parsed as end of statement

Open
#4,006 3 comments 0 reactions 0 assignees View on GitHub
bug help welcome language
Dominant language
JavaScript
Stars
25k
Forks
3.8k
Avg merge
11h 35m
Merged PRs (30d)
3

Description

**Describe the issue**
It looks like a semicolon inside a string is parsed as terminating the statement, at least sometimes.

**Which language seems to have the issue?**
`php`

**Are you using `highlight` or `highlightAuto`?**
`highlight`

**Sample Code to Reproduce**
Fiddle here: https://jsfiddle.net/c3sLm2ga/. See how the highlighting gets messed up halfway through the string in the `throw` statement. Oddly, double-quoted strings are also affected but in a slightly different way.

**Expected behavior**
```php
public static function mutate() {
$result = null;
DB::transaction(function () use (): void {
if (static::$currentMutator !== null) {
throw new LoggingMutatorException('LoggingMutator::mutate called while already in a mutation; nested mutations are not supported.');
}
$operationLogger = new OperationLogger($user);
})
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.