Support for Highlight.js. Fixes #36
This commit is contained in:
parent
1c781890a4
commit
0c54e71e2c
@ -670,6 +670,10 @@ div.dropdown-menu textarea {
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
code, pre {
|
||||
font-family: Menlo, Consolas, "Courier New", monospace;
|
||||
}
|
||||
|
||||
/* Definition list */
|
||||
dt,dd {
|
||||
margin-top: 5px;
|
||||
|
149
css/highlight.css
Normal file
149
css/highlight.css
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
|
||||
Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
|
||||
|
||||
pre code {
|
||||
display: block; padding: 0.5em;
|
||||
background: #F0F0F0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
pre code,
|
||||
pre .subst,
|
||||
pre .tag .title,
|
||||
pre .lisp .title,
|
||||
pre .clojure .built_in,
|
||||
pre .nginx .title {
|
||||
color: black;
|
||||
}
|
||||
|
||||
pre .string,
|
||||
pre .title,
|
||||
pre .constant,
|
||||
pre .parent,
|
||||
pre .tag .value,
|
||||
pre .rules .value,
|
||||
pre .rules .value .number,
|
||||
pre .preprocessor,
|
||||
pre .haml .symbol,
|
||||
pre .ruby .symbol,
|
||||
pre .ruby .symbol .string,
|
||||
pre .aggregate,
|
||||
pre .template_tag,
|
||||
pre .django .variable,
|
||||
pre .smalltalk .class,
|
||||
pre .addition,
|
||||
pre .flow,
|
||||
pre .stream,
|
||||
pre .bash .variable,
|
||||
pre .apache .tag,
|
||||
pre .apache .cbracket,
|
||||
pre .tex .command,
|
||||
pre .tex .special,
|
||||
pre .erlang_repl .function_or_atom,
|
||||
pre .asciidoc .header,
|
||||
pre .markdown .header,
|
||||
pre .coffeescript .attribute {
|
||||
color: #800;
|
||||
}
|
||||
|
||||
pre .comment,
|
||||
pre .annotation,
|
||||
pre .template_comment,
|
||||
pre .diff .header,
|
||||
pre .chunk,
|
||||
pre .asciidoc .blockquote,
|
||||
pre .markdown .blockquote {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
pre .number,
|
||||
pre .date,
|
||||
pre .regexp,
|
||||
pre .literal,
|
||||
pre .hexcolor,
|
||||
pre .smalltalk .symbol,
|
||||
pre .smalltalk .char,
|
||||
pre .go .constant,
|
||||
pre .change,
|
||||
pre .lasso .variable,
|
||||
pre .asciidoc .bullet,
|
||||
pre .markdown .bullet,
|
||||
pre .asciidoc .link_url,
|
||||
pre .markdown .link_url {
|
||||
color: #080;
|
||||
}
|
||||
|
||||
pre .label,
|
||||
pre .javadoc,
|
||||
pre .ruby .string,
|
||||
pre .decorator,
|
||||
pre .filter .argument,
|
||||
pre .localvars,
|
||||
pre .array,
|
||||
pre .attr_selector,
|
||||
pre .important,
|
||||
pre .pseudo,
|
||||
pre .pi,
|
||||
pre .haml .bullet,
|
||||
pre .doctype,
|
||||
pre .deletion,
|
||||
pre .envvar,
|
||||
pre .shebang,
|
||||
pre .apache .sqbracket,
|
||||
pre .nginx .built_in,
|
||||
pre .tex .formula,
|
||||
pre .erlang_repl .reserved,
|
||||
pre .prompt,
|
||||
pre .asciidoc .link_label,
|
||||
pre .markdown .link_label,
|
||||
pre .vhdl .attribute,
|
||||
pre .clojure .attribute,
|
||||
pre .asciidoc .attribute,
|
||||
pre .lasso .attribute,
|
||||
pre .coffeescript .property {
|
||||
color: #88F
|
||||
}
|
||||
|
||||
pre .keyword,
|
||||
pre .id,
|
||||
pre .title,
|
||||
pre .built_in,
|
||||
pre .aggregate,
|
||||
pre .css .tag,
|
||||
pre .javadoctag,
|
||||
pre .phpdoc,
|
||||
pre .yardoctag,
|
||||
pre .smalltalk .class,
|
||||
pre .winutils,
|
||||
pre .bash .variable,
|
||||
pre .apache .tag,
|
||||
pre .go .typename,
|
||||
pre .tex .command,
|
||||
pre .asciidoc .strong,
|
||||
pre .markdown .strong,
|
||||
pre .request,
|
||||
pre .status {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
pre .asciidoc .emphasis,
|
||||
pre .markdown .emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
pre .nginx .built_in {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
pre .coffeescript .javascript,
|
||||
pre .javascript .xml,
|
||||
pre .lasso .markup,
|
||||
pre .tex .formula,
|
||||
pre .xml .javascript,
|
||||
pre .xml .vbscript,
|
||||
pre .xml .css,
|
||||
pre .xml .cdata {
|
||||
opacity: 0.5;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
@import url("bootstrap.css");
|
||||
@import url("jgrowl.css");
|
||||
@import url("prettify.css");
|
||||
@import url("highlight.css");
|
||||
@import url("default.css");
|
||||
|
||||
|
||||
|
@ -1,28 +1,62 @@
|
||||
define([
|
||||
"jquery",
|
||||
"utils",
|
||||
"classes/Extension",
|
||||
"text!html/markdownExtraSettingsBlock.html",
|
||||
"libs/Markdown.Extra",
|
||||
], function(utils, Extension, markdownExtraSettingsBlockHTML) {
|
||||
], function($, utils, Extension, markdownExtraSettingsBlockHTML) {
|
||||
|
||||
var markdownExtra = new Extension("markdownExtra", "Markdown Extra", true);
|
||||
markdownExtra.settingsBlock = markdownExtraSettingsBlockHTML;
|
||||
markdownExtra.defaultConfig = {
|
||||
prettify: true
|
||||
extensions: [
|
||||
"fenced_code_gfm",
|
||||
"tables",
|
||||
"def_list",
|
||||
"attr_list",
|
||||
"footnotes"
|
||||
],
|
||||
highlighter: "prettify"
|
||||
};
|
||||
|
||||
markdownExtra.onLoadSettings = function() {
|
||||
utils.setInputChecked("#input-markdownextra-prettify", markdownExtra.config.prettify);
|
||||
function hasExtension(extensionName) {
|
||||
return _.some(markdownExtra.config.extensions, function(extension) {
|
||||
return extension == extensionName;
|
||||
});
|
||||
}
|
||||
utils.setInputChecked("#input-markdownextra-fencedcodegfm", hasExtension("fenced_code_gfm"));
|
||||
utils.setInputChecked("#input-markdownextra-tables", hasExtension("tables"));
|
||||
utils.setInputChecked("#input-markdownextra-deflist", hasExtension("def_list"));
|
||||
utils.setInputChecked("#input-markdownextra-attrlist", hasExtension("attr_list"));
|
||||
utils.setInputChecked("#input-markdownextra-footnotes", hasExtension("footnotes"));
|
||||
utils.setInputValue("#input-markdownextra-highlighter", markdownExtra.config.highlighter);
|
||||
};
|
||||
|
||||
markdownExtra.onSaveSettings = function(newConfig, event) {
|
||||
newConfig.prettify = utils.getInputChecked("#input-markdownextra-prettify");
|
||||
newConfig.extensions = [];
|
||||
utils.getInputChecked("#input-markdownextra-fencedcodegfm") && newConfig.extensions.push("fenced_code_gfm");
|
||||
utils.getInputChecked("#input-markdownextra-tables") && newConfig.extensions.push("tables");
|
||||
utils.getInputChecked("#input-markdownextra-deflist") && newConfig.extensions.push("def_list");
|
||||
utils.getInputChecked("#input-markdownextra-attrlist") && newConfig.extensions.push("attr_list");
|
||||
utils.getInputChecked("#input-markdownextra-footnotes") && newConfig.extensions.push("footnotes");
|
||||
newConfig.highlighter = utils.getInputValue("#input-markdownextra-highlighter");
|
||||
};
|
||||
|
||||
markdownExtra.onEditorConfigure = function(editor) {
|
||||
var converter = editor.getConverter();
|
||||
var options = {};
|
||||
if(markdownExtra.config.prettify === true) {
|
||||
var options = {
|
||||
extensions: markdownExtra.config.extensions
|
||||
};
|
||||
if(markdownExtra.config.highlighter == "highlight") {
|
||||
options.highlighter = "prettify";
|
||||
editor.hooks.chain("onPreviewRefresh", function() {
|
||||
$('.prettyprint').each(function(i, e) {
|
||||
hljs.highlightBlock(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
else if(markdownExtra.config.highlighter == "prettify") {
|
||||
options.highlighter = "prettify";
|
||||
editor.hooks.chain("onPreviewRefresh", prettyPrint);
|
||||
}
|
||||
|
@ -1,7 +1,3 @@
|
||||
<p>StackEdit is a free, open-source Markdown editor based on
|
||||
PageDown, the Markdown library used by Stack Overflow and the other
|
||||
Stack Exchange sites.</p>
|
||||
|
||||
<dl>
|
||||
<dt>About:</dt>
|
||||
<dd>
|
||||
|
@ -1,11 +1,45 @@
|
||||
<p>Adds extra features to the original Markdown syntax.</p>
|
||||
<div class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input-markdownextra-prettify">Prettify
|
||||
syntax highlighting</label>
|
||||
<label class="control-label" for="input-markdownextra-fencedcodegfm">GFM fenced code blocks</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" id="input-markdownextra-prettify">
|
||||
<input type="checkbox" id="input-markdownextra-fencedcodegfm">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input-markdownextra-tables">Tables</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" id="input-markdownextra-tables">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input-markdownextra-deflist">Definition lists</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" id="input-markdownextra-deflist">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input-markdownextra-attrlist">Special attributes</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" id="input-markdownextra-attrlist">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input-markdownextra-footnotes">Footnotes</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" id="input-markdownextra-footnotes">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="input-markdownextra-highlighter">Syntax
|
||||
highlighter</label>
|
||||
<div class="controls">
|
||||
<select id="input-markdownextra-highlighter"><option>None</option>
|
||||
<option value="prettify">Prettify</option>
|
||||
<option value="highlight">Highlight.js</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="help-block pull-right"><a target="_blank" href="https://github.com/jmcmanus/pagedown-extra">More info</a></span>
|
||||
<span class="help-block pull-right"><a target="_blank"
|
||||
href="https://github.com/jmcmanus/pagedown-extra">More info</a></span>
|
1
js/libs/highlight.pack.js
Normal file
1
js/libs/highlight.pack.js
Normal file
File diff suppressed because one or more lines are too long
@ -46,7 +46,8 @@ requirejs.config({
|
||||
],
|
||||
'libs/Markdown.Extra': [
|
||||
'libs/Markdown.Converter',
|
||||
'libs/prettify'
|
||||
'libs/prettify',
|
||||
'libs/highlight.pack',
|
||||
],
|
||||
'libs/Markdown.Editor': [
|
||||
'libs/Markdown.Converter'
|
||||
|
Loading…
Reference in New Issue
Block a user