Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit a89d7b7

Browse files
committed
Releasing v0.5.0
Removing Settings class & replacing it with standard Kirby `c::get` Changing namespace from S1SYPHOS\HIGHLIGHT to Kirby\Plugins\Highlight
1 parent 9de9837 commit a89d7b7

File tree

3 files changed

+6
-32
lines changed

3 files changed

+6
-32
lines changed

core/syntax_highlight.php

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,24 @@
11
<?php
22

3-
namespace S1SYPHOS\HIGHLIGHT;
3+
namespace Kirby\Plugins\Highlight;
44

55
use kirbytext;
66
use Highlight\Highlighter;
77
use c;
88

9-
class Settings {
10-
11-
/**
12-
* Returns the default options for `kirby-highlight`
13-
*
14-
* @return array
15-
*/
16-
17-
public static function __callStatic($name, $args) {
18-
19-
// Set prefix
20-
$prefix = 'plugin.kirby-highlight.';
21-
22-
// Set config names and fallbacks as settings
23-
$settings = [
24-
'languages' => ['html', 'php'], // Languages to be auto-detected
25-
'escaping' => false, // Enables / disables character escaping
26-
];
27-
28-
// If config settings exist, return the config with fallback
29-
if(isset($settings) && array_key_exists($name, $settings)) {
30-
return c::get($prefix . $name, $settings[$name]);
31-
}
32-
}
33-
}
34-
359
kirbytext::$post[] = function($kirbytext, $value) {
3610

3711
// Pattern to be matched when parsing kirbytext() (everything between <code> and </code>)
3812
$pattern = '~<code[^>]*>\K.*(?=</code>)~Uis';
3913

4014
return preg_replace_callback($pattern, function($match) {
4115

42-
// Instantiating highlighter & passing array of languages
16+
// Instantiating Highlighter & passing array of languages to be auto-detected
4317
$highlighter = new Highlighter();
44-
$highlighter->setAutodetectLanguages(settings::languages());
18+
$highlighter->setAutodetectLanguages(c::get('plugin.kirby-highlight.languages', ['html', 'php']));
4519

4620
// Optionally escaping each match ..
47-
$input = settings::escaping() ? $match[0] : htmlspecialchars_decode($match[0]);
21+
$input = c::get('plugin.kirby-highlight.escaping', false) ? $match[0] : htmlspecialchars_decode($match[0]);
4822

4923
// .. but always highlighting & outputting it
5024
$highlightedMatch = $highlighter->highlightAuto($input);

kirby-highlight.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @package Kirby CMS
77
* @author S1SYPHOS <hello@twobrain.io>
88
* @link http://twobrain.io
9-
* @version 0.4.0
9+
* @version 0.5.0
1010
* @license MIT
1111
*/
1212

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "kirby-highlight",
33
"description": "Themeable server-side syntax highlighting for Kirby",
44
"author": "S1SYPHOS <hello@twobrain.io>",
5-
"version": "0.4.0",
5+
"version": "0.5.0",
66
"type": "kirby-plugin",
77
"license": "MIT"
88
}

0 commit comments

Comments
 (0)