Remove submodule
This commit is contained in:
parent
f969dbb290
commit
89b74e8ef8
50 changed files with 32051 additions and 10 deletions
|
@ -1 +0,0 @@
|
|||
Subproject commit fce395c1e71920e065dbde3e184ffb61ef86996c
|
32
resources/pagedown/LICENSE.txt
Normal file
32
resources/pagedown/LICENSE.txt
Normal file
|
@ -0,0 +1,32 @@
|
|||
A javascript port of Markdown, as used on Stack Overflow
|
||||
and the rest of Stack Exchange network.
|
||||
|
||||
Largely based on showdown.js by John Fraser (Attacklab).
|
||||
|
||||
Original Markdown Copyright (c) 2004-2005 John Gruber
|
||||
<http://daringfireball.net/projects/markdown/>
|
||||
|
||||
|
||||
Original Showdown code copyright (c) 2007 John Fraser
|
||||
|
||||
Modifications and bugfixes (c) 2009 Dana Robinson
|
||||
Modifications and bugfixes (c) 2009-2011 Stack Exchange Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
1332
resources/pagedown/Markdown.Converter.js
Normal file
1332
resources/pagedown/Markdown.Converter.js
Normal file
File diff suppressed because it is too large
Load diff
2333
resources/pagedown/Markdown.Editor.js
Normal file
2333
resources/pagedown/Markdown.Editor.js
Normal file
File diff suppressed because it is too large
Load diff
108
resources/pagedown/Markdown.Sanitizer.js
Normal file
108
resources/pagedown/Markdown.Sanitizer.js
Normal file
|
@ -0,0 +1,108 @@
|
|||
(function () {
|
||||
var output, Converter;
|
||||
if (typeof exports === "object" && typeof require === "function") { // we're in a CommonJS (e.g. Node.js) module
|
||||
output = exports;
|
||||
Converter = require("./Markdown.Converter").Converter;
|
||||
} else {
|
||||
output = window.Markdown;
|
||||
Converter = output.Converter;
|
||||
}
|
||||
|
||||
output.getSanitizingConverter = function () {
|
||||
var converter = new Converter();
|
||||
converter.hooks.chain("postConversion", sanitizeHtml);
|
||||
converter.hooks.chain("postConversion", balanceTags);
|
||||
return converter;
|
||||
}
|
||||
|
||||
function sanitizeHtml(html) {
|
||||
return html.replace(/<[^>]*>?/gi, sanitizeTag);
|
||||
}
|
||||
|
||||
// (tags that can be opened/closed) | (tags that stand alone)
|
||||
var basic_tag_whitelist = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i;
|
||||
// <a href="url..." optional title>|</a>
|
||||
var a_white = /^(<a\shref="((https?|ftp):\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i;
|
||||
|
||||
// <img src="url..." optional width optional height optional alt optional title
|
||||
var img_white = /^(<img\ssrc="(https?:\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i;
|
||||
|
||||
function sanitizeTag(tag) {
|
||||
if (tag.match(basic_tag_whitelist) || tag.match(a_white) || tag.match(img_white))
|
||||
return tag;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// attempt to balance HTML tags in the html string
|
||||
/// by removing any unmatched opening or closing tags
|
||||
/// IMPORTANT: we *assume* HTML has *already* been
|
||||
/// sanitized and is safe/sane before balancing!
|
||||
///
|
||||
/// adapted from CODESNIPPET: A8591DBA-D1D3-11DE-947C-BA5556D89593
|
||||
/// </summary>
|
||||
function balanceTags(html) {
|
||||
|
||||
if (html == "")
|
||||
return "";
|
||||
|
||||
var re = /<\/?\w+[^>]*(\s|$|>)/g;
|
||||
// convert everything to lower case; this makes
|
||||
// our case insensitive comparisons easier
|
||||
var tags = html.toLowerCase().match(re);
|
||||
|
||||
// no HTML tags present? nothing to do; exit now
|
||||
var tagcount = (tags || []).length;
|
||||
if (tagcount == 0)
|
||||
return html;
|
||||
|
||||
var tagname, tag;
|
||||
var ignoredtags = "<p><img><br><li><hr>";
|
||||
var match;
|
||||
var tagpaired = [];
|
||||
var tagremove = [];
|
||||
var needsRemoval = false;
|
||||
|
||||
// loop through matched tags in forward order
|
||||
for (var ctag = 0; ctag < tagcount; ctag++) {
|
||||
tagname = tags[ctag].replace(/<\/?(\w+).*/, "$1");
|
||||
// skip any already paired tags
|
||||
// and skip tags in our ignore list; assume they're self-closed
|
||||
if (tagpaired[ctag] || ignoredtags.search("<" + tagname + ">") > -1)
|
||||
continue;
|
||||
|
||||
tag = tags[ctag];
|
||||
match = -1;
|
||||
|
||||
if (!/^<\//.test(tag)) {
|
||||
// this is an opening tag
|
||||
// search forwards (next tags), look for closing tags
|
||||
for (var ntag = ctag + 1; ntag < tagcount; ntag++) {
|
||||
if (!tagpaired[ntag] && tags[ntag] == "</" + tagname + ">") {
|
||||
match = ntag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match == -1)
|
||||
needsRemoval = tagremove[ctag] = true; // mark for removal
|
||||
else
|
||||
tagpaired[match] = true; // mark paired
|
||||
}
|
||||
|
||||
if (!needsRemoval)
|
||||
return html;
|
||||
|
||||
// delete all orphaned tags from the string
|
||||
|
||||
var ctag = 0;
|
||||
html = html.replace(re, function (match) {
|
||||
var res = tagremove[ctag] ? "" : match;
|
||||
ctag++;
|
||||
return res;
|
||||
});
|
||||
return html;
|
||||
}
|
||||
})();
|
21
resources/pagedown/README.md
Normal file
21
resources/pagedown/README.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
pagedown
|
||||
========
|
||||
|
||||
A clone of the Google code repository for StackOverflow's pagedown markdown editor.
|
||||
|
||||
This fork is intended to be used for [the site component of DMOJ: Modern Online Judge](https://github.com/DMOJ/site).
|
||||
We add features specifically for our own use. If you find these features useful, feel free to use this repository
|
||||
at your own peril, as we offer no support.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="http://dmoj.ca">
|
||||
<img src="https://avatars2.githubusercontent.com/u/6934864?v=3&s=100" align="left"></img>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
A modern online judge and contest platform system, supporting <b>IO-based</b>, <b>interactive</b>, and <b>signature-graded</b> tasks.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
119
resources/pagedown/demo/browser/demo.css
Normal file
119
resources/pagedown/demo/browser/demo.css
Normal file
|
@ -0,0 +1,119 @@
|
|||
body
|
||||
{
|
||||
background-color: White;
|
||||
}
|
||||
|
||||
.wmd-panel
|
||||
{
|
||||
margin-left: 25%;
|
||||
margin-right: 25%;
|
||||
width: 50%;
|
||||
min-width: 500px;
|
||||
}
|
||||
|
||||
.wmd-button-bar
|
||||
{
|
||||
width: 100%;
|
||||
background-color: Silver;
|
||||
}
|
||||
|
||||
.wmd-input
|
||||
{
|
||||
height: 300px;
|
||||
width: 100%;
|
||||
background-color: Gainsboro;
|
||||
border: 1px solid DarkGray;
|
||||
}
|
||||
|
||||
.wmd-preview
|
||||
{
|
||||
background-color: #c0e0ff;
|
||||
}
|
||||
|
||||
.wmd-button-row
|
||||
{
|
||||
position: relative;
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
margin-bottom: 5px;
|
||||
margin-top: 10px;
|
||||
padding: 0px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.wmd-spacer
|
||||
{
|
||||
width: 1px;
|
||||
height: 20px;
|
||||
margin-left: 14px;
|
||||
|
||||
position: absolute;
|
||||
background-color: Silver;
|
||||
display: inline-block;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.wmd-button {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
padding-left: 2px;
|
||||
padding-right: 3px;
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
list-style: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wmd-button > span {
|
||||
background-image: url(../../wmd-buttons.png);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0px 0px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.wmd-spacer1
|
||||
{
|
||||
left: 50px;
|
||||
}
|
||||
.wmd-spacer2
|
||||
{
|
||||
left: 175px;
|
||||
}
|
||||
.wmd-spacer3
|
||||
{
|
||||
left: 300px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.wmd-prompt-background
|
||||
{
|
||||
background-color: Black;
|
||||
}
|
||||
|
||||
.wmd-prompt-dialog
|
||||
{
|
||||
border: 1px solid #999999;
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
.wmd-prompt-dialog > div {
|
||||
font-size: 0.8em;
|
||||
font-family: arial, helvetica, sans-serif;
|
||||
}
|
||||
|
||||
|
||||
.wmd-prompt-dialog > form > input[type="text"] {
|
||||
border: 1px solid #999999;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.wmd-prompt-dialog > form > input[type="button"]{
|
||||
border: 1px solid #888888;
|
||||
font-family: trebuchet MS, helvetica, sans-serif;
|
||||
font-size: 0.8em;
|
||||
font-weight: bold;
|
||||
}
|
83
resources/pagedown/demo/browser/demo.html
Normal file
83
resources/pagedown/demo/browser/demo.html
Normal file
|
@ -0,0 +1,83 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>PageDown Demo Page</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="demo.css" />
|
||||
|
||||
<script type="text/javascript" src="../../Markdown.Converter.js"></script>
|
||||
<script type="text/javascript" src="../../Markdown.Sanitizer.js"></script>
|
||||
<script type="text/javascript" src="../../Markdown.Editor.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wmd-panel">
|
||||
<div id="wmd-button-bar"></div>
|
||||
<textarea class="wmd-input" id="wmd-input">
|
||||
This is the *first* editor.
|
||||
------------------------------
|
||||
|
||||
Just plain **Markdown**, except that the input is sanitized:
|
||||
|
||||
<marquee>I'm the ghost from the past!</marquee>
|
||||
</textarea>
|
||||
</div>
|
||||
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
|
||||
|
||||
<br /> <br />
|
||||
|
||||
<div class="wmd-panel">
|
||||
<div id="wmd-button-bar-second"></div>
|
||||
<textarea class="wmd-input" id="wmd-input-second">
|
||||
This is the *second* editor.
|
||||
------------------------------
|
||||
|
||||
It has a plugin hook registered that surrounds all words starting with the
|
||||
letter A with asterisks before doing the Markdown conversion. Another one gives bare links
|
||||
a nicer link text. User input isn't sanitized here:
|
||||
|
||||
<marquee>I'm the ghost from the past!</marquee>
|
||||
|
||||
http://google.com
|
||||
|
||||
http://stackoverflow.com
|
||||
|
||||
It also includes a help button.
|
||||
|
||||
Finally, note that when you press Ctrl-Q or click the "Blockquote" button (without having a
|
||||
selection), this editor creates an example text that's different from the first editor.
|
||||
</textarea>
|
||||
</div>
|
||||
<div id="wmd-preview-second" class="wmd-panel wmd-preview"></div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var converter1 = Markdown.getSanitizingConverter();
|
||||
var editor1 = new Markdown.Editor(converter1);
|
||||
editor1.run();
|
||||
|
||||
var converter2 = new Markdown.Converter();
|
||||
|
||||
converter2.hooks.chain("preConversion", function (text) {
|
||||
return text.replace(/\b(a\w*)/gi, "*$1*");
|
||||
});
|
||||
|
||||
converter2.hooks.chain("plainLinkText", function (url) {
|
||||
return "This is a link to " + url.replace(/^https?:\/\//, "");
|
||||
});
|
||||
|
||||
var help = function () { alert("Do you need help?"); }
|
||||
var options = {
|
||||
helpButton: { handler: help },
|
||||
strings: { quoteexample: "whatever you're quoting, put it right here" }
|
||||
};
|
||||
var editor2 = new Markdown.Editor(converter2, "-second", options);
|
||||
|
||||
editor2.run();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
44
resources/pagedown/demo/node/demo.js
Normal file
44
resources/pagedown/demo/node/demo.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
// NOTE: This is just a demo -- in a production environment,
|
||||
// be sure to spend a few more thoughts on sanitizing user input.
|
||||
// (also, you probably wouldn't use a get request)
|
||||
|
||||
var http = require("http"),
|
||||
url = require("url"),
|
||||
querystring = require("querystring"),
|
||||
Converter = require("../../Markdown.Converter").Converter,
|
||||
getSanitizingConverter = require("../../Markdown.Sanitizer").getSanitizingConverter,
|
||||
conv = new Converter(),
|
||||
saneConv = getSanitizingConverter();
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
|
||||
var route = url.parse(req.url);
|
||||
if (route.pathname !== "/") {
|
||||
res.writeHead(404);
|
||||
res.end("Page not found");
|
||||
return;
|
||||
}
|
||||
|
||||
var query = querystring.parse(route.query);
|
||||
|
||||
res.writeHead(200, { "Content-type": "text/html" });
|
||||
res.write("<html><body>");
|
||||
|
||||
var markdown = query.md || "## Hello!\n\n<marquee>I'm walking</marquee>\n\nVisit [Stack Overflow](http://stackoverflow.com)\n\n<b><i>This is never closed!";
|
||||
|
||||
res.write("<h1>Your output, sanitized:</h1>\n" + saneConv.makeHtml(markdown))
|
||||
res.write("<h1>Your output, unsanitized:</h1>\n" + conv.makeHtml(markdown))
|
||||
|
||||
res.write(
|
||||
"<h1>Enter Markdown</h1>\n" +
|
||||
"<form method='get' action='/'>" +
|
||||
"<textarea cols=50 rows=10 name='md'>" +
|
||||
markdown.replace(/</g, "<") +
|
||||
"</textarea><br>" +
|
||||
"<input type='submit' value='Convert!'>" +
|
||||
"</form>"
|
||||
);
|
||||
|
||||
res.end("</body></html>");
|
||||
|
||||
}).listen(8000);
|
43
resources/pagedown/local/Markdown.local.fr.js
Normal file
43
resources/pagedown/local/Markdown.local.fr.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Usage:
|
||||
//
|
||||
// var myConverter = new Markdown.Converter(myEditor, null, { strings: Markdown.local.fr });
|
||||
|
||||
(function () {
|
||||
Markdown.local = Markdown.local || {};
|
||||
Markdown.local.fr = {
|
||||
bold: "Gras <strong> Ctrl+B",
|
||||
boldexample: "texte en gras",
|
||||
|
||||
italic: "Italique <em> Ctrl+I",
|
||||
italicexample: "texte en italique",
|
||||
|
||||
link: "Hyperlien <a> Ctrl+L",
|
||||
linkdescription: "description de l'hyperlien",
|
||||
linkdialog: "<p><b>Insérer un hyperlien</b></p><p>http://example.com/ \"titre optionnel\"</p>",
|
||||
|
||||
quote: "Citation <blockquote> Ctrl+Q",
|
||||
quoteexample: "Citation",
|
||||
|
||||
code: "Extrait de code <pre><code> Ctrl+K",
|
||||
codeexample: "votre extrait de code",
|
||||
|
||||
image: "Image <img> Ctrl+G",
|
||||
imagedescription: "description de l'image",
|
||||
imagedialog: "<p><b>Insérer une image</b></p><p>http://example.com/images/diagram.jpg \"titre optionnel\"<br><br><a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>Vous chercher un hébergement d'image grauit ?</a></p>",
|
||||
|
||||
olist: "Liste numérotée <ol> Ctrl+O",
|
||||
ulist: "Liste à point <ul> Ctrl+U",
|
||||
litem: "Elément de liste",
|
||||
|
||||
heading: "Titre <h1>/<h2> Ctrl+H",
|
||||
headingexample: "Titre",
|
||||
|
||||
hr: "Trait horizontal <hr> Ctrl+R",
|
||||
|
||||
undo: "Annuler - Ctrl+Z",
|
||||
redo: "Refaire - Ctrl+Y",
|
||||
redomac: "Refaire - Ctrl+Shift+Z",
|
||||
|
||||
help: "Aide sur Markdown"
|
||||
};
|
||||
})();
|
2
resources/pagedown/node-pagedown.js
Normal file
2
resources/pagedown/node-pagedown.js
Normal file
|
@ -0,0 +1,2 @@
|
|||
exports.Converter = require("./Markdown.Converter").Converter;
|
||||
exports.getSanitizingConverter = require("./Markdown.Sanitizer").getSanitizingConverter;
|
12
resources/pagedown/package.json
Normal file
12
resources/pagedown/package.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "pagedown",
|
||||
"version": "1.0.0",
|
||||
"description": "markdown converter, based on showdown",
|
||||
"repository": { "type": "hg", "url": "https://code.google.com/p/pagedown/" },
|
||||
"keywords": ["markdown"],
|
||||
"license": "MIT",
|
||||
"files": ["Markdown.Converter.js", "Markdown.Sanitizer.js", "node-pagedown.js"],
|
||||
"main": "node-pagedown.js",
|
||||
"bugs": "http://code.google.com/p/pagedown/issues/list",
|
||||
"homepage": "http://code.google.com/p/pagedown/wiki/PageDown"
|
||||
}
|
BIN
resources/pagedown/resources/wmd-buttons.pdn
Normal file
BIN
resources/pagedown/resources/wmd-buttons.pdn
Normal file
Binary file not shown.
BIN
resources/pagedown/resources/wmd-buttons.png
Normal file
BIN
resources/pagedown/resources/wmd-buttons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
resources/pagedown/resources/wmd-buttons.psd
Normal file
BIN
resources/pagedown/resources/wmd-buttons.psd
Normal file
Binary file not shown.
BIN
resources/pagedown/wmd-buttons.png
Normal file
BIN
resources/pagedown/wmd-buttons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
Loading…
Add table
Add a link
Reference in a new issue