-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdownify.php
72 lines (61 loc) · 2.55 KB
/
markdownify.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
<?php
// Copyright (c) 2016-2017 Andrea Zanellato
// This file may be used and distributed under the terms of the public license.
class YellowMarkdownify
{
const Version = "0.0.1";
var $yellow;
// Handle initialisation
function onLoad($yellow)
{
$this->yellow = $yellow;
// jQuery
if(!$this->yellow->config->isExisting("jqueryCdn"))
{
$this->yellow->config->setDefault("jqueryCdn",
"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/");
}
// Codemirror
$this->yellow->config->setDefault("codeMirrorCdn",
"https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.16.0/");
// Marked Markdown Parser
$this->yellow->config->setDefault("markedCdn",
"https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/");
// Markdownify
$this->yellow->config->setDefault("markdownifyCdn",
"https://cdn.rawgit.com/tibastral/markdownify/master/lib/");
}
// Handle page extra HTML data
function onExtra($name)
{
$output = NULL;
if($name == "header")
{
$jqCDN = $this->yellow->config->get("jqueryCdn");
$cmCdn = $this->yellow->config->get("codeMirrorCdn");
$mkdCdn = $this->yellow->config->get("markedCdn");
$mdfCdn = $this->yellow->config->get("markdownifyCdn");
$mdfPth = $this->yellow->config->get("serverBase").
$this->yellow->config->get("pluginLocation");
// jQuery
$output .= "<script type=\"text/javascript\" src=\"{$jqCDN}jquery.min.js\"></script>\n";
// Codemirror Code Editor
$output .= "<script type=\"text/javascript\" src=\"{$cmCdn}codemirror.min.js\"></script>\n";
$output .= "<script type=\"text/javascript\" src=\"{$cmCdn}addon/edit/continuelist.min.js\"></script>\n";
$output .= "<script type=\"text/javascript\" src=\"{$cmCdn}addon/display/autorefresh.min.js\"></script>\n";
$output .= "<script type=\"text/javascript\" src=\"{$cmCdn}mode/xml/xml.min.js\"></script>\n";
$output .= "<script type=\"text/javascript\" src=\"{$cmCdn}mode/markdown/markdown.js\"></script>\n";
$output .= "<link rel=\"stylesheet\" href=\"{$cmCdn}codemirror.min.css\">\n";
// Marked Markdown Parser
$output .= "<script type=\"text/javascript\" src=\"{$mkdCdn}marked.min.js\"></script>\n";
// Markdownify
$output .= "<script type=\"text/javascript\" src=\"{$mdfCdn}jquery.markdownify.js\"></script>\n";
$output .= "<link rel=\"stylesheet\" href=\"{$mdfCdn}jquery.markdownify.css\">\n";
// Plugin
$output .= "<script type=\"text/javascript\" src=\"{$mdfPth}markdownify.js\"></script>\n";
}
return $output;
}
}
$yellow->plugins->register("markdownify", "YellowMarkdownify", YellowMarkdownify::Version);
?>