Highlight added
This commit is contained in:
parent
16eac7eb20
commit
3b71c5b54c
6 changed files with 108 additions and 3 deletions
|
@ -11,8 +11,15 @@ class Post
|
|||
private static function parse_content($c){
|
||||
//$c = htmlentities($c);
|
||||
|
||||
// Highlight
|
||||
if(Config::get("highlight")){
|
||||
$c = preg_replace_callback('/\[code(?:=([^\[]+))?\](.+?)(?:(?=\[\/code\]))\[\/code\]/m', function($m){
|
||||
return '<code'.($m[1] ? ' class="'.$m[1].'"' : '').'>'.htmlentities($m[2]).'</code>';
|
||||
}, $c);
|
||||
} else {
|
||||
// Links
|
||||
$c = preg_replace('/\"([^\"]+)\"/i', "„$1\"", $c);
|
||||
}
|
||||
|
||||
$c = preg_replace('/(https?\:\/\/[^\" \n]+)/i', "<a href=\"\\0\" target=\"_blank\">\\0</a>", $c);
|
||||
//$c = preg_replace('/(\#([A-Za-z0-9-_]+))/i', "<a href=\"#tag=\\1\" class=\"tag\">\\0</a>", $c);
|
||||
|
|
|
@ -15,6 +15,8 @@ cover = static/images/cover.jpg
|
|||
[language]
|
||||
lang = en
|
||||
|
||||
highlight = true
|
||||
|
||||
[login]
|
||||
force_login = true
|
||||
nick = demo
|
||||
|
@ -22,6 +24,6 @@ pass = demo
|
|||
|
||||
[system]
|
||||
system_name = blog
|
||||
version = 1.02
|
||||
version = 1.03
|
||||
debug = true
|
||||
logs = false
|
|
@ -62,6 +62,8 @@ if(file_exists($header_path)){
|
|||
<link href="static/styles/design.css?v=<?php echo Config::get("version"); ?>" rel="stylesheet" type="text/css" />
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans&subset=all" rel="stylesheet">
|
||||
|
||||
<?php echo Config::get("highlight") ? '<link href="static/styles/highlight.css" rel="stylesheet" type="text/css" />' : ''; ?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="dd_mask" class="mask"></div>
|
||||
|
@ -294,6 +296,7 @@ if(file_exists($header_path)){
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
||||
<!--<script src="static/scripts/jquery.min.js"></script>-->
|
||||
<script>$["\x61\x6A\x61\x78\x53\x65\x74\x75\x70"]({"\x68\x65\x61\x64\x65\x72\x73":{"\x43\x73\x72\x66-\x54\x6F\x6B\x65\x6E":"<?php echo $_SESSION['token'];?>"}});</script>
|
||||
<?php echo Config::get("highlight") ? '<script src="static/scripts/highlight.js"></script><script>hljs.initHighlightingOnLoad();</script>' : ''; ?>
|
||||
<script src="static/scripts/app.js?v=<?php echo Config::get("version"); ?>"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -618,6 +618,7 @@ $.fn.post_fill = function(data){
|
|||
post.data("id", data.id);
|
||||
|
||||
post.find(".b_text").html(data.text);
|
||||
|
||||
post.find(".b_text").find(".tag").click(function(){
|
||||
var tag = $(this).text();
|
||||
tag = tag.substr(1);
|
||||
|
@ -642,6 +643,13 @@ $.fn.post_fill = function(data){
|
|||
});
|
||||
}
|
||||
|
||||
// Highlight
|
||||
if(typeof hljs !== "undefined"){
|
||||
post.find("code").each(function(i, block) {
|
||||
hljs.highlightBlock(block);
|
||||
});
|
||||
}
|
||||
|
||||
post.find(".b_feeling").html(data.feeling);
|
||||
post.find(".b_persons").html(data.persons);
|
||||
post.find(".b_location").html(data.location).click(function(){
|
||||
|
|
2
static/scripts/highlight.js
Normal file
2
static/scripts/highlight.js
Normal file
File diff suppressed because one or more lines are too long
83
static/styles/highlight.css
Normal file
83
static/styles/highlight.css
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
|
||||
Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/
|
||||
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
background: #23241f;
|
||||
}
|
||||
|
||||
.hljs,
|
||||
.hljs-tag,
|
||||
.hljs-subst {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.hljs-strong,
|
||||
.hljs-emphasis {
|
||||
color: #a8a8a2;
|
||||
}
|
||||
|
||||
.hljs-bullet,
|
||||
.hljs-quote,
|
||||
.hljs-number,
|
||||
.hljs-regexp,
|
||||
.hljs-literal,
|
||||
.hljs-link {
|
||||
color: #ae81ff;
|
||||
}
|
||||
|
||||
.hljs-code,
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-selector-class {
|
||||
color: #a6e22e;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-name,
|
||||
.hljs-attr {
|
||||
color: #f92672;
|
||||
}
|
||||
|
||||
.hljs-symbol,
|
||||
.hljs-attribute {
|
||||
color: #66d9ef;
|
||||
}
|
||||
|
||||
.hljs-params,
|
||||
.hljs-class .hljs-title {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.hljs-string,
|
||||
.hljs-type,
|
||||
.hljs-built_in,
|
||||
.hljs-builtin-name,
|
||||
.hljs-selector-id,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-pseudo,
|
||||
.hljs-addition,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable {
|
||||
color: #e6db74;
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-deletion,
|
||||
.hljs-meta {
|
||||
color: #75715e;
|
||||
}
|
Loading…
Reference in a new issue