Implement syntax highlighting
This commit is contained in:
parent
d60fd4abf3
commit
7c7a465966
|
@ -76,6 +76,7 @@ function loadConfig() {
|
||||||
'file_icons',
|
'file_icons',
|
||||||
'footer',
|
'footer',
|
||||||
'stylesheets',
|
'stylesheets',
|
||||||
|
'code_stylesheets',
|
||||||
'additional_javascript',
|
'additional_javascript',
|
||||||
'markup',
|
'markup',
|
||||||
'custom_pages',
|
'custom_pages',
|
||||||
|
@ -1515,9 +1516,17 @@ function buildJavascript() {
|
||||||
'uri' => addslashes((!empty($uri) ? $config['uri_stylesheets'] : '') . $uri));
|
'uri' => addslashes((!empty($uri) ? $config['uri_stylesheets'] : '') . $uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$code_stylesheets = array();
|
||||||
|
foreach ($config['code_stylesheets'] as $name => $uri) {
|
||||||
|
$code_stylesheets[] = array(
|
||||||
|
'name' => addslashes($name),
|
||||||
|
'uri' => addslashes((!empty($uri) ? $config['uri_stylesheets'] : '') . $uri));
|
||||||
|
}
|
||||||
|
|
||||||
$script = Element('main.js', array(
|
$script = Element('main.js', array(
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'stylesheets' => $stylesheets
|
'stylesheets' => $stylesheets,
|
||||||
|
'code_stylesheets' => $code_stylesheets
|
||||||
));
|
));
|
||||||
|
|
||||||
// Check if we have translation for the javascripts; if yes, we add it to additional javascripts
|
// Check if we have translation for the javascripts; if yes, we add it to additional javascripts
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
function styleCode() {
|
||||||
|
$('pre').each(function() {
|
||||||
|
if (!$(this).hasClass('prettyprint')) {
|
||||||
|
$(this).addClass('prettyprint');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
prettyPrint();
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function() {styleCode();});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,141 @@
|
||||||
|
/* Tomorrow Night Eighties Theme */
|
||||||
|
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||||
|
.prettyprint {
|
||||||
|
background: #2d2d2d;
|
||||||
|
font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pln {
|
||||||
|
color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen {
|
||||||
|
.str {
|
||||||
|
color: #99cc99;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kwd {
|
||||||
|
color: #cc99cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.com {
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typ {
|
||||||
|
color: #6699cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lit {
|
||||||
|
color: #f99157;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pun {
|
||||||
|
color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.opn {
|
||||||
|
color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clo {
|
||||||
|
color: #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
color: #f2777a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.atn {
|
||||||
|
color: #f99157;
|
||||||
|
}
|
||||||
|
|
||||||
|
.atv {
|
||||||
|
color: #66cccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dec {
|
||||||
|
color: #f99157;
|
||||||
|
}
|
||||||
|
|
||||||
|
.var {
|
||||||
|
color: #f2777a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fun {
|
||||||
|
color: #6699cc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media print, projection {
|
||||||
|
.str {
|
||||||
|
color: #006600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kwd {
|
||||||
|
color: #006;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.com {
|
||||||
|
color: #600;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typ {
|
||||||
|
color: #404;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lit {
|
||||||
|
color: #004444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pun, .opn, .clo {
|
||||||
|
color: #444400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
color: #006;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.atn {
|
||||||
|
color: #440044;
|
||||||
|
}
|
||||||
|
|
||||||
|
.atv {
|
||||||
|
color: #006600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Specify class=linenums on a pre to get line numbering */
|
||||||
|
ol.linenums {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IE indents via margin-left */
|
||||||
|
li.L0,
|
||||||
|
li.L1,
|
||||||
|
li.L2,
|
||||||
|
li.L3,
|
||||||
|
li.L4,
|
||||||
|
li.L5,
|
||||||
|
li.L6,
|
||||||
|
li.L7,
|
||||||
|
li.L8,
|
||||||
|
li.L9 {
|
||||||
|
/* */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternate shading for lines */
|
||||||
|
li.L1,
|
||||||
|
li.L3,
|
||||||
|
li.L5,
|
||||||
|
li.L7,
|
||||||
|
li.L9 {
|
||||||
|
/* */
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
/* Tomorrow Theme */
|
||||||
|
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||||
|
.prettyprint {
|
||||||
|
background: white;
|
||||||
|
font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pln {
|
||||||
|
color: #4d4d4c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen {
|
||||||
|
.str {
|
||||||
|
color: #718c00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kwd {
|
||||||
|
color: #8959a8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.com {
|
||||||
|
color: #8e908c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typ {
|
||||||
|
color: #4271ae;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lit {
|
||||||
|
color: #f5871f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pun {
|
||||||
|
color: #4d4d4c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.opn {
|
||||||
|
color: #4d4d4c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clo {
|
||||||
|
color: #4d4d4c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
color: #c82829;
|
||||||
|
}
|
||||||
|
|
||||||
|
.atn {
|
||||||
|
color: #f5871f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.atv {
|
||||||
|
color: #3e999f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dec {
|
||||||
|
color: #f5871f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.var {
|
||||||
|
color: #c82829;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fun {
|
||||||
|
color: #4271ae;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media print, projection {
|
||||||
|
.str {
|
||||||
|
color: #006600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kwd {
|
||||||
|
color: #006;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.com {
|
||||||
|
color: #600;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typ {
|
||||||
|
color: #404;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lit {
|
||||||
|
color: #004444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pun, .opn, .clo {
|
||||||
|
color: #444400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
color: #006;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.atn {
|
||||||
|
color: #440044;
|
||||||
|
}
|
||||||
|
|
||||||
|
.atv {
|
||||||
|
color: #006600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Specify class=linenums on a pre to get line numbering */
|
||||||
|
ol.linenums {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IE indents via margin-left */
|
||||||
|
li.L0,
|
||||||
|
li.L1,
|
||||||
|
li.L2,
|
||||||
|
li.L3,
|
||||||
|
li.L4,
|
||||||
|
li.L5,
|
||||||
|
li.L6,
|
||||||
|
li.L7,
|
||||||
|
li.L8,
|
||||||
|
li.L9 {
|
||||||
|
/* */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternate shading for lines */
|
||||||
|
li.L1,
|
||||||
|
li.L3,
|
||||||
|
li.L5,
|
||||||
|
li.L7,
|
||||||
|
li.L9 {
|
||||||
|
/* */
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
|
||||||
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %}
|
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %}
|
||||||
{% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %}
|
{% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %}
|
||||||
|
{% if config.default_code_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="code_stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_code_stylesheet.1 }}">{% endif %}
|
||||||
{% if config.font_awesome %}<link rel="stylesheet" href="{{ config.root }}{{ config.font_awesome_css }}">{% endif %}
|
{% if config.font_awesome %}<link rel="stylesheet" href="{{ config.root }}{{ config.font_awesome_css }}">{% endif %}
|
||||||
{% if config.country_flags_condensed %}<link rel="stylesheet" href="{{ config.root }}{{ config.country_flags_condensed_css }}">{% endif %}
|
{% if config.country_flags_condensed %}<link rel="stylesheet" href="{{ config.root }}{{ config.country_flags_condensed_css }}">{% endif %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
|
@ -31,6 +31,11 @@ var styles = {
|
||||||
{% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
|
{% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
|
||||||
{% endraw %}{% endfor %}{% raw %}
|
{% endraw %}{% endfor %}{% raw %}
|
||||||
};
|
};
|
||||||
|
var codestyles = {
|
||||||
|
{% endraw %}
|
||||||
|
{% for stylesheet in code_stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
|
||||||
|
{% endraw %}{% endfor %}{% raw %}
|
||||||
|
};
|
||||||
var board_name = false;
|
var board_name = false;
|
||||||
|
|
||||||
function changeStyle(styleName, link) {
|
function changeStyle(styleName, link) {
|
||||||
|
@ -45,6 +50,7 @@ function changeStyle(styleName, link) {
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% raw %}
|
{% raw %}
|
||||||
|
|
||||||
|
// Main stylesheet
|
||||||
if (!document.getElementById('stylesheet')) {
|
if (!document.getElementById('stylesheet')) {
|
||||||
var s = document.createElement('link');
|
var s = document.createElement('link');
|
||||||
s.rel = 'stylesheet';
|
s.rel = 'stylesheet';
|
||||||
|
@ -53,9 +59,21 @@ function changeStyle(styleName, link) {
|
||||||
var x = document.getElementsByTagName('head')[0];
|
var x = document.getElementsByTagName('head')[0];
|
||||||
x.appendChild(s);
|
x.appendChild(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('stylesheet').href = styles[styleName];
|
document.getElementById('stylesheet').href = styles[styleName];
|
||||||
selectedstyle = styleName;
|
selectedstyle = styleName;
|
||||||
|
|
||||||
|
// Code stylesheet
|
||||||
|
if (!document.getElementById('code_stylesheet')) {
|
||||||
|
var s = document.createElement('link');
|
||||||
|
s.rel = 'stylesheet';
|
||||||
|
s.type = 'text/css';
|
||||||
|
s.id = 'code_stylesheet';
|
||||||
|
var x = document.getElementsByTagName('head')[0];
|
||||||
|
x.appendChild(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('code_stylesheet').href = codestyles[styleName];
|
||||||
|
|
||||||
if (document.getElementsByClassName('styles').length != 0) {
|
if (document.getElementsByClassName('styles').length != 0) {
|
||||||
var styleLinks = document.getElementsByClassName('styles')[0].childNodes;
|
var styleLinks = document.getElementsByClassName('styles')[0].childNodes;
|
||||||
|
|
Loading…
Reference in New Issue