friendica-addons/highlightjs/highlightjs.php

34 lines
796 B
PHP
Raw Permalink Normal View History

2018-09-20 02:03:15 +00:00
<?php
/**
* Name: Syntax Highlighting
* Description: Highlights syntax of code blocks with highlight.js
* Version: 1.0
* Author: Hypolite Petovan <hypolite@mrpetovan.com>
*/
use Friendica\Core\Hook;
use Friendica\DI;
2018-09-20 02:03:15 +00:00
function highlightjs_install()
{
Hook::register('head' , __FILE__, 'highlightjs_head');
Hook::register('footer', __FILE__, 'highlightjs_footer');
2018-09-20 02:03:15 +00:00
}
function highlightjs_head(string &$str)
2018-09-20 02:03:15 +00:00
{
2024-12-11 21:47:10 +00:00
if (DI::appHelper()->getCurrentTheme() == 'frio') {
2018-09-20 02:03:15 +00:00
$style = 'bootstrap';
} else {
$style = 'default';
}
DI::page()->registerStylesheet(__DIR__ . '/asset/styles/' . $style . '.css');
}
2018-09-20 02:03:15 +00:00
function highlightjs_footer(string &$str)
{
DI::page()->registerFooterScript(__DIR__ . '/asset/highlight.pack.js');
DI::page()->registerFooterScript(__DIR__ . '/highlightjs.js');
2018-09-20 02:03:15 +00:00
}