Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Highlighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function __construct(
->addLanguage(new ScssLanguage())
->addLanguage(new SqlLanguage())
->addLanguage(new TerminalLanguage())
->addLanguage(new TextLanguage())
->addLanguage(new TerraformLanguage())
->addLanguage(new TypeScriptLanguage())
->addLanguage(new XmlLanguage())
Expand Down
3 changes: 3 additions & 0 deletions tests/Bench/Fixtures/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Plain text may contain protocol method names such as resources/list and mcp:list.
It may also contain HTTP header names such as Sec-Fetch-Site.
No syntax highlighting should be applied to this content.
1 change: 1 addition & 0 deletions tests/Bench/HighlighterBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ final class HighlighterBench
'terminal' => 'terminal.txt',
'terraform' => 'terraform.txt',
'typescript' => 'typescript.txt',
'txt' => 'text.txt',
'twig' => 'twig.txt',
'vue' => 'vue.txt',
'xml' => 'xml.txt',
Expand Down
10 changes: 10 additions & 0 deletions tests/HighlighterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,14 @@ public function test_fallback_language(): void
$highlighted,
);
}

#[Test]
public function text_language_does_not_use_the_configured_fallback_language(): void
{
$highlighter = new Highlighter(fallbackLanguage: new PhpLanguage());

$this->assertSame('mcp:list', $highlighter->parse('mcp:list', 'txt'));
$this->assertSame('resources/list', $highlighter->parse('resources/list', 'text'));
$this->assertSame('Sec-Fetch-Site', $highlighter->parse('Sec-Fetch-Site', 'txt'));
}
}
Loading