Commit 99fb6ca9 authored by Florian Pritz's avatar Florian Pritz
Browse files

Add special *.asciinema.json filename



Don't force users to name all their files asciinema.json. Give them
some room for descriptive names.
Signed-off-by: default avatarFlorian Pritz <bluewind@xinu.at>
parent ed496907
......@@ -171,6 +171,14 @@ class Pygments {
);
if (array_key_exists($this->filename, $namearray)) return $namearray[$this->filename];
$longextarray = array(
'.asciinema.json' => 'asciinema',
);
foreach ($longextarray as $key => $lexer) {
if (substr($this->filename, -strlen($key)) === $key) {
return $lexer;
}
}
if (strpos($this->filename, ".") !== false) {
$extension = substr($this->filename, strrpos($this->filename, ".") + 1);
......
......@@ -47,6 +47,12 @@ class test_libraries_pygments extends \test\Test {
$p = new \libraries\Pygments('/invalid/filepath', 'text/plain', 'PKGBUILD');
$this->t->is($p->autodetect_lexer(), 'bash', "PKGBUILD should be bash");
$p = new \libraries\Pygments('/invalid/filepath', 'text/plain', 'asciinema.json');
$this->t->is($p->autodetect_lexer(), 'asciinema', "asciinema.json should be asciinema");
$p = new \libraries\Pygments('/invalid/filepath', 'text/plain', 'test.asciinema.json');
$this->t->is($p->autodetect_lexer(), 'asciinema', "asciinema.json should be asciinema");
}
public function test_autodetect_lexer_specialFilenamesBinaryShouldNotHighlight()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment