New 'libraries' folder in root instalation directory

This commit is contained in:
Manuel Cillero 2017-08-08 18:24:12 +02:00
parent 05b6a91b0c
commit 006992b900
2267 changed files with 50 additions and 65 deletions

View file

@ -0,0 +1,161 @@
CodeMirror.defineMode("bbcodemixed", function(config) {
var settings, regs, helpers, parsers,
htmlMixedMode = CodeMirror.getMode(config, "htmlmixed"),
bbcodeMode = CodeMirror.getMode(config, "bbcode"),
settings = {
bbCodeLiteral: 'literal'
};
if (config.hasOwnProperty("bbCodeLiteral")) {
settings.bbCodeLiteral = config.bbCodeLiteral;
}
function escapeRegExp(s) {
return s.replace(/([\[\]\.\-\+\<\>\?\:\(\)\{\}])/g, '\\$1');
}
regs = {
hasLeftDelimeter: /.*\[/,
htmlHasLeftDelimeter: /[^\<\>]*\[/,
literalOpen: new RegExp(escapeRegExp("[" + settings.bbCodeLiteral + "]")),
literalClose: new RegExp(escapeRegExp("[/" + settings.bbCodeLiteral + "]"))
};
helpers = {
chain: function(stream, state, parser) {
state.tokenize = parser;
return parser(stream, state);
},
cleanChain: function(stream, state, parser) {
state.tokenize = null;
state.localState = null;
state.localMode = null;
return (typeof parser == "string") ? (parser ? parser : null) : parser(stream, state);
},
maybeBackup: function(stream, pat, style) {
pat = escapeRegExp(pat);
var cur = stream.current();
var close = cur.search(pat),
m;
if (close > - 1) stream.backUp(cur.length - close);
else if (m = cur.match(/<\/?$/)) {
stream.backUp(cur.length);
if (!stream.match(pat, false)) stream.match(cur[0]);
}
return style;
}
};
parsers = {
html: function(stream, state) {
if (!state.inLiteral && stream.match(regs.htmlHasLeftDelimeter, false) && state.htmlMixedState.htmlState.tagName === null) {
state.tokenize = parsers.bbcode;
state.localMode = bbcodeMode;
state.localState = bbcodeMode.startState(htmlMixedMode.indent(state.htmlMixedState, ""));
return helpers.maybeBackup(stream, "[", bbcodeMode.token(stream, state.localState));
} else if (!state.inLiteral && stream.match("[", false)) {
state.tokenize = parsers.bbcode;
state.localMode = bbcodeMode;
state.localState = bbcodeMode.startState(htmlMixedMode.indent(state.htmlMixedState, ""));
return helpers.maybeBackup(stream, "[", bbcodeMode.token(stream, state.localState));
}
return htmlMixedMode.token(stream, state.htmlMixedState);
},
bbcode: function(stream, state) {
if (stream.match("]", false)) {
stream.eat("]");
state.tokenize = parsers.html;
state.localMode = htmlMixedMode;
state.localState = state.htmlMixedState;
return "tag";
//return bbcodeMode.token(stream, state);
}
return helpers.maybeBackup(stream, "]", bbcodeMode.token(stream, state.localState));
},
inBlock: function(style, terminator) {
return function(stream, state) {
while (!stream.eol()) {
if (stream.match(terminator)) {
helpers.cleanChain(stream, state, "");
break;
}
stream.next();
}
return style;
};
}
};
return {
startState: function() {
var state = htmlMixedMode.startState();
return {
token: parsers.html,
localMode: null,
localState: null,
htmlMixedState: state,
tokenize: null,
inLiteral: false
};
},
copyState: function(state) {
var local = null, tok = (state.tokenize || state.token);
if (state.localState) {
local = CodeMirror.copyState((tok != parsers.html ? bbcodeMode : htmlMixedMode), state.localState);
}
return {
token: state.token,
tokenize: state.tokenize,
localMode: state.localMode,
localState: local,
htmlMixedState: CodeMirror.copyState(htmlMixedMode, state.htmlMixedState),
inLiteral: state.inLiteral
};
},
token: function(stream, state) {
if (stream.match("[", false)) {
if (!state.inLiteral && stream.match(regs.literalOpen, true)) {
state.inLiteral = true;
return "keyword";
} else if (state.inLiteral && stream.match(regs.literalClose, true)) {
state.inLiteral = false;
return "keyword";
}
}
if (state.inLiteral && state.localState != state.htmlMixedState) {
state.tokenize = parsers.html;
state.localMode = htmlMixedMode;
state.localState = state.htmlMixedState;
}
var style = (state.tokenize || state.token)(stream, state);
return style;
},
indent: function(state, textAfter) {
if (state.localMode == bbcodeMode
|| (state.inLiteral && !state.localMode)
|| regs.hasLeftDelimeter.test(textAfter)) {
return CodeMirror.Pass;
}
return htmlMixedMode.indent(state.htmlMixedState, textAfter);
},
innerMode: function(state) {
return {
state: state.localState || state.htmlMixedState,
mode: state.localMode || htmlMixedMode
};
}
};
}, "xml", "javascript", "css");
CodeMirror.defineMIME("text/x-bbcode", "bbcodemixed");
// vim: et ts=2 sts=2 sw=2

View file

@ -0,0 +1,128 @@
<!doctype html>
<title>CodeMirror: BBCode mixed mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../mode/xml/xml.js"></script>
<script src="../../mode/javascript/javascript.js"></script>
<script src="../../mode/css/css.js"></script>
<script src="../../mode/htmlmixed/htmlmixed.js"></script>
<script src="../../mode/bbcode/bbcode.js"></script>
<script src="../../mode/bbcodemixed/bbcodemixed.js"></script>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">BBCode mixed</a>
</ul>
</div>
<article>
<h2>BBCode mixed mode</h2>
<form><textarea id="code" name="code">
[literal]
<script type="text/javascript">//<![CDATA[
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
mode : "bbcodemixed",
tabSize : 2,
indentUnit : 2,
indentWithTabs : false,
lineNumbers : true
});
// ]]>
</script>
[/literal]
<style>
/* CSS content
[b]bbcode[/b] */
.some-class { font-weight: bolder; color: "orange"; }
</style>
[*] item [:-)]
Normal text [b]Bold text[/b] [i]italic[/i] [s]strikethrough[/s]
[hr]
<strong>[url]http://domain.com[/url]</strong>
<div>
[url=http://domain.com?a=1&amp;b=2]<span>Link</span>[/url]
</div>
[img]http://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Go-home.svg/100px-Go-home.svg.png[/img]
[quote]quoted text[/quote]
[code]monospaced text[/code]
[size=15]Large Text[/size]
[color=red]Red Text[/color]
or
[color=#FF0000]Red Text[/color]
or
[color=FF0000]Red Text[/color]
[list] [*]Entry 1 [*]Entry 2 [/list]
[list] *Entry 1 *Entry 2 [/list]
[table] [tr] [td]table data[/td] [/tr] [/table]
<h2>this is H2 tag</h2>
<p>This is a part of one snippet</p>
<div id="homeBlocks" class="clearfix">
<div id="bioBlock" class="placed featured-image-wrapper brick">
<div class="caption">[home_content]</div>
</div>
[pageImage type="medium" link="url" show="99" form="home-images" xhtml="yes"]
</div>
[if_data]
<div class="contact-bar hidden-phone pull-right">
<!-- <span class="sitePhone"><b>CALL NOW: [sitePhone]</b></span> -->
%%[contactBar]%%
</div><!-- END contact-bar -->
[/if_data]
[if_data][contactBar][/if_data]
[if_data]soemthing here %%[contactBar]%% and after[/if_data]
[if_data]<div class="contact-bar hidden-phone pull-right"><!-- <span
class="sitePhone"><b>CALL NOW: [sitePhone]</b></span>
-->%%[contactBar]%%</div><!-- END contact-bar -->[/if_data]
[if_data]<img src="%%[logoPath]%%" alt="[siteTitle]"
/>[else_if_data][siteTitle][/if_data]
</textarea></form>
<script type="text/javascript">
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
mode : "bbcodemixed",
tabSize : 2,
indentUnit : 2,
indentWithTabs : false,
lineNumbers : true,
matchBrackets : true
});
</script>
<p>The BBCodeMixed mixed mode depends on the BBCode and HTML mixed modes. HTML
mixed mode itself depends on XML, JavaScript, and CSS modes.</p>
<p>It takes the same options, as BBCode and HTML mixed modes.</p>
<p><strong>MIME types defined:</strong> <code>text/x-bbcode</code>.</p>
</article>
<!-- vim: set et ts=2 sts=2 sw=2: -->