summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/libraries/Pygments.php8
-rw-r--r--application/test/tests/test_libraries_pygments.php6
2 files changed, 14 insertions, 0 deletions
diff --git a/application/libraries/Pygments.php b/application/libraries/Pygments.php
index 62229c472..082c52394 100644
--- a/application/libraries/Pygments.php
+++ b/application/libraries/Pygments.php
@@ -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);
diff --git a/application/test/tests/test_libraries_pygments.php b/application/test/tests/test_libraries_pygments.php
index d6bb559ee..57c5d27fe 100644
--- a/application/test/tests/test_libraries_pygments.php
+++ b/application/test/tests/test_libraries_pygments.php
@@ -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()