Importing project into Git

This project lived only on the server without version control. This is now the starting point for the repository.
This commit is contained in:
Emi
2023-05-23 20:03:24 +02:00
commit 07ec659385
1190 changed files with 140706 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

View File

@@ -0,0 +1,43 @@
Markdown Editor plugin for Question2Answer
=================================================
This is an editor plugin for popular open source Q&A platform, [Question2Answer](http://www.question2answer.org). It uses Markdown to format posts, which is a simple text-friendly markup language using for example \*\*bold\*\* for **bold text** or \> for quoting sources.
The plugin uses modified versions of the PageDown scripts (released by Stack Overflow) for the editor and live preview respectively.
Installation
-------------------------------------------------
1. Download and extract the `markdown-editor` folder to the `qa-plugins` folder in your Q2A installation.
2. If your site is a different language from English, copy `qa-md-lang-default.php` to the required language code (e.g. `qa-tt-lang-de.php` for German) and edit the phrases for your language.
3. Log in to your Q2A site as a Super Administrator and head to Admin > Posting.
4. Set the default editor for questions and answers to 'Markdown Editor'. The editor does also work for comments, but keeping to plain text is recommended.
In Admin > Plugins, you can set three options:
- "Don't add CSS inline" - this will not output the CSS onto the page, to allow putting it in a stylesheet instead which is more efficient. Copy the CSS from `pagedown/wmd.css` to the bottom of your theme's current stylesheet.
- "Plaintext comments" - Sets a post as plaintext when converting answers to comments.
- "Use syntax highlighting" - Integrates [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) for code blocks (including while writing posts). All common programming languages are supported, but you can add more using the [customized download here](http://softwaremaniacs.org/soft/highlight/en/download/). Save the file and overwrite `pagedown/highlight.min.js`. If you ticked the box for CSS above, copy the CSS from `pagedown/highlightjs.css` to the bottom of your theme's current stylesheet.
Extra bits
-------------------------------------------------
**Converting old posts:** If you have been running your Q2A site for a little while, you may wish to convert old content to Markdown. This does not work reliably for HTML content (created via the WYSIWYG editor); it is pretty safe for plain text content, but check your posts afterwards as some formatting may go awry. You can convert text posts automatically using this SQL query:
UPDATE qa_posts SET format='markdown' WHERE format='' AND type IN ('Q', 'A', 'Q_HIDDEN', 'A_HIDDEN')
(Make sure to change `qa_` above to your installation's table prefix if it is different.)
Pay What You Like
-------------------------------------------------
Most of my code is released under the open source GPLv3 license, and provided with a 'Pay What You Like' approach. Feel free to download and modify the plugins/themes to suit your needs, and I hope you value them enough to make a small donation of a few dollars or more.
### [Donate here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4R5SHBNM3UDLU)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"name": "Markdown Editor",
"uri": "https://github.com/svivian/q2a-markdown-editor",
"description": "Markdown editor plugin for simple text-based markup",
"version": "2.3.2",
"date": "2015-07-30",
"author": "Scott Vivian",
"author_uri": "http://codelair.com",
"license": "GPLv3",
"update_uri": "https://raw.githubusercontent.com/svivian/q2a-markdown-editor/master/metadata.json",
"min_q2a": "1.5",
"min_php": "5.2"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View 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;
}
})();

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
$(function() {
$('.wmd-input').keypress(function() {
window.clearTimeout(hljs.Timeout);
hljs.Timeout = window.setTimeout(function() {
hljs.initHighlighting.called = false;
hljs.initHighlighting();
}, 500);
});
window.setTimeout(function() {
hljs.initHighlighting.called = false;
hljs.initHighlighting();
}, 500);
});

View File

@@ -0,0 +1,116 @@
/* HighlightJS styles */
pre code,
pre .ruby .subst,
pre .tag .title,
pre .lisp .title,
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 .ruby .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .instancevar,
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 .markdown .header {
color: #800;
}
pre .comment,
pre .annotation,
pre .template_comment,
pre .diff .header,
pre .chunk,
pre .markdown .blockquote {
color: #888;
}
pre .number,
pre .date,
pre .regexp,
pre .literal,
pre .smalltalk .symbol,
pre .smalltalk .char,
pre .go .constant,
pre .change,
pre .markdown .bullet,
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 .doctype,
pre .deletion,
pre .envvar,
pre .shebang,
pre .apache .sqbracket,
pre .nginx .built_in,
pre .tex .formula,
pre .erlang_repl .reserved,
pre .input_number,
pre .markdown .link_label,
pre .vhdl .attribute {
color: #88f;
}
pre .keyword,
pre .id,
pre .phpdoc,
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 .markdown .strong,
pre .request,
pre .status {
font-weight: bold;
}
pre .markdown .emphasis {
font-style: italic;
}
pre .nginx .built_in {
font-weight: normal;
}
pre .coffeescript .javascript,
pre .xml .css,
pre .xml .javascript,
pre .xml .vbscript,
pre .tex .formula {
opacity: 0.5;
}

View File

@@ -0,0 +1,64 @@
var Markdown;Markdown="object"===typeof exports&&"function"===typeof require?exports:{};
(function(){function o(g){return g}function x(){return!1}function t(){}function l(){}t.prototype={chain:function(g,l){var p=this[g];if(!p)throw Error("unknown hook "+g);this[g]=p===o?l:function(g){return l(p(g))}},set:function(g,l){if(!this[g])throw Error("unknown hook "+g);this[g]=l},addNoop:function(g){this[g]=o},addFalse:function(g){this[g]=x}};Markdown.HookCollection=t;l.prototype={set:function(g,l){this["s_"+g]=l},get:function(g){return this["s_"+g]}};Markdown.Converter=function(){function g(a){return a=
a.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm,function(a,q,b,c,f,y){q=q.toLowerCase();C.set(q,d(b));if(f)return c;y&&E.set(q,y.replace(/"/g,"&quot;"));return""})}function o(a){a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,p);a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,
p);a=a.replace(/\n[ ]{0,3}((<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,p);a=a.replace(/\n\n[ ]{0,3}(<!(--(?:|(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>[ \t]*(?=\n{2,}))/g,p);return a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,p)}function p(a,b){var d;d=b.replace(/^\n+/,"");d=d.replace(/\n+$/g,"");return d="\n\n~K"+(I.push(d)-1)+"K\n\n"}function x(a,d){a=r(a);a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,"<hr />\n");a=a.replace(/^[ ]{0,2}([ ]?-[ ]?){3,}[ \t]*$/gm,"<hr />\n");a=
a.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm,"<hr />\n");a=e(a);a=F(a);a=b(a);a=o(a);return a=c(a,d)}function z(a){a=h(a);a=G(a);a=a.replace(/\\(\\)/g,w);a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,w);a=a.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,u);a=a.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,u);a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,D);a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?((?:\([^)]*\)|[^()])*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,
D);a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,D);a=f(a);a=a.replace(/~P/g,"://");a=d(a);a=a.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g,"$1<strong>$3</strong>$4");a=a.replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g,"$1<em>$3</em>$4");return a=a.replace(/\n/g,"<br>\n")}function G(a){return a=a.replace(/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--(?:|(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>)/gi,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=j(b,"!"==a.charAt(1)?
"\\`*_/":"\\`*_")})}function D(a,b,d,c,f,i,y,n){void 0==n&&(n="");a=d.replace(/:\/\//g,"~P");c=c.toLowerCase();if(""==f)if(""==c&&(c=a.toLowerCase().replace(/ ?\n/g," ")),void 0!=C.get(c))f=C.get(c),void 0!=E.get(c)&&(n=E.get(c));else if(-1<b.search(/\(\s*\)$/m))f="";else return b;f=s(f);f=j(f,"*_");b='<a href="'+f+'"';""!=n&&(n=k(n),n=j(n,"*_"),b+=' title="'+n+'"');return b+(">"+a+"</a>")}function k(a){return a.replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function u(a,b,d,c,f,
n,y,i){a=d;c=c.toLowerCase();i||(i="");if(""==f)if(""==c&&(c=a.toLowerCase().replace(/ ?\n/g," ")),void 0!=C.get(c))f=C.get(c),void 0!=E.get(c)&&(i=E.get(c));else return b;a=j(k(a),"*_[]()");f=j(f,"*_");b='<img src="'+f+'" alt="'+a+'"';i=k(i);i=j(i,"*_");return b+(' title="'+i+'"')+" />"}function r(a){a=a.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(a,b){return"<h2>"+z(b)+"</h2>\n\n"});a=a.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(a,b){return"<h3>"+z(b)+"</h3>\n\n"});return a=a.replace(/^(\#{1,5})[ \t]*(.+?)[ \t]*\#*\n+/gm,
function(a,b,c){a=b.length+1;return"<h"+a+">"+z(c)+"</h"+a+">\n\n"})}function e(a){var a=a+"~0",b=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;n?a=a.replace(b,function(a,b,c){a=-1<c.search(/[*+-]/g)?"ul":"ol";b=m(b,a);b=b.replace(/\s+$/,"");return"<"+a+">"+b+"</"+a+">\n"}):(b=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,a=a.replace(b,function(a,b,c,d){a=-1<d.search(/[*+-]/g)?"ul":"ol";c=m(c,
a);return b+"<"+a+">\n"+c+"</"+a+">\n"}));return a=a.replace(/~0/,"")}function m(a,b){n++;var a=a.replace(/\n{2,}$/,"\n"),c=N[b],d=!1,a=(a+"~0").replace(RegExp("(^[ \\t]*)("+c+")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1("+c+")[ \\t]+))","gm"),function(a,b,c,f){a=f;(b=/\n\n$/.test(a))||-1<a.search(/\n{2,}/)||d?a=x(L(a),!0):(a=e(L(a)),a=a.replace(/\n$/,""),a=z(a));d=b;return"<li>"+a+"</li>\n"}),a=a.replace(/~0/g,"");n--;return a}function F(b){b=(b+"~0").replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
function(b,c,d){b=a(L(c));b=B(b);b=b.replace(/^\n+/g,"");b=b.replace(/\n+$/g,"");return"\n\n"+("<pre><code>"+b+"\n</code></pre>")+"\n\n"+d});return b=b.replace(/~0/,"")}function M(a){a=a.replace(/(^\n+|\n+$)/g,"");return"\n\n~K"+(I.push(a)-1)+"K\n\n"}function h(b){return b=b.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(b,c,d,f){b=f.replace(/^([ \t]*)/g,"");b=b.replace(/[ \t]*$/g,"");b=a(b);b=b.replace(/:\/\//g,"~P");return c+"<code>"+b+"</code>"})}function a(a){a=a.replace(/&/g,"&amp;");
a=a.replace(/</g,"&lt;");a=a.replace(/>/g,"&gt;");return a=j(a,"*_{}[]\\",!1)}function b(a){return a=a.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,b){var c;c=b.replace(/^[ \t]*>[ \t]?/gm,"~0");c=c.replace(/~0/g,"");c=c.replace(/^[ \t]+$/gm,"");c=x(c);c=c.replace(/(^|\n)/g,"$1 ");c=c.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(a,b){var c;c=b.replace(/^ /mg,"~0");return c=c.replace(/~0/g,"")});return M("<blockquote>\n"+c+"\n</blockquote>")})}function c(a,b){for(var a=a.replace(/^\n+/g,
""),a=a.replace(/\n+$/g,""),c=a.split(/\n{2,}/g),d=[],f=/~K(\d+)K/,j=c.length,y=0;y<j;y++){var i=c[y];f.test(i)?d.push(i):/\S/.test(i)&&(i=z(i),i=i.replace(/^([ \t]*)/g,"<p>"),i+="</p>",d.push(i))}if(!b){j=d.length;for(y=0;y<j;y++)for(var n=!0;n;)n=!1,d[y]=d[y].replace(/~K(\d+)K/g,function(a,b){n=!0;return I[b]})}return d.join("\n\n")}function d(a){a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;");return a=a.replace(/<(?![a-z\/?\$!])/gi,"&lt;")}function f(a){a=a.replace(/(^|\s)(https?|ftp)(:\/\/[-A-Z0-9+&@#\/%?=~_|\[\]\(\)!:,\.;]*[-A-Z0-9+&@#\/%=~_|\[\]])($|\W)/gi,
"$1<$2$3>$4");return a=a.replace(/<((https?|ftp):[^'">\s]+)>/gi,function(a,b){return'<a href="'+b+'">'+v.plainLinkText(b)+"</a>"})}function i(a){return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)})}function L(a){a=a.replace(/^(\t|[ ]{1,4})/gm,"~0");return a=a.replace(/~0/g,"")}function B(a){if(!/\t/.test(a))return a;var b=[" "," "," "," "],c=0,d;return a.replace(/[\n\t]/g,function(a,f){if("\n"===a)return c=f+1,a;d=(f-c)%4;c=f+1;return b[d]})}function s(a){if(!a)return"";
var b=a.length;return a.replace(O,function(c,d){return"~D"==c?"%24":":"==c&&(d==b-1||/[0-9\/]/.test(a.charAt(d+1)))?":":"%"+c.charCodeAt(0).toString(16)})}function j(a,b,c){b="(["+b.replace(/([\[\]\\])/g,"\\$1")+"])";c&&(b="\\\\"+b);return a=a.replace(RegExp(b,"g"),w)}function w(a,b){return"~E"+b.charCodeAt(0)+"E"}var v=this.hooks=new t;v.addNoop("plainLinkText");v.addNoop("preConversion");v.addNoop("postConversion");var C,E,I,n;this.makeHtml=function(a){if(C)throw Error("Recursive call to converter.makeHtml");
C=new l;E=new l;I=[];n=0;a=v.preConversion(a);a=a.replace(/~/g,"~T");a=a.replace(/\$/g,"~D");a=a.replace(/\r\n/g,"\n");a=a.replace(/\r/g,"\n");a=B("\n\n"+a+"\n\n");a=a.replace(/^[ \t]+$/mg,"");a=o(a);a=g(a);a=x(a);a=i(a);a=a.replace(/~D/g,"$$");a=a.replace(/~T/g,"~");a=v.postConversion(a);I=E=C=null;return a};var N={ol:"\\d+[.]",ul:"[*+-]"},O=/(?:["'*()[\]:]|~D)/g}})();
(function(){function o(g){return g.replace(/<[^>]*>?/gi,x)}function x(g){return g.match(J)||g.match(p)||g.match(K)?g:""}function t(g){if(""==g)return"";var l=/<\/?\w+[^>]*(\s|$|>)/g,o=g.toLowerCase().match(l),k=(o||[]).length;if(0==k)return g;for(var p,r,e,m=[],x=[],t=!1,h=0;h<k;h++)if(p=o[h].replace(/<\/?(\w+).*/,"$1"),!(m[h]||-1<"<p><img><br><li><hr>".search("<"+p+">"))){r=o[h];e=-1;if(!/^<\//.test(r))for(r=h+1;r<k;r++)if(!m[r]&&o[r]=="</"+p+">"){e=r;break}-1==e?t=x[h]=!0:m[e]=!0}if(!t)return g;
h=0;return g=g.replace(l,function(a){a=x[h]?"":a;h++;return a})}var l,g;"object"===typeof exports&&"function"===typeof require?(l=exports,g=require("./Markdown.Converter").Converter):(l=window.Markdown,g=l.Converter);l.getSanitizingConverter=function(){var l=new g;l.hooks.chain("postConversion",o);l.hooks.chain("postConversion",t);return l};var J=/^(<\/?(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,p=/^(<a\shref="((https?|ftp):\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i,
K=/^(<img\ssrc="(https?:\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i})();
(function(){var o,x,t;function l(){}function g(a){this.buttonBar=e.getElementById("wmd-button-bar"+a);this.preview=e.getElementById("wmd-preview"+a);this.input=e.getElementById("wmd-input"+a)}function J(a,b){var c=this,d=[],f=0,i="none",e,g,s,j=function(a,b){i!=a&&(i=a,b||v());!o||"moving"!=i?g=setTimeout(w,1):s=null},w=function(a){s=new p(b,a);g=void 0};this.setCommandMode=function(){i="command";v();g=setTimeout(w,0)};this.canUndo=function(){return 1<f};this.canRedo=function(){return d[f+1]?!0:!1};
this.undo=function(){c.canUndo()&&(e?(e.restore(),e=null):(d[f]=new p(b),d[--f].restore(),a&&a()));i="none";b.input.focus();w()};this.redo=function(){c.canRedo()&&(d[++f].restore(),a&&a());i="none";b.input.focus();w()};var v=function(){var c=s||new p(b);if(!c)return!1;"moving"==i?e||(e=c):(e&&(d[f-1].text!=e.text&&(d[f++]=e),e=null),d[f++]=c,d[f+1]=null,a&&a())},h=function(a){var b=!1;if(a.ctrlKey||a.metaKey)switch(String.fromCharCode(a.charCode||a.keyCode)){case "y":c.redo();b=!0;break;case "z":a.shiftKey?
c.redo():c.undo(),b=!0}b&&(a.preventDefault&&a.preventDefault(),window.event&&(window.event.returnValue=!1))},l=function(a){!a.ctrlKey&&!a.metaKey&&(a=a.keyCode,33<=a&&40>=a||63232<=a&&63235>=a?j("moving"):8==a||46==a||127==a?j("deleting"):13==a?j("newlines"):27==a?j("escape"):(16>a||20<a)&&91!=a&&j("typing"))};(function(){k.addEvent(b.input,"keypress",function(a){(a.ctrlKey||a.metaKey)&&(89==a.keyCode||90==a.keyCode)&&a.preventDefault()});var a=function(){if((o||s&&s.text!=b.input.value)&&void 0==
g)i="paste",v(),w()};k.addEvent(b.input,"keydown",h);k.addEvent(b.input,"keydown",l);k.addEvent(b.input,"mousedown",function(){j("moving")});b.input.onpaste=a;b.input.ondrop=a})();w(!0);v()}function p(a,b){var c=this,d=a.input;this.init=function(){if(k.isVisible(d)&&(b||!(e.activeElement&&e.activeElement!==d)))if(this.setInputAreaSelectionStartEnd(),this.scrollTop=d.scrollTop,!this.text&&d.selectionStart||0===d.selectionStart)this.text=d.value};this.setInputAreaSelection=function(){if(k.isVisible(d))if(void 0!==
d.selectionStart&&!x)d.focus(),d.selectionStart=c.start,d.selectionEnd=c.end,d.scrollTop=c.scrollTop;else if(e.selection&&!(e.activeElement&&e.activeElement!==d)){d.focus();var a=d.createTextRange();a.moveStart("character",-d.value.length);a.moveEnd("character",-d.value.length);a.moveEnd("character",c.end);a.moveStart("character",c.start);a.select()}};this.setInputAreaSelectionStartEnd=function(){if(!a.ieCachedRange&&(d.selectionStart||0===d.selectionStart))c.start=d.selectionStart,c.end=d.selectionEnd;
else if(e.selection){c.text=k.fixEolChars(d.value);var b=a.ieCachedRange||e.selection.createRange(),i=k.fixEolChars(b.text),g="\u0007"+i+"\u0007";b.text=g;var B=k.fixEolChars(d.value);b.moveStart("character",-g.length);b.text=i;c.start=B.indexOf("\u0007");c.end=B.lastIndexOf("\u0007")-1;if(g=c.text.length-k.fixEolChars(d.value).length){for(b.moveStart("character",-i.length);g--;)i+="\n",c.end+=1;b.text=i}a.ieCachedRange&&(c.scrollTop=a.ieCachedScrollTop);a.ieCachedRange=null;this.setInputAreaSelection()}};
this.restore=function(){void 0!=c.text&&c.text!=d.value&&(d.value=c.text);this.setInputAreaSelection();d.scrollTop=c.scrollTop};this.getChunks=function(){var a=new l;a.before=k.fixEolChars(c.text.substring(0,c.start));a.startTag="";a.selection=k.fixEolChars(c.text.substring(c.start,c.end));a.endTag="";a.after=k.fixEolChars(c.text.substring(c.end));a.scrollTop=c.scrollTop;return a};this.setChunks=function(a){a.before+=a.startTag;a.after=a.endTag+a.after;this.start=a.before.length;this.end=a.before.length+
a.selection.length;this.text=a.before+a.selection+a.after;this.scrollTop=a.scrollTop};this.init()}function K(a,b,c){var d,f,i,g=function(){var a=0;window.innerHeight?a=window.pageYOffset:e.documentElement&&e.documentElement.scrollTop?a=e.documentElement.scrollTop:e.body&&(a=e.body.scrollTop);return a},B=function(){if(b.preview){var c=b.input.value;if(!(c&&c==i)){i=c;var d=(new Date).getTime(),c=a.makeHtml(c);f=(new Date).getTime()-d;m(c)}}},s=function(){d&&(clearTimeout(d),d=void 0);var a=0,a=f;3E3<
a&&(a=3E3);d=setTimeout(B,a)};this.refresh=function(a){a?(i="",B()):s()};this.processingTime=function(){return f};var j=!0,w=function(a){var c=b.preview,d=c.parentNode,f=c.nextSibling;d.removeChild(c);c.innerHTML=a;f?d.insertBefore(c,f):d.appendChild(c)},v=function(a){b.preview.innerHTML=a},h,l=function(a){if(h)return h(a);try{v(a),h=v}catch(b){h=w,h(a)}},m=function(a){var d=u.getTop(b.input)-g();b.preview&&(l(a),c());b.preview&&(b.preview.scrollTop=(b.preview.scrollHeight-b.preview.clientHeight)*
(b.preview.scrollHeight<=b.preview.clientHeight?1:b.preview.scrollTop/(b.preview.scrollHeight-b.preview.clientHeight)));if(j)j=!1;else{var f=u.getTop(b.input)-g();o?setTimeout(function(){window.scrollBy(0,f-d)},0):window.scrollBy(0,f-d)}};(function(a,b){k.addEvent(a,"input",b);a.onpaste=b;a.ondrop=b;k.addEvent(a,"keypress",b);k.addEvent(a,"keydown",b)})(b.input,s);B();b.preview&&(b.preview.scrollTop=0)}function z(a,b,c,d,f,i){var g,h,s,j,w,v,l,m,r,n,u,t;function q(a){H.focus();if(a.textOp){c&&c.setCommandMode();
var f=new p(b);if(!f)return;var j=f.getChunks(),i=function(){H.focus();j&&f.setChunks(j);f.restore();d.refresh()};a.textOp(j,i)||i()}a.execute&&a.execute(c)}function z(a,c){var d=a.getElementsByTagName("span")[0];c?(d.style.backgroundPosition=a.XShift+" 0px",a.onmouseover=function(){d.style.backgroundPosition=this.XShift+" -40px"},a.onmouseout=function(){d.style.backgroundPosition=this.XShift+" 0px"},o&&(a.onmousedown=function(){e.activeElement&&e.activeElement!==b.input||(b.ieCachedRange=document.selection.createRange(),
b.ieCachedScrollTop=b.input.scrollTop)}),a.isHelp||(a.onclick=function(){if(this.onmouseout)this.onmouseout();q(this);return!1})):(d.style.backgroundPosition=a.XShift+" -20px",a.onmouseover=a.onmouseout=a.onclick=function(){})}function A(a){"string"===typeof a&&(a=f[a]);return function(){a.apply(f,arguments)}}function D(){c&&(z(u,c.canUndo()),z(t,c.canRedo()))}var H=b.input;g=void 0;h=void 0;s=void 0;j=void 0;w=void 0;v=void 0;l=void 0;m=void 0;r=void 0;n=void 0;u=void 0;t=void 0;(function(){var c=
b.buttonBar,d=document.createElement("ul");d.id="wmd-button-row"+a;d.className="wmd-button-row";var d=c.appendChild(d),f=0,c=function(b,c,j,i){var e=document.createElement("li");e.className="wmd-button";e.style.left=f+"px";f+=25;var g=document.createElement("span");e.id=b+a;e.appendChild(g);e.title=c;e.XShift=j;i&&(e.textOp=i);z(e,!0);d.appendChild(e);return e},e=function(b){var c=document.createElement("li");c.className="wmd-spacer wmd-spacer"+b;c.id="wmd-spacer"+b+a;d.appendChild(c);f+=25};g=c("wmd-bold-button",
"Strong <strong> Ctrl+B","0px",A("doBold"));h=c("wmd-italic-button","Emphasis <em> Ctrl+I","-20px",A("doItalic"));e(1);s=c("wmd-link-button","Hyperlink <a> Ctrl+L","-40px",A(function(a,b){return this.doLinkOrImage(a,b,!1)}));j=c("wmd-quote-button","Blockquote <blockquote> Ctrl+Q","-60px",A("doBlockquote"));w=c("wmd-code-button","Code Sample <pre><code> Ctrl+K","-80px",A("doCode"));v=c("wmd-image-button","Image <img> Ctrl+G","-100px",A(function(a,b){return this.doLinkOrImage(a,b,!0)}));e(2);l=c("wmd-olist-button",
"Numbered List <ol> Ctrl+O","-120px",A(function(a,b){this.doList(a,b,!0)}));m=c("wmd-ulist-button","Bulleted List <ul> Ctrl+U","-140px",A(function(a,b){this.doList(a,b,!1)}));r=c("wmd-heading-button","Heading <h1>/<h2> Ctrl+H","-160px",A("doHeading"));n=c("wmd-hr-button","Horizontal Rule <hr> Ctrl+R","-180px",A("doHorizontalRule"));e(3);u=c("wmd-undo-button","Undo - Ctrl+Z","-200px",null);u.execute=function(a){a&&a.undo()};e=/win/.test(F.platform.toLowerCase())?"Redo - Ctrl+Y":"Redo - Ctrl+Shift+Z";
t=c("wmd-redo-button",e,"-220px",null);t.execute=function(a){a&&a.redo()};i&&(c=document.createElement("li"),e=document.createElement("span"),c.appendChild(e),c.className="wmd-button wmd-help-button",c.id="wmd-help-button"+a,c.XShift="-240px",c.isHelp=!0,c.style.right="0px",c.title=i.title||M,c.onclick=i.handler,z(c,!0),d.appendChild(c));D()})();var G="keydown";x&&(G="keypress");k.addEvent(H,G,function(a){if((a.ctrlKey||a.metaKey)&&!a.altKey&&!a.shiftKey){switch(String.fromCharCode(a.charCode||a.keyCode).toLowerCase()){case "b":q(g);
break;case "i":q(h);break;case "l":q(s);break;case "q":q(j);break;case "k":q(w);break;case "g":q(v);break;case "o":q(l);break;case "u":q(m);break;case "h":q(r);break;case "r":q(n);break;case "y":q(t);break;case "z":a.shiftKey?q(t):q(u);break;default:return}a.preventDefault&&a.preventDefault();window.event&&(window.event.returnValue=!1)}});k.addEvent(H,"keyup",function(a){if(a.shiftKey&&!a.ctrlKey&&!a.metaKey&&13===(a.charCode||a.keyCode))a={},a.textOp=A("doAutoindent"),q(a)});o&&k.addEvent(H,"keydown",
function(a){if(27===a.keyCode)return!1});this.setUndoRedoButtonStates=D}function G(a){this.hooks=a}function D(a){return a.replace(/^\s*(.*?)(?:\s+"(.+)")?\s*$/,function(a,c,d){c=c.replace(/\?.*$/,function(a){return a.replace(/\+/g," ")});c=decodeURIComponent(c);c=encodeURI(c).replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29");c=c.replace(/\?.*$/,function(a){return a.replace(/\+/g,"%2b")});d&&(d=d.trim?d.trim():d.replace(/^\s*/,"").replace(/\s*$/,""),d=$.trim(d).replace(/"/g,"quot;").replace(/\(/g,
"&#40;").replace(/\)/g,"&#41;").replace(/</g,"&lt;").replace(/>/g,"&gt;"));return d?c+' "'+d+'"':c})}var k={},u={},r={},e=window.document,m=window.RegExp,F=window.navigator;o=/msie/.test(F.userAgent.toLowerCase());t=/msie 6/.test(F.userAgent.toLowerCase())||/msie 5/.test(F.userAgent.toLowerCase());x=/opera/.test(F.userAgent.toLowerCase());var M="Help with formatting";Markdown.Editor=function(a,b,c){var b=b||"",d=this.hooks=new Markdown.HookCollection;d.addNoop("onPreviewRefresh");d.addNoop("postBlockquoteCreation");
d.addFalse("insertImageDialog");this.getConverter=function(){return a};var f=this,i;this.run=function(){if(!i){i=new g(b);var h=new G(d),k=new K(a,i,function(){d.onPreviewRefresh()}),s,j;/\?noundo/.test(e.location.href)||(s=new J(function(){k.refresh();j&&j.setUndoRedoButtonStates()},i),this.textOperation=function(a){s.setCommandMode();a();f.refreshPreview()});j=new z(b,i,s,k,h,c);j.setUndoRedoButtonStates();(f.refreshPreview=function(){k.refresh(!0)})()}}};l.prototype.findTags=function(a,b){var c=
this,d;a&&(d=k.extendRegExp(a,"","$"),this.before=this.before.replace(d,function(a){c.startTag+=a;return""}),d=k.extendRegExp(a,"^",""),this.selection=this.selection.replace(d,function(a){c.startTag+=a;return""}));b&&(d=k.extendRegExp(b,"","$"),this.selection=this.selection.replace(d,function(a){c.endTag=a+c.endTag;return""}),d=k.extendRegExp(b,"^",""),this.after=this.after.replace(d,function(a){c.endTag=a+c.endTag;return""}))};l.prototype.trimWhitespace=function(a){var b,c=this;a?a=b="":(a=function(a){c.before+=
a;return""},b=function(a){c.after=a+c.after;return""});this.selection=this.selection.replace(/^(\s*)/,a).replace(/(\s*)$/,b)};l.prototype.skipLines=function(a,b,c){void 0===a&&(a=1);void 0===b&&(b=1);a++;b++;var d,f;navigator.userAgent.match(/Chrome/)&&"X".match(/()./);this.selection=this.selection.replace(/(^\n*)/,"");this.startTag+=m.$1;this.selection=this.selection.replace(/(\n*$)/,"");this.endTag+=m.$1;this.startTag=this.startTag.replace(/(^\n*)/,"");this.before+=m.$1;this.endTag=this.endTag.replace(/(\n*$)/,
"");this.after+=m.$1;if(this.before){for(d=f="";a--;)d+="\\n?",f+="\n";c&&(d="\\n*");this.before=this.before.replace(new m(d+"$",""),f)}if(this.after){for(d=f="";b--;)d+="\\n?",f+="\n";c&&(d="\\n*");this.after=this.after.replace(new m(d,""),f)}};k.isVisible=function(a){if(window.getComputedStyle)return"none"!==window.getComputedStyle(a,null).getPropertyValue("display");if(a.currentStyle)return"none"!==a.currentStyle.display};k.addEvent=function(a,b,c){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,
c,!1)};k.removeEvent=function(a,b,c){a.detachEvent?a.detachEvent("on"+b,c):a.removeEventListener(b,c,!1)};k.fixEolChars=function(a){a=a.replace(/\r\n/g,"\n");return a=a.replace(/\r/g,"\n")};k.extendRegExp=function(a,b,c){if(null===b||void 0===b)b="";if(null===c||void 0===c)c="";var a=a.toString(),d,a=a.replace(/\/([gim]*)$/,function(a,b){d=b;return""}),a=a.replace(/(^\/|\/$)/g,"");return new m(b+a+c,d)};u.getTop=function(a,b){var c=a.offsetTop;if(!b)for(;a=a.offsetParent;)c+=a.offsetTop;return c};
u.getHeight=function(a){return a.offsetHeight||a.scrollHeight};u.getWidth=function(a){return a.offsetWidth||a.scrollWidth};u.getPageSize=function(){var a,b,c,d;self.innerHeight&&self.scrollMaxY?(a=e.body.scrollWidth,b=self.innerHeight+self.scrollMaxY):e.body.scrollHeight>e.body.offsetHeight?(a=e.body.scrollWidth,b=e.body.scrollHeight):(a=e.body.offsetWidth,b=e.body.offsetHeight);self.innerHeight?(c=self.innerWidth,d=self.innerHeight):e.documentElement&&e.documentElement.clientHeight?(c=e.documentElement.clientWidth,
d=e.documentElement.clientHeight):e.body&&(c=e.body.clientWidth,d=e.body.clientHeight);a=Math.max(a,c);b=Math.max(b,d);return[a,b,c,d]};r.createBackground=function(){var a=e.createElement("div"),b=a.style;a.className="wmd-prompt-background";b.position="absolute";b.top="0";b.zIndex="1000";o?b.filter="alpha(opacity=50)":b.opacity="0.5";var c=u.getPageSize();b.height=c[1]+"px";o?(b.left=e.documentElement.scrollLeft,b.width=e.documentElement.clientWidth):(b.left="0",b.width="100%");e.body.appendChild(a);
return a};r.prompt=function(a,b,c){var d,f;void 0===b&&(b="");var i=function(a){27===(a.charCode||a.keyCode)&&g(!0)},g=function(a){k.removeEvent(e.body,"keydown",i);var b=f.value;a?b=null:(b=b.replace(/^http:\/\/(https?|ftp):\/\//,"$1://"),/^(?:https?|ftp):\/\//.test(b)||(b="http://"+b));d.parentNode.removeChild(d);c(b);return!1},h=function(){d=e.createElement("div");d.className="wmd-prompt-dialog";d.style.padding="10px;";d.style.position="fixed";d.style.width="400px";d.style.zIndex="1001";var c=
e.createElement("div");c.innerHTML=a;c.style.padding="5px";d.appendChild(c);var c=e.createElement("form"),j=c.style;c.onsubmit=function(){return g(!1)};j.padding="0";j.margin="0";j.cssFloat="left";j.width="100%";j.textAlign="center";j.position="relative";d.appendChild(c);f=e.createElement("input");f.type="text";f.value=b;j=f.style;j.display="block";j.width="80%";j.marginLeft=j.marginRight="auto";c.appendChild(f);var h=e.createElement("input");h.type="button";h.onclick=function(){return g(!1)};h.value=
"OK";j=h.style;j.margin="10px";j.display="inline";j.width="7em";var l=e.createElement("input");l.type="button";l.onclick=function(){return g(!0)};l.value="Cancel";j=l.style;j.margin="10px";j.display="inline";j.width="7em";c.appendChild(h);c.appendChild(l);k.addEvent(e.body,"keydown",i);d.style.top="50%";d.style.left="50%";d.style.display="block";t&&(d.style.position="absolute",d.style.top=e.documentElement.scrollTop+200+"px",d.style.left="50%");e.body.appendChild(d);d.style.marginTop=-(u.getHeight(d)/
2)+"px";d.style.marginLeft=-(u.getWidth(d)/2)+"px"};setTimeout(function(){h();var a=b.length;if(void 0!==f.selectionStart)f.selectionStart=0,f.selectionEnd=a;else if(f.createTextRange){var c=f.createTextRange();c.collapse(!1);c.moveStart("character",-a);c.moveEnd("character",a);c.select()}f.focus()},0)};var h=G.prototype;h.prefixes="(?:\\s{4,}|\\s*>|\\s*-\\s+|\\s*\\d+\\.|=|\\+|-|_|\\*|#|\\s*\\[[^\n]]+\\]:)";h.unwrap=function(a){var b=new m("([^\\n])\\n(?!(\\n|"+this.prefixes+"))","g");a.selection=
a.selection.replace(b,"$1 $2")};h.wrap=function(a,b){this.unwrap(a);var c=new m("(.{1,"+b+"})( +|$\\n?)","gm"),d=this;a.selection=a.selection.replace(c,function(a,b){return(new m("^"+d.prefixes,"")).test(a)?a:b+"\n"});a.selection=a.selection.replace(/\s+$/,"")};h.doBold=function(a,b){return this.doBorI(a,b,2,"strong text")};h.doItalic=function(a,b){return this.doBorI(a,b,1,"emphasized text")};h.doBorI=function(a,b,c,d){a.trimWhitespace();a.selection=a.selection.replace(/\n{2,}/g,"\n");var f=/(\**$)/.exec(a.before)[0],
b=/(^\**)/.exec(a.after)[0],f=Math.min(f.length,b.length);f>=c&&(2!=f||1!=c)?(a.before=a.before.replace(m("[*]{"+c+"}$",""),""),a.after=a.after.replace(m("^[*]{"+c+"}",""),"")):!a.selection&&b?(a.after=a.after.replace(/^([*_]*)/,""),a.before=a.before.replace(/(\s?)$/,""),a.before=a.before+b+m.$1):(!a.selection&&!b&&(a.selection=d),c=1>=c?"*":"**",a.before+=c,a.after=c+a.after)};h.stripLinkDefs=function(a,b){return a=a.replace(/^[ ]{0,3}\[(\d+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|$)/gm,
function(a,d,f,e,g){b[d]=a.replace(/\s*$/,"");return e?(b[d]=a.replace(/["(](.+?)[")]$/,""),e+g):""})};h.addLinkDef=function(a,b){var c=0,d={};a.before=this.stripLinkDefs(a.before,d);a.selection=this.stripLinkDefs(a.selection,d);a.after=this.stripLinkDefs(a.after,d);var f="",e=/(\[)((?:\[[^\]]*\]|[^\[\]])*)(\][ ]?(?:\n[ ]*)?\[)(\d+)(\])/g,g=function(a){c++;a=a.replace(/^[ ]{0,3}\[(\d+)\]:/," ["+c+"]:");f+="\n"+a},h=function(a,b,f,k,l,s){f=f.replace(e,h);return d[l]?(g(d[l]),b+f+k+c+s):a};a.before=
a.before.replace(e,h);b?g(b):a.selection=a.selection.replace(e,h);var k=c;a.after=a.after.replace(e,h);a.after&&(a.after=a.after.replace(/\n*$/,""));a.after||(a.selection=a.selection.replace(/\n*$/,""));a.after+="\n\n"+f;return k};h.doLinkOrImage=function(a,b,c){a.trimWhitespace();a.findTags(/\s*!?\[/,/\][ ]?(?:\n[ ]*)?(\[.*?\])?/);var d;if(1<a.endTag.length&&0<a.startTag.length)a.startTag=a.startTag.replace(/!?\[/,""),a.endTag="",this.addLinkDef(a,null);else if(a.selection=a.startTag+a.selection+
a.endTag,a.startTag=a.endTag="",/\n\n/.test(a.selection))this.addLinkDef(a,null);else{var f=this,e=function(e){d.parentNode.removeChild(d);null!==e&&(a.selection=(" "+a.selection).replace(/([^\\](?:\\\\)*)(?=[[\]])/g,"$1\\").substr(1),e=" [999]: "+D(e),e=f.addLinkDef(a,e),a.startTag=c?"![":"[",a.endTag="]["+e+"]",a.selection||(a.selection=c?"enter image description here":"enter link description here"));b()};d=r.createBackground();c?this.hooks.insertImageDialog(e)||r.prompt('<h3 style="margin-top:0">Enter the image URL.</h3>',
"http://",e):r.prompt('<h3 style="margin-top:0">Enter the web address.</h3>',"http://",e);return!0}};h.doAutoindent=function(a){var b=!1;a.before=a.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/,"\n\n");a.before=a.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/,"\n\n");a.before=a.before.replace(/(\n|^)[ \t]+\n$/,"\n\n");!a.selection&&!/^[ \t]*(?:\n|$)/.test(a.after)&&(a.after=a.after.replace(/^[^\n]*/,function(b){a.selection=b;return""}),b=!0);/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]+.*\n$/.test(a.before)&&
this.doList&&this.doList(a);/(\n|^)[ ]{0,3}>[ \t]+.*\n$/.test(a.before)&&this.doBlockquote&&this.doBlockquote(a);/(\n|^)(\t|[ ]{4,}).*\n$/.test(a.before)&&this.doCode&&this.doCode(a);b&&(a.after=a.selection+a.after,a.selection="")};h.doBlockquote=function(a){a.selection=a.selection.replace(/^(\n*)([^\r]+?)(\n*)$/,function(b,c,d,f){a.before+=c;a.after=f+a.after;return d});a.before=a.before.replace(/(>[ \t]*)$/,function(b,c){a.selection=c+a.selection;return""});a.selection=a.selection.replace(/^(\s|>)+$/,
"");a.selection=a.selection||"Blockquote";var b="",c="",d;if(a.before){for(var f=a.before.replace(/\n$/,"").split("\n"),e=!1,g=0;g<f.length;g++){var h=!1;d=f[g];e=e&&0<d.length;/^>/.test(d)?(h=!0,!e&&1<d.length&&(e=!0)):h=/^[ \t]*$/.test(d)?!0:e;h?b+=d+"\n":(c+=b+d,b="\n")}/(^|\n)>/.test(b)||(c+=b,b="")}a.startTag=b;a.before=c;a.after&&(a.after=a.after.replace(/^\n?/,"\n"));a.after=a.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/,function(b){a.endTag=b;return""});b=function(b){var c=
b?"> ":"";a.startTag&&(a.startTag=a.startTag.replace(/\n((>|\s)*)\n$/,function(a,b){return"\n"+b.replace(/^[ ]{0,3}>?[ \t]*$/gm,c)+"\n"}));a.endTag&&(a.endTag=a.endTag.replace(/^\n((>|\s)*)\n/,function(a,b){return"\n"+b.replace(/^[ ]{0,3}>?[ \t]*$/gm,c)+"\n"}))};/^(?![ ]{0,3}>)/m.test(a.selection)?(this.wrap(a,70),a.selection=a.selection.replace(/^/gm,"> "),b(!0),a.skipLines()):(a.selection=a.selection.replace(/^[ ]{0,3}> ?/gm,""),this.unwrap(a),b(!1),!/^(\n|^)[ ]{0,3}>/.test(a.selection)&&a.startTag&&
(a.startTag=a.startTag.replace(/\n{0,2}$/,"\n\n")),!/(\n|^)[ ]{0,3}>.*$/.test(a.selection)&&a.endTag&&(a.endTag=a.endTag.replace(/^\n{0,2}/,"\n\n")));a.selection=this.hooks.postBlockquoteCreation(a.selection);/\n/.test(a.selection)||(a.selection=a.selection.replace(/^(> *)/,function(b,c){a.startTag+=c;return""}))};h.doCode=function(a){var b=/\S[ ]*$/.test(a.before);if(!/^[ ]*\S/.test(a.after)&&!b||/\n/.test(a.selection)){a.before=a.before.replace(/[ ]{4}$/,function(b){a.selection=b+a.selection;return""});
var c=b=1;/(\n|^)(\t|[ ]{4,}).*\n$/.test(a.before)&&(b=0);/^\n(\t|[ ]{4,})/.test(a.after)&&(c=0);a.skipLines(b,c);a.selection?/^[ ]{0,3}\S/m.test(a.selection)?/\n/.test(a.selection)?a.selection=a.selection.replace(/^/gm," "):a.before+=" ":a.selection=a.selection.replace(/^[ ]{4}/gm,""):(a.startTag=" ",a.selection="enter code here")}else a.trimWhitespace(),a.findTags(/`/,/`/),!a.startTag&&!a.endTag?(a.startTag=a.endTag="`",a.selection||(a.selection="enter code here")):a.endTag&&!a.startTag?
(a.before+=a.endTag,a.endTag=""):a.startTag=a.endTag=""};h.doList=function(a,b,c){var b=/^\n*(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/,d="-",f=1,e=function(){var a;c?(a=" "+f+". ",f++):a=" "+d+" ";return a},g=function(a){void 0===c&&(c=/^\s*\d/.test(a));return a=a.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm,function(){return e()})};a.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/,null);a.before&&!/\n$/.test(a.before)&&!/^\n/.test(a.startTag)&&(a.before+=
a.startTag,a.startTag="");if(a.startTag){var h=/\d+[.]/.test(a.startTag);a.startTag="";a.selection=a.selection.replace(/\n[ ]{4}/g,"\n");this.unwrap(a);a.skipLines();h&&(a.after=a.after.replace(b,g));if(c==h)return}var k=1;a.before=a.before.replace(/(\n|^)(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*$/,function(a){/^\s*([*+-])/.test(a)&&(d=m.$1);k=/[^\n]\n\n[^\n]/.test(a)?1:0;return g(a)});a.selection||(a.selection="List item");var h=e(),j=1;a.after=
a.after.replace(b,function(a){j=/[^\n]\n\n[^\n]/.test(a)?1:0;return g(a)});a.trimWhitespace(!0);a.skipLines(k,j,!0);a.startTag=h;b=h.replace(/./g," ");this.wrap(a,72-b.length);a.selection=a.selection.replace(/\n/g,"\n"+b)};h.doHeading=function(a){a.selection=a.selection.replace(/\s+/g," ");a.selection=a.selection.replace(/(^\s+|\s+$)/g,"");if(a.selection){var b=0;a.findTags(/#+[ ]*/,/[ ]*#+/);/#+/.test(a.startTag)&&(b=m.lastMatch.length);a.startTag=a.endTag="";a.findTags(null,/\s?(-+|=+)/);/=+/.test(a.endTag)&&
(b=1);/-+/.test(a.endTag)&&(b=2);a.startTag=a.endTag="";a.skipLines(1,1);b=0==b?2:b-1;if(0<b){var b=2<=b?"-":"=",c=a.selection.length;72<c&&(c=72);for(a.endTag="\n";c--;)a.endTag+=b}}else a.startTag="## ",a.selection="Heading",a.endTag=" ##"};h.doHorizontalRule=function(a){a.startTag="----------\n";a.selection="";a.skipLines(2,1,!0)}})();

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,105 @@
/* Markdown editor styles */
.wmd-button-bar {
width: 100%;
padding: 5px 0;
}
.wmd-input {
/* 604 */
width: 598px;
height: 250px;
margin: 0 0 10px;
padding: 2px;
border: 1px solid #ccc;
}
.wmd-preview {
/* 604 */
width: 584px;
margin: 10px 0;
padding: 8px;
border: 2px dashed #ccc;
}
.qa-q-view-content pre,
.qa-a-item-content pre,
.wmd-preview pre {
overflow: auto;
width: 100%;
max-height: 400px;
padding: 0;
border-width: 1px 1px 1px 3px;
border-style: solid;
border-color: #ddd;
background-color: #eee;
}
pre code {
display: block;
padding: 8px;
}
.wmd-button-row {
position: relative;
margin: 0;
padding: 0;
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 {
/* note: background-image is set in plugin script */
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: #000;
}
.wmd-prompt-dialog {
border: 1px solid #999;
background-color: #f5f5f5;
}
.wmd-prompt-dialog > div {
font-size: 0.8em;
}
.wmd-prompt-dialog > form > input[type="text"] {
border: 1px solid #999;
color: black;
}
.wmd-prompt-dialog > form > input[type="button"] {
border: 1px solid #888;
font-size: 11px;
font-weight: bold;
}

View File

@@ -0,0 +1,122 @@
<?php
/*
Question2Answer Markdown editor plugin
License: http://www.gnu.org/licenses/gpl.html
*/
class qa_markdown_editor
{
private $pluginurl;
private $cssopt = 'markdown_editor_css';
private $convopt = 'markdown_comment';
private $hljsopt = 'markdown_highlightjs';
public function load_module($directory, $urltoroot)
{
$this->pluginurl = $urltoroot;
}
public function calc_quality($content, $format)
{
return $format == 'markdown' ? 1.0 : 0.8;
}
public function get_field(&$qa_content, $content, $format, $fieldname, $rows, $autofocus)
{
$html = '<div id="wmd-button-bar-'.$fieldname.'" class="wmd-button-bar"></div>' . "\n";
$html .= '<textarea name="'.$fieldname.'" id="wmd-input-'.$fieldname.'" class="wmd-input">'.$content.'</textarea>' . "\n";
$html .= '<h3>'.qa_lang_html('markdown/preview').'</h3>' . "\n";
$html .= '<div id="wmd-preview-'.$fieldname.'" class="wmd-preview"></div>' . "\n";
// $html .= '<script src="'.$this->pluginurl.'pagedown/Markdown.Converter.js"></script>' . "\n";
// $html .= '<script src="'.$this->pluginurl.'pagedown/Markdown.Sanitizer.js"></script>' . "\n";
// $html .= '<script src="'.$this->pluginurl.'pagedown/Markdown.Editor.js"></script>' . "\n";
// comment this script and uncomment the 3 above to use the non-minified code
$html .= '<script src="'.$this->pluginurl.'pagedown/markdown.min.js"></script>' . "\n";
return array('type'=>'custom', 'html'=>$html);
}
public function read_post($fieldname)
{
$html = $this->_my_qa_post_text($fieldname);
return array(
'format' => 'markdown',
'content' => $html
);
}
public function load_script($fieldname)
{
return
'var converter = Markdown.getSanitizingConverter();' . "\n" .
'var editor = new Markdown.Editor(converter, "-'.$fieldname.'");' . "\n" .
'editor.run();' . "\n";
}
// set admin options
public function admin_form(&$qa_content)
{
$saved_msg = null;
if (qa_clicked('markdown_save')) {
// save options
$hidecss = qa_post_text('md_hidecss') ? '1' : '0';
qa_opt($this->cssopt, $hidecss);
$convert = qa_post_text('md_comments') ? '1' : '0';
qa_opt($this->convopt, $convert);
$convert = qa_post_text('md_highlightjs') ? '1' : '0';
qa_opt($this->hljsopt, $convert);
$saved_msg = qa_lang_html('admin/options_saved');
}
return array(
'ok' => $saved_msg,
'style' => 'wide',
'fields' => array(
'css' => array(
'type' => 'checkbox',
'label' => qa_lang_html('markdown/admin_hidecss'),
'tags' => 'NAME="md_hidecss"',
'value' => qa_opt($this->cssopt) === '1',
'note' => qa_lang_html('markdown/admin_hidecss_note'),
),
'comments' => array(
'type' => 'checkbox',
'label' => qa_lang_html('markdown/admin_comments'),
'tags' => 'NAME="md_comments"',
'value' => qa_opt($this->convopt) === '1',
'note' => qa_lang_html('markdown/admin_comments_note'),
),
'highlightjs' => array(
'type' => 'checkbox',
'label' => qa_lang_html('markdown/admin_syntax'),
'tags' => 'NAME="md_highlightjs"',
'value' => qa_opt($this->hljsopt) === '1',
'note' => qa_lang_html('markdown/admin_syntax_note'),
),
),
'buttons' => array(
'save' => array(
'tags' => 'NAME="markdown_save"',
'label' => qa_lang_html('admin/save_options_button'),
'value' => '1',
),
),
);
}
// copy of qa-base.php > qa_post_text, with trim() function removed.
private function _my_qa_post_text($field)
{
return isset($_POST[$field]) ? preg_replace('/\r\n?/', "\n", qa_gpc_to_string($_POST[$field])) : null;
}
}

View File

@@ -0,0 +1,40 @@
<?php
/*
Question2Answer Markdown editor plugin
License: http://www.gnu.org/licenses/gpl.html
*/
class qa_markdown_viewer
{
private $plugindir;
public function load_module($directory, $urltoroot)
{
$this->plugindir = $directory;
}
public function calc_quality($content, $format)
{
return $format == 'markdown' ? 1.0 : 0.8;
}
public function get_html($content, $format, $options)
{
if (isset($options['blockwordspreg'])) {
require_once QA_INCLUDE_DIR.'qa-util-string.php';
$content = qa_block_words_replace($content, $options['blockwordspreg']);
}
require_once $this->plugindir . 'inc.markdown.php';
$html = Markdown($content);
return qa_sanitize_html($html, @$options['linksnewwindow']);
}
public function get_text($content, $format, $options)
{
$viewer = qa_load_module('viewer', '');
$text = $viewer->get_text($content, 'html', array());
return $text;
}
}

View File

@@ -0,0 +1,31 @@
<?php
/*
Question2Answer Markdown editor plugin
License: http://www.gnu.org/licenses/gpl.html
*/
require_once QA_INCLUDE_DIR.'qa-app-posts.php';
class qa_markdown_events
{
private $directory;
private $urltoroot;
private $convopt = 'markdown_comment';
public function load_module($directory, $urltoroot)
{
$this->directory = $directory;
$this->urltoroot = $urltoroot;
}
public function process_event($event, $userid, $handle, $cookieid, $params)
{
// check we have the correct event and the option is set
if ($event != 'a_to_c')
return;
if (!qa_opt($this->convopt))
return;
qa_post_set_content($params['postid'], null, null, '', null, null, null, qa_get_logged_in_userid());
}
}

View File

@@ -0,0 +1,17 @@
<?php
/*
Question2Answer Edit History plugin
License: http://www.gnu.org/licenses/gpl.html
*/
return array(
'plugin_title' => 'Markdown',
'preview' => 'Preview',
'admin_hidecss' => 'Don\'t add CSS inline',
'admin_hidecss_note' => 'Tick if you added the CSS to your own stylesheet (more efficient).',
'admin_comments' => 'Plaintext comments',
'admin_comments_note' => 'Sets a post as plaintext when converting answers to comments.',
'admin_syntax' => 'Use syntax highlighting',
'admin_syntax_note' => 'Integrates highlight.js for code blocks.',
);

View File

@@ -0,0 +1,54 @@
<?php
/*
Question2Answer Markdown editor plugin
License: http://www.gnu.org/licenses/gpl.html
*/
class qa_html_theme_layer extends qa_html_theme_base
{
private $cssopt = 'markdown_editor_css';
private $hljsopt = 'markdown_highlightjs';
public function head_custom()
{
parent::head_custom();
$tmpl = array('ask', 'question');
if (!in_array($this->template, $tmpl))
return;
$hidecss = qa_opt($this->cssopt) === '1';
$usehljs = qa_opt($this->hljsopt) === '1';
$wmd_buttons = QA_HTML_THEME_LAYER_URLTOROOT.'pagedown/wmd-buttons.png';
$this->output_raw(
"<style>\n" .
".wmd-button > span { background-image: url('$wmd_buttons') }\n"
);
// display CSS for Markdown Editor
if (!$hidecss) {
$cssWMD = file_get_contents(QA_HTML_THEME_LAYER_DIRECTORY.'pagedown/wmd.css');
$this->output_raw($cssWMD);
// display CSS for HighlightJS
if ($usehljs)
{
$cssHJS = file_get_contents(QA_HTML_THEME_LAYER_DIRECTORY.'pagedown/highlightjs.css');
$this->output_raw($cssHJS);
}
}
$this->output_raw("</style>\n\n");
// set up HighlightJS
if ($usehljs) {
$js = file_get_contents(QA_HTML_THEME_LAYER_DIRECTORY.'pagedown/highlightjs-run.js');
$this->output_raw(
'<script src="'.QA_HTML_THEME_LAYER_URLTOROOT.'pagedown/highlight.min.js"></script>' .
'<script>'.$js.'</script>'
);
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
Plugin Name: Markdown Editor
Plugin URI: https://github.com/svivian/q2a-markdown-editor
Plugin Description: Markdown editor plugin for simple text-based markup
Plugin Version: 2.3.2
Plugin Date: 2015-07-30
Plugin Author: Scott Vivian
Plugin Author URI: http://codelair.com/
Plugin Contributors: NoahY
Plugin License: GPLv3
Plugin Minimum Question2Answer Version: 1.5
Plugin Minimum PHP Version: 5.2
Plugin Update Check URI: https://raw.githubusercontent.com/svivian/q2a-markdown-editor/master/qa-plugin.php
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
More about this license: http://www.gnu.org/licenses/gpl.html
*/
if (!defined('QA_VERSION')) exit;
qa_register_plugin_module('editor', 'qa-markdown-editor.php', 'qa_markdown_editor', 'Markdown Editor');
qa_register_plugin_module('viewer', 'qa-markdown-viewer.php', 'qa_markdown_viewer', 'Markdown Viewer');
qa_register_plugin_module('event', 'qa-md-events.php', 'qa_markdown_events', 'Markdown events');
qa_register_plugin_layer('qa-md-layer.php', 'Markdown Editor layer');
qa_register_plugin_phrases('qa-md-lang-*.php', 'markdown');