initial commit

This commit is contained in:
Corey Innis 2008-11-13 13:40:18 -08:00
commit 33e6d67096
11 changed files with 7464 additions and 0 deletions

419
compressed/showdown.js Normal file
View File

@ -0,0 +1,419 @@
/*
A A L Source code at:
T C A <http://www.attacklab.net/>
T K B
*/
var Showdown={};
Showdown.converter=function(){
var _1;
var _2;
var _3;
var _4=0;
this.makeHtml=function(_5){
_1=new Array();
_2=new Array();
_3=new Array();
_5=_5.replace(/~/g,"~T");
_5=_5.replace(/\$/g,"~D");
_5=_5.replace(/\r\n/g,"\n");
_5=_5.replace(/\r/g,"\n");
_5="\n\n"+_5+"\n\n";
_5=_6(_5);
_5=_5.replace(/^[ \t]+$/mg,"");
_5=_7(_5);
_5=_8(_5);
_5=_9(_5);
_5=_a(_5);
_5=_5.replace(/~D/g,"$$");
_5=_5.replace(/~T/g,"~");
return _5;
};
var _8=function(_b){
var _b=_b.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(_c,m1,m2,m3,m4){
m1=m1.toLowerCase();
_1[m1]=_11(m2);
if(m3){
return m3+m4;
}else{
if(m4){
_2[m1]=m4.replace(/"/g,"&quot;");
}
}
return "";
});
return _b;
};
var _7=function(_12){
_12=_12.replace(/\n/g,"\n\n");
var _13="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del";
var _14="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";
_12=_12.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,_15);
_12=_12.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,_15);
_12=_12.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,_15);
_12=_12.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,_15);
_12=_12.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,_15);
_12=_12.replace(/\n\n/g,"\n");
return _12;
};
var _15=function(_16,m1){
var _18=m1;
_18=_18.replace(/\n\n/g,"\n");
_18=_18.replace(/^\n/,"");
_18=_18.replace(/\n+$/g,"");
_18="\n\n~K"+(_3.push(_18)-1)+"K\n\n";
return _18;
};
var _9=function(_19){
_19=_1a(_19);
var key=_1c("<hr />");
_19=_19.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
_19=_19.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
_19=_19.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
_19=_1d(_19);
_19=_1e(_19);
_19=_1f(_19);
_19=_7(_19);
_19=_20(_19);
return _19;
};
var _21=function(_22){
_22=_23(_22);
_22=_24(_22);
_22=_25(_22);
_22=_26(_22);
_22=_27(_22);
_22=_28(_22);
_22=_11(_22);
_22=_29(_22);
_22=_22.replace(/ +\n/g," <br />\n");
return _22;
};
var _24=function(_2a){
var _2b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
_2a=_2a.replace(_2b,function(_2c){
var tag=_2c.replace(/(.)<\/?code>(?=.)/g,"$1`");
tag=_2e(tag,"\\`*_");
return tag;
});
return _2a;
};
var _27=function(_2f){
_2f=_2f.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,_30);
_2f=_2f.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,_30);
_2f=_2f.replace(/(\[([^\[\]]+)\])()()()()()/g,_30);
return _2f;
};
var _30=function(_31,m1,m2,m3,m4,m5,m6,m7){
if(m7==undefined){
m7="";
}
var _39=m1;
var _3a=m2;
var _3b=m3.toLowerCase();
var url=m4;
var _3d=m7;
if(url==""){
if(_3b==""){
_3b=_3a.toLowerCase().replace(/ ?\n/g," ");
}
url="#"+_3b;
if(_1[_3b]!=undefined){
url=_1[_3b];
if(_2[_3b]!=undefined){
_3d=_2[_3b];
}
}else{
if(_39.search(/\(\s*\)$/m)>-1){
url="";
}else{
return _39;
}
}
}
url=_2e(url,"*_");
var _3e="<a href=\""+url+"\"";
if(_3d!=""){
_3d=_3d.replace(/"/g,"&quot;");
_3d=_2e(_3d,"*_");
_3e+=" title=\""+_3d+"\"";
}
_3e+=">"+_3a+"</a>";
return _3e;
};
var _26=function(_3f){
_3f=_3f.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,_40);
_3f=_3f.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,_40);
return _3f;
};
var _40=function(_41,m1,m2,m3,m4,m5,m6,m7){
var _49=m1;
var _4a=m2;
var _4b=m3.toLowerCase();
var url=m4;
var _4d=m7;
if(!_4d){
_4d="";
}
if(url==""){
if(_4b==""){
_4b=_4a.toLowerCase().replace(/ ?\n/g," ");
}
url="#"+_4b;
if(_1[_4b]!=undefined){
url=_1[_4b];
if(_2[_4b]!=undefined){
_4d=_2[_4b];
}
}else{
return _49;
}
}
_4a=_4a.replace(/"/g,"&quot;");
url=_2e(url,"*_");
var _4e="<img src=\""+url+"\" alt=\""+_4a+"\"";
_4d=_4d.replace(/"/g,"&quot;");
_4d=_2e(_4d,"*_");
_4e+=" title=\""+_4d+"\"";
_4e+=" />";
return _4e;
};
var _1a=function(_4f){
_4f=_4f.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(_50,m1){
return _1c("<h1>"+_21(m1)+"</h1>");
});
_4f=_4f.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(_52,m1){
return _1c("<h2>"+_21(m1)+"</h2>");
});
_4f=_4f.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(_54,m1,m2){
var _57=m1.length;
return _1c("<h"+_57+">"+_21(m2)+"</h"+_57+">");
});
return _4f;
};
var _58;
var _1d=function(_59){
_59+="~0";
var _5a=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
if(_4){
_59=_59.replace(_5a,function(_5b,m1,m2){
var _5e=m1;
var _5f=(m2.search(/[*+-]/g)>-1)?"ul":"ol";
_5e=_5e.replace(/\n{2,}/g,"\n\n\n");
var _60=_58(_5e);
_60=_60.replace(/\s+$/,"");
_60="<"+_5f+">"+_60+"</"+_5f+">\n";
return _60;
});
}else{
_5a=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
_59=_59.replace(_5a,function(_61,m1,m2,m3){
var _65=m1;
var _66=m2;
var _67=(m3.search(/[*+-]/g)>-1)?"ul":"ol";
var _66=_66.replace(/\n{2,}/g,"\n\n\n");
var _68=_58(_66);
_68=_65+"<"+_67+">\n"+_68+"</"+_67+">\n";
return _68;
});
}
_59=_59.replace(/~0/,"");
return _59;
};
_58=function(_69){
_4++;
_69=_69.replace(/\n{2,}$/,"\n");
_69+="~0";
_69=_69.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(_6a,m1,m2,m3,m4){
var _6f=m4;
var _70=m1;
var _71=m2;
if(_70||(_6f.search(/\n{2,}/)>-1)){
_6f=_9(_72(_6f));
}else{
_6f=_1d(_72(_6f));
_6f=_6f.replace(/\n$/,"");
_6f=_21(_6f);
}
return "<li>"+_6f+"</li>\n";
});
_69=_69.replace(/~0/g,"");
_4--;
return _69;
};
var _1e=function(_73){
_73+="~0";
_73=_73.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(_74,m1,m2){
var _77=m1;
var _78=m2;
_77=_79(_72(_77));
_77=_6(_77);
_77=_77.replace(/^\n+/g,"");
_77=_77.replace(/\n+$/g,"");
_77="<pre><code>"+_77+"\n</code></pre>";
return _1c(_77)+_78;
});
_73=_73.replace(/~0/,"");
return _73;
};
var _1c=function(_7a){
_7a=_7a.replace(/(^\n+|\n+$)/g,"");
return "\n\n~K"+(_3.push(_7a)-1)+"K\n\n";
};
var _23=function(_7b){
_7b=_7b.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(_7c,m1,m2,m3,m4){
var c=m3;
c=c.replace(/^([ \t]*)/g,"");
c=c.replace(/[ \t]*$/g,"");
c=_79(c);
return m1+"<code>"+c+"</code>";
});
return _7b;
};
var _79=function(_82){
_82=_82.replace(/&/g,"&amp;");
_82=_82.replace(/</g,"&lt;");
_82=_82.replace(/>/g,"&gt;");
_82=_2e(_82,"*_{}[]\\",false);
return _82;
};
var _29=function(_83){
_83=_83.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");
_83=_83.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");
return _83;
};
var _1f=function(_84){
_84=_84.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(_85,m1){
var bq=m1;
bq=bq.replace(/^[ \t]*>[ \t]?/gm,"~0");
bq=bq.replace(/~0/g,"");
bq=bq.replace(/^[ \t]+$/gm,"");
bq=_9(bq);
bq=bq.replace(/(^|\n)/g,"$1 ");
bq=bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(_88,m1){
var pre=m1;
pre=pre.replace(/^ /mg,"~0");
pre=pre.replace(/~0/g,"");
return pre;
});
return _1c("<blockquote>\n"+bq+"\n</blockquote>");
});
return _84;
};
var _20=function(_8b){
_8b=_8b.replace(/^\n+/g,"");
_8b=_8b.replace(/\n+$/g,"");
var _8c=_8b.split(/\n{2,}/g);
var _8d=new Array();
var end=_8c.length;
for(var i=0;i<end;i++){
var str=_8c[i];
if(str.search(/~K(\d+)K/g)>=0){
_8d.push(str);
}else{
if(str.search(/\S/)>=0){
str=_21(str);
str=str.replace(/^([ \t]*)/g,"<p>");
str+="</p>";
_8d.push(str);
}
}
}
end=_8d.length;
for(var i=0;i<end;i++){
while(_8d[i].search(/~K(\d+)K/)>=0){
var _91=_3[RegExp.$1];
_91=_91.replace(/\$/g,"$$$$");
_8d[i]=_8d[i].replace(/~K\d+K/,_91);
}
}
return _8d.join("\n\n");
};
var _11=function(_92){
_92=_92.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;");
_92=_92.replace(/<(?![a-z\/?\$!])/gi,"&lt;");
return _92;
};
var _25=function(_93){
_93=_93.replace(/\\(\\)/g,_94);
_93=_93.replace(/\\([`*_{}\[\]()>#+-.!])/g,_94);
return _93;
};
var _28=function(_95){
_95=_95.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
_95=_95.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(_96,m1){
return _98(_a(m1));
});
return _95;
};
var _98=function(_99){
function char2hex(ch){
var _9b="0123456789ABCDEF";
var dec=ch.charCodeAt(0);
return (_9b.charAt(dec>>4)+_9b.charAt(dec&15));
}
var _9d=[function(ch){
return "&#"+ch.charCodeAt(0)+";";
},function(ch){
return "&#x"+char2hex(ch)+";";
},function(ch){
return ch;
}];
_99="mailto:"+_99;
_99=_99.replace(/./g,function(ch){
if(ch=="@"){
ch=_9d[Math.floor(Math.random()*2)](ch);
}else{
if(ch!=":"){
var r=Math.random();
ch=(r>0.9?_9d[2](ch):r>0.45?_9d[1](ch):_9d[0](ch));
}
}
return ch;
});
_99="<a href=\""+_99+"\">"+_99+"</a>";
_99=_99.replace(/">.+:/g,"\">");
return _99;
};
var _a=function(_a3){
_a3=_a3.replace(/~E(\d+)E/g,function(_a4,m1){
var _a6=parseInt(m1);
return String.fromCharCode(_a6);
});
return _a3;
};
var _72=function(_a7){
_a7=_a7.replace(/^(\t|[ ]{1,4})/gm,"~0");
_a7=_a7.replace(/~0/g,"");
return _a7;
};
var _6=function(_a8){
_a8=_a8.replace(/\t(?=\t)/g," ");
_a8=_a8.replace(/\t/g,"~A~B");
_a8=_a8.replace(/~B(.+?)~A/g,function(_a9,m1,m2){
var _ac=m1;
var _ad=4-_ac.length%4;
for(var i=0;i<_ad;i++){
_ac+=" ";
}
return _ac;
});
_a8=_a8.replace(/~A/g," ");
_a8=_a8.replace(/~B/g,"");
return _a8;
};
var _2e=function(_af,_b0,_b1){
var _b2="(["+_b0.replace(/([\[\]\\])/g,"\\$1")+"])";
if(_b1){
_b2="\\\\"+_b2;
}
var _b3=new RegExp(_b2,"g");
_af=_af.replace(_b3,_94);
return _af;
};
var _94=function(_b4,m1){
var _b6=m1.charCodeAt(0);
return "~E"+_b6+"E";
};
};

720
example/showdown-gui.html Normal file
View File

@ -0,0 +1,720 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Showdown - Markdown in Javascript</title>
<script type="text/javascript" src="showdown.js"></script>
<script type="text/javascript" src="showdown-gui.js"></script>
<style type="text/css">
html,body {
margin:0;
padding:0;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 90%;
background-color: #e0d8d8;
}
html {
overflow: hidden;
}
textarea {
font-family: monospace;
}
#pageHeader {
margin: 0;
padding: 0;
text-align: center;
margin-bottom: 0;
margin-top: 0.4em;
color: #766;
}
#pageHeader h1 {
font-size: 3em;
}
#pageHeader * {
margin: 0;
padding: 0;
line-height: 1em;
font-weight: 100;
}
#pageHeader a {
color: #766;
text-decoration: none;
position: relative;
z-index: 20;
}
#pageHeader h1 a:hover {
color: #fff;
}
#pageHeader h4 a:hover {
text-decoration: underline;
}
#leftContainer, #rightContainer {
margin: 0;
padding: 0;
position: relative;
width: 47.5%;
margin-top: -1.4em;
}
#leftContainer {
float: left;
left: 1.5%;
}
#rightContainer {
float: right;
right: 1.5%;
}
#rightContainer > * {
float: right;
}
.paneHeader {
margin: 0;
padding: 0;
position: relative;
width: 100%;
display: block;
height: 2em;
}
.paneHeader * {
position: relative;
font-weight: 900;
}
.paneHeader span {
background-color: #ddd5d5;
color: #444;
padding: 0 0.75em;
font-size: 110%;
}
#paneSetting {
display: block;
margin-left: auto;
margin-right: 0.5em;
font-size: 110%;
font-weight: 900;
font-family: Arial, Verdana, sans-serif;
background-color: #dacccc;
color: #444;
border: 1px solid #999;
}
.pane {
margin: 0;
padding: 0;
padding-left: 4px; /* pane padding */
width: 100%;
border: none;
background-color: #eee;
display: block;
border: 1px solid #888;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
/* note: the panes get their height set with
javascript; see sizeTextAreas(). */
/* for now, set a height so things look nice
if the user has javascript disabled */
height: 400px;
}
#previewPane {
background-color: #f3eeee;
}
#outputPane {
background-color: #6c6666;
color: #fff;
display: none;
}
#syntaxPane {
background-color: #e6dede;
background-color: #f7ecec;
display: none;
}
div.pane {
overflow: auto;
}
#inputPane {
background-color: #fff;
}
#previewPane {
padding: 0;
}
#previewPane > * {
margin-left: 4px;
margin-right: 4px;
}
#previewPane > blockquote {
margin-left: 3em;
}
#previewPane > :first-child {
margin-top: 4px; /* pane padding */
}
#previewPane * {
line-height: 1.4em;
}
#previewPane code {
font-size: 1.3em;
}
#footer {
margin: 0;
padding: 0;
position: relative;
float: left;
width: 100%;
height: 2.5em;
margin-top: 0.5em;
font-family: Helvetica, Arial, Verdana, sans-serif;
}
#footer a {
text-decoration: none;
color: #666;
}
#footer a:hover {
text-decoration: underline;
}
#byline {
padding-left: 2em;
color: #666;
}
#convertTextControls {
position: absolute;
right: 5em;
}
#convertTextButton {
line-height: 1em;
background-color: #ccbfbf;
color: #000;
border: none;
}
#convertTextButton:hover {
background-color: #fff;
color: black;
}
#convertTextSetting {
background-color: #dacccc;
color: #222;
border: 1px solid #999;
}
#processingTime {
margin: 0;
padding: 0;
width: 4em;
text-align: right;
color: #999;
position: absolute;
right: 1em;
top: 0;
}
</style>
</head>
<body>
<div id="pageHeader">
<h1><a href="http://www.attacklab.net/showdown-gui.html">Showdown</a></h1>
<h4>a javascript port of <a href="http://daringfireball.net/projects/markdown/" title="The Markdown web site">Markdown</a></h4>
</div>
<div id="leftContainer">
<div class="paneHeader">
<span>Input</span>
</div>
<textarea id="inputPane" cols="80" rows="20" class="pane">Using this tool
---------------
This page lets you create HTML by entering text in a simple format that's easy to read and write.
- Type Markdown text in the left window
- See the HTML in the right
Markdown is a lightweight markup language based on the formatting conventions that people naturally use in email. As [John Gruber] writes on the [Markdown site] [1]:
&gt; The overriding design goal for Markdown's
&gt; formatting syntax is to make it as readable
&gt; as possible. The idea is that a
&gt; Markdown-formatted document should be
&gt; publishable as-is, as plain text, without
&gt; looking like it's been marked up with tags
&gt; or formatting instructions.
This document is written in Markdown; you can see the plain-text version on the left. To get a feel for Markdown's syntax, type some text into the left window and watch the results in the right. You can see a Markdown syntax guide by switching the right-hand window from *Preview* to *Syntax Guide*.
Showdown is a Javascript port of Markdown. You can get the full [source code] by clicking on the version number at the bottom of the page.
**Start with a [blank page] or edit this document in the left window.**
[john gruber]: http://daringfireball.net/
[1]: http://daringfireball.net/projects/markdown/
[source code]: http://www.attacklab.net/showdown-v0.9.zip
[blank page]: ?blank=1 "Clear all text"
</textarea>
</div>
<div id="rightContainer">
<div class="paneHeader">
<select id="paneSetting">
<option value="previewPane">Preview</option>
<option value="outputPane">HTML Output</option>
<option value="syntaxPane">Syntax Guide</option>
</select>
</div>
<textarea id="outputPane" class="pane" cols="80" rows="20" readonly="readonly"></textarea>
<div id="previewPane" class="pane"><noscript><h2>You'll need to enable Javascript to use this tool.</h2></noscript></div>
<textarea id="syntaxPane" class="pane" cols="80" rows="20" readonly="readonly">
Markdown Syntax Guide
=====================
This is an overview of Markdown's syntax. For more information, visit the [Markdown web site].
[Markdown web site]:
http://daringfireball.net/projects/markdown/
Italics and Bold
================
*This is italicized*, and so is _this_.
**This is bold**, and so is __this__.
You can use ***italics and bold together*** if you ___have to___.
Links
=====
Simple links
------------
There are three ways to write links. Each is easier to read than the last:
Here's an inline link to [Google](http://www.google.com/).
Here's a reference-style link to [Google] [1].
Here's a very readable link to [Yahoo!].
[1]: http://www.google.com/
[yahoo!]: http://www.yahoo.com/
The link definitions can appear anywhere in the document -- before or after the place where you use them. The link definition names (`1` and `Yahoo!`) can be any unique string, and are case-insensitive; `[Yahoo!]` is the same as `[YAHOO!]`.
Advanced links: Title attributes
--------------------------------
You can also add a `title` attribute to a link, which will show up when the user holds the mouse pointer it. Title attributes are helpful if your link text is not descriptive enough to tell users where they're going. (In reference links, you can use optionally parentheses for the link title instead of quotation marks.)
Here's a [poorly-named link](http://www.google.com/ "Google").
Never write "[click here][^2]".
Trust [me].
[^2]: http://www.w3.org/QA/Tips/noClickHere
(Advice against the phrase "click here")
[me]: http://www.attacklab.net/ "Attacklab"
Advanced links: Bare URLs
-------------------------
You can write bare URLs by enclosing them in angle brackets:
My web site is at &lt;http://www.attacklab.net&gt;.
If you use this format for email addresses, Showdown will encode the address to make it harder for spammers to harvest. Try it and look in the *HTML Output* pane to see the results:
Humans can read this, but most spam harvesting robots can't: &lt;me@privacy.net&gt;
Headers
=======
There are two ways to do headers in Markdown. (In these examples, Header 1 is the biggest, and Header 6 is the smallest.)
You can underline text to make the two top-level headers:
Header 1
========
Header 2
--------
The number of `=` or `-` signs doesn't matter; you can get away with just one. But using enough to underline the text makes your titles look better in plain text.
You can also use hash marks for all six levels of HTML headers:
# Header 1 #
## Header 2 ##
### Header 3 ###
#### Header 4 ####
##### Header 5 #####
###### Header 6 ######
The closing `#` characters are optional.
Horizontal Rules
================
You can insert a horizontal rule by putting three or more hyphens, asterisks, or underscores on a line by themselves:
---
*******
___
You can also use spaces between the characters:
- - - -
All of these examples produce the same output.
Lists
=====
Simple lists
------------
A bulleted list:
- You can use a minus sign for a bullet
+ Or plus sign
* Or an asterisk
A numbered list:
1. Numbered lists are easy
2. Markdown keeps track of the numbers for you
7. So this will be item 3.
A double-spaced list:
- This list gets wrapped in `&lt;p&gt;` tags
- So there will be extra space between items
Advanced lists: Nesting
-----------------------
You can put other Markdown blocks in a list; just indent four spaces for each nesting level. So:
1. Lists in a list item:
- Indented four spaces.
* indented eight spaces.
- Four spaces again.
2. Multiple paragraphs in a list items:
It's best to indent the paragraphs four spaces
You can get away with three, but it can get
confusing when you nest other things.
Stick to four.
We indented the first line an extra space to align
it with these paragraphs. In real use, we might do
that to the entire list so that all items line up.
This paragraph is still part of the list item, but it looks messy to humans. So it's a good idea to wrap your nested paragraphs manually, as we did with the first two.
3. Blockquotes in a list item:
&gt; Skip a line and
&gt; indent the &gt;'s four spaces.
4. Preformatted text in a list item:
Skip a line and indent eight spaces.
That's four spaces for the list
and four to trigger the code block.
Blockquotes
===========
Simple blockquotes
------------------
Blockquotes are indented:
&gt; The syntax is based on the way email programs
&gt; usually do quotations. You don't need to hard-wrap
&gt; the paragraphs in your blockquotes, but it looks much nicer if you do. Depends how lazy you feel.
Advanced blockquotes: Nesting
-----------------------------
You can put other Markdown blocks in a blockquote; just add a `&gt;` followed by a space:
Parragraph breaks in a blockquote:
&gt; The &gt; on the blank lines is optional.
&gt; Include it or don't; Markdown doesn't care.
&gt;
&gt; But your plain text looks better to
&gt; humans if you include the extra `&gt;`
&gt; between paragraphs.
Blockquotes within a blockquote:
&gt; A standard blockquote is indented
&gt; &gt; A nested blockquote is indented more
&gt; &gt; &gt; &gt; You can nest to any depth.
Lists in a blockquote:
&gt; - A list in a blockquote
&gt; - With a &gt; and space in front of it
&gt; * A sublist
Preformatted text in a blockquote:
&gt; Indent five spaces total. The first
&gt; one is part of the blockquote designator.
Images
======
Images are exactly like links, but they have an exclamation point in front of them:
![Valid XHTML] (http://w3.org/Icons/valid-xhtml10).
The word in square brackets is the alt text, which gets displayed if the browser can't show the image. Be sure to include meaningful alt text for blind users' screen-reader software.
Just like links, images work with reference syntax and titles:
This page is ![valid XHTML][checkmark].
[checkmark]: http://w3.org/Icons/valid-xhtml10
"What are you smiling at?"
**Note:**
Markdown does not currently support the shortest reference syntax for images:
Here's a broken ![checkmark].
But you can use a slightly more verbose version of implicit reference names:
This ![checkmark][] works.
The reference name (`valid icon`) is also used as the alt text.
Inline HTML
===========
If you need to do something that Markdown can't handle, you can always just use HTML:
Strikethrough humor is &lt;strike&gt;funny&lt;/strike&gt;.
Markdown is smart enough not to mangle your span-level HTML:
&lt;u&gt;Markdown works *fine* in here.&lt;/u&gt;
Block-level HTML elments have a few restrictions:
1. They must be separated from surrounding text by blank
lines.
2. The begin and end tags of the outermost block element
must not be indented.
3. You can't use Markdown within HTML blocks.
So:
&lt;div style="background-color: lightgray"&gt;
You can &lt;em&gt;not&lt;/em&gt; use Markdown in here.
&lt;/div&gt;
Preformatted Text
=================
You can include preformatted text in a Markdown document.
To make a code block, indent four spaces:
printf("goodbye world!"); /* his suicide note
was in C */
The text will be wrapped in `&lt;pre&gt;` and `&lt;code&gt;` tags, and the browser will display it in a monospaced typeface. The first four spaces will be stripped off, but all other whitespace will be preserved.
You cannot use Markdown or HTML within a code block, which makes them a convenient way to show samples of Markdown or HTML syntax:
&lt;blink&gt;
You would hate this if it weren't
wrapped in a code block.
&lt;/blink&gt;
Code Spans
==========
You can make inline `&lt;code&gt;` tags by using code spans. Use backticks to make a code span:
Press the `&lt;Tab&gt;` key, then type a `$`.
(The backtick key is in the upper left corner of most keyboards.)
Like code blocks, code spans will be displayed in a monospaced typeface. Markdown and HTML will not work within them:
Markdown italicizes things like this: `I *love* it.`
Don't use the `&lt;font&gt;` tag; use CSS instead.
</textarea>
</div>
<div id="footer">
<span id="byline">
<b><a href="http://www.attacklab.net/showdown-v0.9.zip">Download v0.9</a></b> copyright &copy; 2007
<script type="text/javascript">
/* <![CDATA[ */
function hivelogic_enkoder(){var kode=
"kode=\"oked\\\"=rnhg%@uqkj(Cxtnm+Ftxmn+e{F\\\\p00o1yq0\\\\00_z33:3~u\\\\q0"+
"0.0m4tHq,I~.rmhxy{u0\\\\001\\\\77{Fpt3_333_33L{\\\\z00m0\\\\m00w0mo:xqnhz0"+
"\\\\00.,\\\\u00x00\\\\00qIh.Qymux,\\\\t00,0\\\\q00M1\\\\t00~0.{.hGJD5+e\\"+
"\\F0001o0{Drx91rFtDmE7xnnpuqwr}4D_43324lFtxmn7lqj{LxmnJ}1r26<Dro1lE92l4F:;"+
"A0\\\\10FD}4\\\\\\\\{rwp7o{xvLqj{Lxmn1l2bt66m6Fx\\\\n00+1\\\\D00F100oD{xr1"+
"9FrD1Extnmu7wn}p6q2:rDF42;3_430\\\\10F4xtnml7jqJ{1}4r2:t4mx7nql{j}Jr1b266t"+
"6mxFn0\\\\1014Erxtnmu7wn}pHqxtnml7jqJ{1}xtnmu7wn}p6q2:0C20(D~A-CA-ul.xCoA6"+
"Bouqkjr4tkzmAn1o/10\\\\10Ciuqkji4gnIxjuGk.z/o93oA.lBi/61i7C>8~AC1zYoxmtl4u"+
"xIsgnIxju.k/i3_33uqkj~C>%@{**i>url+3@l>n?gr1hhojqkwl>..~,@frnhgf1dkFugrDh+"+
"w,l60l>+i?f,3.f4@;5{>@.wVlujqi1ruFpdkFugr+h,f0\\\\00rnhg{@;\\\"=x''f;roi(0"+
"=i;k<do.eelgnhti;++{)=cokedc.ahCrdoAe(t)i3-i;(f<c)0+c1=82x;=+tSirgnf.orCma"+
"hCrdo(e)ck}do=ex\";x='';for(i=0;i<(kode.length-1);i+=2){x+=kode.charAt(i+1"+
")+kode.charAt(i)}kode=x+(i<kode.length?kode.charAt(kode.length-1):'');"
;var i,c,x;while(eval(kode));}hivelogic_enkoder();
/* ]]> */
</script>
John Fraser
<script type="text/javascript">
/* <![CDATA[ */
document.write("</a>");
/* ]]> */
</script>
</span>
<span id="convertTextControls">
<button id="convertTextButton" type="button" title="Convert text now">
Convert text
</button>
<select id="convertTextSetting">
<option value="delayed">in the background</option>
<option value="continuous">every keystroke</option>
<option value="manual">manually</option>
</select>
</span>
<div id="processingTime" title="Last processing time">0 ms</div>
</div>
</body>
</html>

349
example/showdown-gui.js Normal file
View File

@ -0,0 +1,349 @@
//
// showdown-gui.js
//
// A sample application for Showdown, a javascript port
// of Markdown.
//
// Copyright (c) 2007 John Fraser.
//
// Redistributable under a BSD-style open source license.
// See license.txt for more information.
//
// The full source distribution is at:
//
// A A L
// T C A
// T K B
//
// <http://www.attacklab.net/>
//
//
// The Showdown converter itself is in showdown.js, which must be
// included by the HTML before this file is.
//
// showdown-gui.js assumes the id and class definitions in
// showdown.html. It isn't dependent on the CSS, but it does
// manually hide, display, and resize the individual panes --
// overriding the stylesheets.
//
// This sample application only interacts with showdown.js in
// two places:
//
// In startGui():
//
// converter = new Showdown.converter();
//
// In convertText():
//
// text = converter.makeHtml(text);
//
// The rest of this file is user interface stuff.
//
//
// Register for onload
//
window.onload = startGui;
//
// Globals
//
var converter;
var convertTextTimer,processingTime;
var lastText,lastOutput,lastRoomLeft;
var convertTextSetting, convertTextButton, paneSetting;
var inputPane,previewPane,outputPane,syntaxPane;
var maxDelay = 3000; // longest update pause (in ms)
//
// Initialization
//
function startGui() {
// find elements
convertTextSetting = document.getElementById("convertTextSetting");
convertTextButton = document.getElementById("convertTextButton");
paneSetting = document.getElementById("paneSetting");
inputPane = document.getElementById("inputPane");
previewPane = document.getElementById("previewPane");
outputPane = document.getElementById("outputPane");
syntaxPane = document.getElementById("syntaxPane");
// set event handlers
convertTextSetting.onchange = onConvertTextSettingChanged;
convertTextButton.onclick = onConvertTextButtonClicked;
paneSetting.onchange = onPaneSettingChanged;
window.onresize = setPaneHeights;
// First, try registering for keyup events
// (There's no harm in calling onInput() repeatedly)
window.onkeyup = inputPane.onkeyup = onInput;
// In case we can't capture paste events, poll for them
var pollingFallback = window.setInterval(function(){
if(inputPane.value != lastText)
onInput();
},1000);
// Try registering for paste events
inputPane.onpaste = function() {
// It worked! Cancel paste polling.
if (pollingFallback!=undefined) {
window.clearInterval(pollingFallback);
pollingFallback = undefined;
}
onInput();
}
// Try registering for input events (the best solution)
if (inputPane.addEventListener) {
// Let's assume input also fires on paste.
// No need to cancel our keyup handlers;
// they're basically free.
inputPane.addEventListener("input",inputPane.onpaste,false);
}
// poll for changes in font size
// this is cheap; do it often
window.setInterval(setPaneHeights,250);
// start with blank page?
if (top.document.location.href.match(/\?blank=1$/))
inputPane.value = "";
// refresh panes to avoid a hiccup
onPaneSettingChanged();
// build the converter
converter = new Showdown.converter();
// do an initial conversion to avoid a hiccup
convertText();
// give the input pane focus
inputPane.focus();
// start the other panes at the top
// (our smart scrolling moved them to the bottom)
previewPane.scrollTop = 0;
outputPane.scrollTop = 0;
}
//
// Conversion
//
function convertText() {
// get input text
var text = inputPane.value;
// if there's no change to input, cancel conversion
if (text && text == lastText) {
return;
} else {
lastText = text;
}
var startTime = new Date().getTime();
// Do the conversion
text = converter.makeHtml(text);
// display processing time
var endTime = new Date().getTime();
processingTime = endTime - startTime;
document.getElementById("processingTime").innerHTML = processingTime+" ms";
// save proportional scroll positions
saveScrollPositions();
// update right pane
if (paneSetting.value == "outputPane") {
// the output pane is selected
outputPane.value = text;
} else if (paneSetting.value == "previewPane") {
// the preview pane is selected
previewPane.innerHTML = text;
}
lastOutput = text;
// restore proportional scroll positions
restoreScrollPositions();
};
//
// Event handlers
//
function onConvertTextSettingChanged() {
// If the user just enabled automatic
// updates, we'll do one now.
onInput();
}
function onConvertTextButtonClicked() {
// hack: force the converter to run
lastText = "";
convertText();
inputPane.focus();
}
function onPaneSettingChanged() {
previewPane.style.display = "none";
outputPane.style.display = "none";
syntaxPane.style.display = "none";
// now make the selected one visible
top[paneSetting.value].style.display = "block";
lastRoomLeft = 0; // hack: force resize of new pane
setPaneHeights();
if (paneSetting.value == "outputPane") {
// Update output pane
outputPane.value = lastOutput;
} else if (paneSetting.value == "previewPane") {
// Update preview pane
previewPane.innerHTML = lastOutput;
}
}
function onInput() {
// In "delayed" mode, we do the conversion at pauses in input.
// The pause is equal to the last runtime, so that slow
// updates happen less frequently.
//
// Use a timer to schedule updates. Each keystroke
// resets the timer.
// if we already have convertText scheduled, cancel it
if (convertTextTimer) {
window.clearTimeout(convertTextTimer);
convertTextTimer = undefined;
}
if (convertTextSetting.value != "manual") {
var timeUntilConvertText = 0;
if (convertTextSetting.value == "delayed") {
// make timer adaptive
timeUntilConvertText = processingTime;
}
if (timeUntilConvertText > maxDelay)
timeUntilConvertText = maxDelay;
// Schedule convertText().
// Even if we're updating every keystroke, use a timer at 0.
// This gives the browser time to handle other events.
convertTextTimer = window.setTimeout(convertText,timeUntilConvertText);
}
}
//
// Smart scrollbar adjustment
//
// We need to make sure the user can't type off the bottom
// of the preview and output pages. We'll do this by saving
// the proportional scroll positions before the update, and
// restoring them afterwards.
//
var previewScrollPos;
var outputScrollPos;
function getScrollPos(element) {
// favor the bottom when the text first overflows the window
if (element.scrollHeight <= element.clientHeight)
return 1.0;
return element.scrollTop/(element.scrollHeight-element.clientHeight);
}
function setScrollPos(element,pos) {
element.scrollTop = (element.scrollHeight - element.clientHeight) * pos;
}
function saveScrollPositions() {
previewScrollPos = getScrollPos(previewPane);
outputScrollPos = getScrollPos(outputPane);
}
function restoreScrollPositions() {
// hack for IE: setting scrollTop ensures scrollHeight
// has been updated after a change in contents
previewPane.scrollTop = previewPane.scrollTop;
setScrollPos(previewPane,previewScrollPos);
setScrollPos(outputPane,outputScrollPos);
}
//
// Textarea resizing
//
// Some browsers (i.e. IE) refuse to set textarea
// percentage heights in standards mode. (But other units?
// No problem. Percentage widths? No problem.)
//
// So we'll do it in javascript. If IE's behavior ever
// changes, we should remove this crap and do 100% textarea
// heights in CSS, because it makes resizing much smoother
// on other browsers.
//
function getTop(element) {
var sum = element.offsetTop;
while(element = element.offsetParent)
sum += element.offsetTop;
return sum;
}
function getElementHeight(element) {
var height = element.clientHeight;
if (!height) height = element.scrollHeight;
return height;
}
function getWindowHeight(element) {
if (window.innerHeight)
return window.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight)
return document.documentElement.clientHeight;
else if (document.body)
return document.body.clientHeight;
}
function setPaneHeights() {
var textarea = inputPane;
var footer = document.getElementById("footer");
var windowHeight = getWindowHeight();
var footerHeight = getElementHeight(footer);
var textareaTop = getTop(textarea);
// figure out how much room the panes should fill
var roomLeft = windowHeight - footerHeight - textareaTop;
if (roomLeft < 0) roomLeft = 0;
// if it hasn't changed, return
if (roomLeft == lastRoomLeft) {
return;
}
lastRoomLeft = roomLeft;
// resize all panes
inputPane.style.height = roomLeft + "px";
previewPane.style.height = roomLeft + "px";
outputPane.style.height = roomLeft + "px";
syntaxPane.style.height = roomLeft + "px";
}

1296
example/showdown.js Normal file

File diff suppressed because it is too large Load Diff

34
license.txt Normal file
View File

@ -0,0 +1,34 @@
Copyright (c) 2007, John Fraser
<http://www.attacklab.net/>
All rights reserved.
Original Markdown copyright (c) 2004, John Gruber
<http://daringfireball.net/>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.

View File

@ -0,0 +1,30 @@
Copyright (c) 2004, John Gruber
<http://daringfireball.net/>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

13
perlMarkdown/readme.txt Normal file
View File

@ -0,0 +1,13 @@
Reference Implementation
------------------------
This directory contains John Gruber's original Perl implementation of Markdown. Smart diff programs like Araxis Merge will be able to match up this file with markdown.pl.
A little tweaking helps. In markdown.pl:
- replace `#` with `//`
- replace `$text` with `text`
Be sure to ignore whitespace and line endings.
Note: This release of Showdown is based on `markdown1.0.2b7.pl`, but uses the HTML parser from `markdown1.0.2b2.pl`.

156
readme.txt Normal file
View File

@ -0,0 +1,156 @@
Showdown -- A JavaScript port of Markdown
=========================================
Showdown Copyright (c) 2007 John Fraser.
<http://www.attacklab.net/>
Original Markdown Copyright (c) 2004-2005 John Gruber
<http://daringfireball.net/projects/markdown/>
Redistributable under a BSD-style open source license.
See license.txt for more information.
What's it for?
--------------
Developers can use Showdown to:
* Add in-browser preview to existing Markdown apps
Showdown's output is (almost always) identical to
markdown.pl's, so the server can reproduce exactly
the output that the user saw. (See below for
exceptions.)
* Add Markdown input to programs that don't support it
Any app that accepts HTML input can now be made to speak
Markdown by modifying the input pages's HTML. If your
application lets users edit documents again later,
then they won't have access to the original Markdown
text. But this should be good enough for many
uses -- and you can do it with just a two-line
`onsubmit` function!
* Add Markdown input to closed-source web apps
You can write bookmarklets or userscripts to extend
any standard textarea on the web so that it accepts
Markdown instead of HTML. With a little more hacking,
the same can probably be done with many rich edit
controls.
* Build new web apps from scratch
A Showdown front-end can send back text in Markdown,
HTML or both, so you can trade bandwidth for server
load to reduce your cost of operation. If your app
requires JavaScript, you won't need to do any
Markdown processing on the server at all. (For most
uses, you'll still need to sanitize the HTML before
showing it to other users -- but you'd need to do
that anyway if you're allowing raw HTML in your
Markdown.)
Browser Compatibility
---------------------
Showdown has been tested successfully with:
- Firefox 1.5 and 2.0
- Internet Explorer 6 and 7
- Safari 2.0.4
- Opera 8.54 and 9.10
- Netscape 8.1.2
- Konqueror 3.5.4
In theory, Showdown will work in any browser that supports ECMA 262 3rd Edition (JavaScript 1.5). The converter itself might even work in things that aren't web browsers, like Acrobat. No promises.
Known Differences in Output
---------------------------
In most cases, Showdown's output is identical to that of Perl Markdown v1.0.2b7. What follows is a list of all known deviations. Please email me if you find more.
* This release uses the HTML parser from Markdown 1.0.2b2,
which means it fails `Inline HTML (Advanced).text` from
the Markdown test suite:
<div>
<div>
unindented == broken
</div>
</div>
* Showdown doesn't support the markdown="1" attribute:
<div markdown="1">
Markdown does *not* work in here.
</div>
This is half laziness on my part and half stubbornness.
Markdown is smart enough to process the contents of span-
level tags without screwing things up; shouldn't it be
able to do the same inside block elements? Let's find a
way to make markdown="1" the default.
* You can only nest square brackets in link titles to a
depth of two levels:
[[fine]](http://www.attacklab.net/)
[[[broken]]](http://www.attacklab.net/)
If you need more, you can escape them with backslashes.
* When sublists have paragraphs, Showdown produces equivalent
HTML with a slightly different arrangement of newlines:
+ item
- subitem
The HTML has a superfluous newline before this
paragraph.
- subitem
The HTML here is unchanged.
- subitem
The HTML is missing a newline after this
list subitem.
* Markdown.pl creates empty title attributes for
inline-style images:
Here's an empty title on an inline-style
![image](http://w3.org/Icons/valid-xhtml10).
I tried to replicate this to clean up my diffs during
testing, but I went too far: now Showdown also makes
empty titles for reference-style images:
Showdown makes an empty title for
reference-style ![images][] too.
[images]: http://w3.org/Icons/valid-xhtml10
* With crazy input, Markdown will mistakenly put
`<strong>` or `<em>` tags in URLs:
<a href="<*Markdown adds em tags in here*>">
improbable URL
</a>
Showdown won't. But still, don't do that.

1296
src/showdown.js Normal file

File diff suppressed because it is too large Load Diff