forked from mossadal/xmd-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.php
96 lines (82 loc) · 2.45 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php namespace Mossadal\ExtendMarkdown;
use Backend;
use Controller;
use System\Classes\PluginBase;
use October\Rain\Support\MarkdownData;
use Mossadal\ExtendMarkdown\Models\Rule;
use Mossadal\ExtendMarkdown\Classes\Hooks;
use System\Classes\SettingsManager;
use Event;
/**
* ExtendMarkdown Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Returns information about this plugin.
*
* @return array
*/
public function pluginDetails()
{
return [
'name' => 'mossadal.extendmarkdown::lang.plugin.name',
'description' => 'mossadal.extendmarkdown::lang.plugin.description',
'author' => 'Frank Wikström, Mossadal konsult och design AB',
'icon' => 'icon-user-md'
];
}
public function boot()
{
Event::listen('markdown.beforeParse', function($data) {
Hooks::preMarkdownHook($data);
});
Event::listen('markdown.parse', function($original, $data) {
Hooks::postMarkdownHook($original, $data);
});
}
/**
* Filter to apply the replacement rules specified in the plugin page.
* By default, the database is seeded with some rules to handle
* Parsedown/MathJax conflicts.
* @param string $text The text to parse using Parsedown together with the user defined shortcuts
* @return string Html generated by the parser
*/
public function xmd($text)
{
$data = new MarkdownData($text);
Hooks::preMarkdownhook($data);
Hooks::postMarkdownhook($text, $data);
return $data->text;
}
/**
* Register the extended Markdown parser as a Twig filter.
*
* @return void
*/
public function registerMarkupTags()
{
return [
'filters' => [
'xmd' => [$this, 'xmd']
]
];
}
/**
* Define the backend menus
* @return void
*/
public function registerSettings()
{
return [
'definitions' => [
'label' => 'mossadal.extendmarkdown::lang.navigation.label',
'description' => 'mossadal.extendmarkdown::lang.navigation.description',
'url' => Backend::url('mossadal/extendmarkdown/rule'),
'icon' => 'icon-user-md',
'order' => 700,
'category' => SettingsManager::CATEGORY_CMS,
]
];
}
}