-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhighlighter.stub.php
More file actions
53 lines (48 loc) · 1.92 KB
/
Copy pathhighlighter.stub.php
File metadata and controls
53 lines (48 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace YiiPress;
/**
* Server-side syntax highlighter backed by the native highlighter extension.
*/
final class Highlighter
{
/**
* Creates a highlighter instance.
*
* The default theme is used when a highlight method does not receive an explicit theme name.
*
* @param string $defaultTheme Syntect theme name or .tmTheme file path to use by default.
*/
public function __construct(string $defaultTheme = 'InspiredGitHub') {}
/**
* Highlights all supported code blocks in an HTML fragment.
*
* Code blocks are detected in the form `<pre><code class="language-...">...</code></pre>`.
* If the fragment contains no supported blocks, the original HTML is returned unchanged.
*
* @param string $html HTML fragment containing escaped code blocks.
* @param string|null $themeName Syntect theme name or .tmTheme file path. When null, the constructor default is used.
*
* @throws \RuntimeException When the theme is unknown or input cannot be processed.
*/
public function highlightHtml(string $html, ?string $themeName = null): string
{
return $html;
}
/**
* Highlights a raw code string and returns highlighted HTML.
*
* Unknown languages fall back to plain text highlighting. PHP code may be passed without an
* opening `<?php` tag; the synthetic tag used internally is stripped from the returned HTML.
*
* @param string $code Raw source code.
* @param string $language Syntax token such as "php", "js", or "css".
* @param string|null $themeName Syntect theme name or .tmTheme file path. When null, the constructor default is used.
*
* @throws \RuntimeException When the theme is unknown or input cannot be processed.
*/
public function highlight(string $code, string $language, ?string $themeName = null): string
{
return $code;
}
}