From 45a68bd6f75783fd874c14fe42370e8a6baaa87d Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 1 Apr 2025 10:00:59 +0200 Subject: [PATCH] New plugin: Use Prism for syntax highlighting --- CHANGELOG.md | 1 + plugins/prism.php | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 plugins/prism.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ec42e00..c4afd3b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - CSS: Hide menu on mobile - CSS: Invert icons in dark mode - Plugins: Allow changing CSP by more plugins +- New plugin: Use Prism for syntax highlighting ## Adminer 5.1.0 (released 2025-03-24) - Display collation at table structure if different from table diff --git a/plugins/prism.php b/plugins/prism.php new file mode 100644 index 00000000..8e3d366a --- /dev/null +++ b/plugins/prism.php @@ -0,0 +1,41 @@ + +* @link https://prismjs.com/ +* @link https://www.adminer.org/plugins/#use +* @author Jakub Vrana, https://www.vrana.cz/ +* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 +* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) +*/ +class AdminerPrism { + private $root; + private $minified; + private $theme; + + function __construct($root = "https://cdn.jsdelivr.net/npm/prismjs@1", $minified = ".min", $theme = "prism") { + $this->root = $root; + $this->minified = $minified; + $this->theme = $theme; + } + + function syntaxHighlighting($tableStatuses) { + echo "\n"; + echo Adminer\script_src("$this->root/prism$this->minified.js"); + echo Adminer\script_src("$this->root/components/prism-json$this->minified.js"); + echo Adminer\script_src("$this->root/components/prism-sql$this->minified.js"); + ?> + +