fuel 0.3.34 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f44b806e44773aaef00d1ed770577bedeffce5ca
4
- data.tar.gz: 9a25014011ec7c17cfbc6f96ec322d509948f308
3
+ metadata.gz: 45c04536e15ee5917fefb99040e07e6743eb74e5
4
+ data.tar.gz: 341eac3d86051e8a5c95fac7da25da2f7bfa858d
5
5
  SHA512:
6
- metadata.gz: 3a66b012d71eb03806bf08db3801125ad987f9d528facb27c169d0bbfc7fbee29dd4cf0fdadad478b67f83a5b4ee849c1e4f6f95cd8386311fc98610a794c9ea
7
- data.tar.gz: b1485b5dd9e31278595c5f60a9137d0e58c5c0cb3c998f8d3134fd24ea0bc69d0ee580c324ae3e254e79d4eeff9fffeae5c5462d2b6ffac52441497030c87ca2
6
+ metadata.gz: cd4c7fc2e90cb8ae3387071ed9c4ca3acd0e23600e643837cd30def9876959ac1616cf322a21efaa94989a3429c56597a9cac5a34c19419ea55e8f2a68d12620
7
+ data.tar.gz: 575db881a8aa1c34338b365236b65cb69375967ebf9c9434878829cefc9ffa80f904ab8039d04b0bef67d8ca468b681b0dce8fcf659f0e54f269249299dc358f
@@ -18,6 +18,8 @@
18
18
  //= require pickadate/picker
19
19
  //= require pickadate/picker.date
20
20
  //= require fuel/pickadate-datepicker
21
+ //= require fuel/to-markdown
22
+ //= require fuel/showdown
21
23
  //= require fuel/posts
22
24
  //= require fuel/wysihtml5x-toolbar.min.js
23
25
  //= require fuel/advanced_and_extended
@@ -1,5 +1,8 @@
1
1
  $(function(){
2
2
 
3
+ var $markdownField = $("#fuel_post_content_markdown");
4
+ var $htmlField = $("#fuel_post_content_html");
5
+
3
6
  $("#fuel_post_published").on("change", function(){
4
7
  var val = $(this).val();
5
8
  var $publishedAtGroup = $("#publishedAtGroup");
@@ -13,4 +16,89 @@ $(function(){
13
16
  }
14
17
  });
15
18
 
19
+ var findFormat = function(){
20
+ return $("#fuel_post_format").val();
21
+ }
22
+
23
+ var isMarkdown = function(){
24
+ return findFormat() == "markdown"
25
+ }
26
+
27
+ setCorrectEditor = function(){
28
+ var format = findFormat();
29
+
30
+ var $editors = $(".editor-area");
31
+ $editors.find("textarea").prop("disabled", true);
32
+ $editors.hide();
33
+
34
+ var $activeEditor = $(".editor-area*[data-format='" + format + "']");
35
+ $activeEditor.find("textarea").prop("disabled", false);
36
+ $activeEditor.show();
37
+
38
+ if (isMarkdown()){
39
+ wysihtml5Editor.disable();
40
+ } else {
41
+ wysihtml5Editor.enable();
42
+ };
43
+ };
44
+
45
+ var formatContent = function(){
46
+ var format = findFormat();
47
+ if (isMarkdown()){
48
+ var html = wysihtml5Editor.getValue(),
49
+ markdown = toMarkdown(html);
50
+ $markdownField.val(markdown);
51
+ } else {
52
+ var markdown = $markdownField.val(),
53
+ converter = new showdown.Converter(),
54
+ html = converter.makeHtml(markdown);
55
+
56
+ wysihtml5Editor.setValue(html);
57
+ }
58
+ };
59
+
60
+ var retrieveCurrentContent = function(){
61
+ if (isMarkdown()){
62
+ var content = $markdownField.val();
63
+ } else {
64
+ var content = wysihtml5Editor.getValue();
65
+ }
66
+ return content;
67
+ };
68
+
69
+ var setContent = function(content){
70
+ if (isMarkdown()){
71
+ wysihtml5Editor.setValue(content);
72
+ } else {
73
+ $markdownField.val(content);
74
+ }
75
+ }
76
+
77
+ $("#fuel_post_format").on("change", function(){
78
+ setCorrectEditor();
79
+ formatContent();
80
+ });
81
+
82
+ $(".trigger-preview").on("click", function(e){
83
+ e.preventDefault();
84
+ var url = $(this).data("url");
85
+
86
+ var content = retrieveCurrentContent();
87
+ $.ajax({
88
+ dataType: "json",
89
+ url: url,
90
+ type: "post",
91
+ data: {
92
+ fuel_post: {
93
+ content: content
94
+ }
95
+ },
96
+ success: function(data){
97
+ $("#render-content").replaceWith(data.html);
98
+ }
99
+ });
100
+ $('.js-menu,.js-menu-screen').toggleClass('is-visible');
101
+ $('.js-menu').parents('body').toggleClass('is-fixed');
102
+ });
103
+
16
104
  });
@@ -0,0 +1,4 @@
1
+ /*! showdown 07-10-2015 */
2
+
3
+ (function(){function a(a){"use strict";var b={omitExtraWLInCodeBlocks:{"default":!1,describe:"Omit the default extra whiteline added to code blocks",type:"boolean"},noHeaderId:{"default":!1,describe:"Turn on/off generated header id",type:"boolean"},prefixHeaderId:{"default":!1,describe:"Specify a prefix to generated header ids",type:"string"},headerLevelStart:{"default":!1,describe:"The header blocks level start",type:"integer"},parseImgDimensions:{"default":!1,describe:"Turn on/off image dimension parsing",type:"boolean"},simplifiedAutoLink:{"default":!1,describe:"Turn on/off GFM autolink style",type:"boolean"},literalMidWordUnderscores:{"default":!1,describe:"Parse midword underscores as literal underscores",type:"boolean"},strikethrough:{"default":!1,describe:"Turn on/off strikethrough support",type:"boolean"},tables:{"default":!1,describe:"Turn on/off tables support",type:"boolean"},tablesHeaderId:{"default":!1,describe:"Add an id to table headers",type:"boolean"},ghCodeBlocks:{"default":!0,describe:"Turn on/off GFM fenced code blocks support",type:"boolean"},tasklists:{"default":!1,describe:"Turn on/off GFM tasklist support",type:"boolean"},smoothLivePreview:{"default":!1,describe:"Prevents weird effects in live previews due to incomplete input",type:"boolean"}};if(a===!1)return JSON.parse(JSON.stringify(b));var c={};for(var d in b)b.hasOwnProperty(d)&&(c[d]=b[d]["default"]);return c}function b(a,b){"use strict";var c=b?"Error in "+b+" extension->":"Error in unnamed extension",e={valid:!0,error:""};d.helper.isArray(a)||(a=[a]);for(var f=0;f<a.length;++f){var g=c+" sub-extension "+f+": ",h=a[f];if("object"!=typeof h)return e.valid=!1,e.error=g+"must be an object, but "+typeof h+" given",e;if(!d.helper.isString(h.type))return e.valid=!1,e.error=g+'property "type" must be a string, but '+typeof h.type+" given",e;var i=h.type=h.type.toLowerCase();if("language"===i&&(i=h.type="lang"),"html"===i&&(i=h.type="output"),"lang"!==i&&"output"!==i)return e.valid=!1,e.error=g+"type "+i+' is not recognized. Valid values: "lang" or "output"',e;if(h.filter){if("function"!=typeof h.filter)return e.valid=!1,e.error=g+'"filter" must be a function, but '+typeof h.filter+" given",e}else{if(!h.regex)return e.valid=!1,e.error=g+'extensions must define either a "regex" property or a "filter" method',e;if(d.helper.isString(h.regex)&&(h.regex=new RegExp(h.regex,"g")),!h.regex instanceof RegExp)return e.valid=!1,e.error=g+'"regex" property must either be a string or a RegExp object, but '+typeof h.regex+" given",e;if(d.helper.isUndefined(h.replace))return e.valid=!1,e.error=g+'"regex" extensions must implement a replace string or function',e}if(d.helper.isUndefined(h.filter)&&d.helper.isUndefined(h.regex))return e.valid=!1,e.error=g+"output extensions must define a filter property",e}return e}function c(a,b){"use strict";var c=b.charCodeAt(0);return"~E"+c+"E"}var d={},e={},f={},g=a(!0),h={github:{omitExtraWLInCodeBlocks:!0,prefixHeaderId:"user-content-",simplifiedAutoLink:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0},vanilla:a(!0)};d.helper={},d.extensions={},d.setOption=function(a,b){"use strict";return g[a]=b,this},d.getOption=function(a){"use strict";return g[a]},d.getOptions=function(){"use strict";return g},d.resetOptions=function(){"use strict";g=a(!0)},d.setFlavor=function(a){"use strict";if(h.hasOwnProperty(a)){var b=h[a];for(var c in b)b.hasOwnProperty(c)&&(g[c]=b[c])}},d.getDefaultOptions=function(b){"use strict";return a(b)},d.subParser=function(a,b){"use strict";if(d.helper.isString(a)){if("undefined"==typeof b){if(e.hasOwnProperty(a))return e[a];throw Error("SubParser named "+a+" not registered!")}e[a]=b}},d.extension=function(a,c){"use strict";if(!d.helper.isString(a))throw Error("Extension 'name' must be a string");if(a=d.helper.stdExtName(a),d.helper.isUndefined(c)){if(!f.hasOwnProperty(a))throw Error("Extension named "+a+" is not registered!");return f[a]}"function"==typeof c&&(c=c()),d.helper.isArray(c)||(c=[c]);var e=b(c,a);if(!e.valid)throw Error(e.error);f[a]=c},d.getAllExtensions=function(){"use strict";return f},d.removeExtension=function(a){"use strict";delete f[a]},d.resetExtensions=function(){"use strict";f={}},d.validateExtension=function(a){"use strict";var c=b(a,null);return c.valid?!0:(console.warn(c.error),!1)},d.hasOwnProperty("helper")||(d.helper={}),d.helper.isString=function(a){"use strict";return"string"==typeof a||a instanceof String},d.helper.forEach=function(a,b){"use strict";if("function"==typeof a.forEach)a.forEach(b);else for(var c=0;c<a.length;c++)b(a[c],c,a)},d.helper.isArray=function(a){"use strict";return a.constructor===Array},d.helper.isUndefined=function(a){"use strict";return"undefined"==typeof a},d.helper.stdExtName=function(a){"use strict";return a.replace(/[_-]||\s/g,"").toLowerCase()},d.helper.escapeCharactersCallback=c,d.helper.escapeCharacters=function(a,b,d){"use strict";var e="(["+b.replace(/([\[\]\\])/g,"\\$1")+"])";d&&(e="\\\\"+e);var f=new RegExp(e,"g");return a=a.replace(f,c)},d.helper.isUndefined(console)&&(console={warn:function(a){"use strict";alert(a)},log:function(a){"use strict";alert(a)}}),d.Converter=function(a){"use strict";function c(){a=a||{};for(var b in g)g.hasOwnProperty(b)&&(k[b]=g[b]);if("object"!=typeof a)throw Error("Converter expects the passed parameter to be an object, but "+typeof a+" was passed instead.");for(var c in a)a.hasOwnProperty(c)&&(k[c]=a[c]);k.extensions&&d.helper.forEach(k.extensions,i)}function i(a,c){if(c=c||null,d.helper.isString(a)){if(a=d.helper.stdExtName(a),c=a,d.extensions[a])return console.warn("DEPRECATION WARNING: "+a+" is an old extension that uses a deprecated loading method.Please inform the developer that the extension should be updated!"),void j(d.extensions[a],a);if(d.helper.isUndefined(f[a]))throw Error('Extension "'+a+'" could not be loaded. It was either not found or is not a valid extension.');a=f[a]}"function"==typeof a&&(a=a()),d.helper.isArray(a)||(a=[a]);var e=b(a,c);if(!e.valid)throw Error(e.error);for(var g=0;g<a.length;++g)switch(a[g].type){case"lang":l.push(a[g]);break;case"output":m.push(a[g]);break;default:throw Error("Extension loader error: Type unrecognized!!!")}}function j(a,c){"function"==typeof a&&(a=a(new d.Converter)),d.helper.isArray(a)||(a=[a]);var e=b(a,c);if(!e.valid)throw Error(e.error);for(var f=0;f<a.length;++f)switch(a[f].type){case"lang":l.push(a[f]);break;case"output":m.push(a[f]);break;default:throw Error("Extension loader error: Type unrecognized!!!")}}var k={},l=[],m=[],n=["githubCodeBlocks","hashHTMLBlocks","stripLinkDefinitions","blockGamut","unescapeSpecialChars"];c(),this.makeHtml=function(a){if(!a)return a;var b={gHtmlBlocks:[],gUrls:{},gTitles:{},gDimensions:{},gListLevel:0,hashLinkCounts:{},langExtensions:l,outputModifiers:m,converter:this};a=a.replace(/~/g,"~T"),a=a.replace(/\$/g,"~D"),a=a.replace(/\r\n/g,"\n"),a=a.replace(/\r/g,"\n"),a="\n\n"+a+"\n\n",a=d.subParser("detab")(a,k,b),a=d.subParser("stripBlankLines")(a,k,b),d.helper.forEach(l,function(c){a=d.subParser("runExtension")(c,a,k,b)});for(var c=0;c<n.length;++c){var f=n[c];a=e[f](a,k,b)}return a=a.replace(/~D/g,"$$"),a=a.replace(/~T/g,"~"),d.helper.forEach(m,function(c){a=d.subParser("runExtension")(c,a,k,b)}),a},this.setOption=function(a,b){k[a]=b},this.getOption=function(a){return k[a]},this.getOptions=function(){return k},this.addExtension=function(a,b){b=b||null,i(a,b)},this.useExtension=function(a){i(a)},this.setFlavor=function(a){if(h.hasOwnProperty(a)){var b=h[a];for(var c in b)b.hasOwnProperty(c)&&(k[c]=b[c])}},this.removeExtension=function(a){d.helper.isArray(a)||(a=[a]);for(var b=0;b<a.length;++b){for(var c=a[b],e=0;e<l.length;++e)l[e]===c&&l[e].splice(e,1);for(var f=0;f<m.length;++e)m[f]===c&&m[f].splice(e,1)}},this.getAllExtensions=function(){return{language:l,output:m}}},d.subParser("anchors",function(a,b,c){"use strict";var e=function(a,b,e,f,g,h,i,j){d.helper.isUndefined(j)&&(j=""),a=b;var k=e,l=f.toLowerCase(),m=g,n=j;if(!m)if(l||(l=k.toLowerCase().replace(/ ?\n/g," ")),m="#"+l,d.helper.isUndefined(c.gUrls[l])){if(!(a.search(/\(\s*\)$/m)>-1))return a;m=""}else m=c.gUrls[l],d.helper.isUndefined(c.gTitles[l])||(n=c.gTitles[l]);m=d.helper.escapeCharacters(m,"*_",!1);var o='<a href="'+m+'"';return""!==n&&null!==n&&(n=n.replace(/"/g,"&quot;"),n=d.helper.escapeCharacters(n,"*_",!1),o+=' title="'+n+'"'),o+=">"+k+"</a>"};return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,e),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,e),a=a.replace(/(\[([^\[\]]+)\])()()()()()/g,e)}),d.subParser("autoLinks",function(a,b){"use strict";function c(a,b){var c=d.subParser("unescapeSpecialChars")(b);return d.subParser("encodeEmailAddress")(c)}var e=/\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\s|$)(?!["<>])/gi,f=/<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi,g=/(?:^|[ \n\t])([A-Za-z0-9!#$%&'*+-/=?^_`\{|}~\.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?:$|[ \n\t])/gi,h=/<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;return a=a.replace(f,'<a href="$1">$1</a>'),a=a.replace(h,c),b.simplifiedAutoLink&&(a=a.replace(e,'<a href="$1">$1</a>'),a=a.replace(g,c)),a}),d.subParser("blockGamut",function(a,b,c){"use strict";a=d.subParser("blockQuotes")(a,b,c),a=d.subParser("headers")(a,b,c);var e=d.subParser("hashBlock")("<hr />",b,c);return a=a.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,e),a=a.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,e),a=a.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm,e),a=d.subParser("lists")(a,b,c),a=d.subParser("codeBlocks")(a,b,c),a=d.subParser("tables")(a,b,c),a=d.subParser("hashHTMLBlocks")(a,b,c),a=d.subParser("paragraphs")(a,b,c)}),d.subParser("blockQuotes",function(a,b,c){"use strict";return a=a.replace(/((^[ \t]{0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(a,e){var f=e;return f=f.replace(/^[ \t]*>[ \t]?/gm,"~0"),f=f.replace(/~0/g,""),f=f.replace(/^[ \t]+$/gm,""),f=d.subParser("githubCodeBlocks")(f,b,c),f=d.subParser("blockGamut")(f,b,c),f=f.replace(/(^|\n)/g,"$1 "),f=f.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(a,b){var c=b;return c=c.replace(/^ /gm,"~0"),c=c.replace(/~0/g,"")}),d.subParser("hashBlock")("<blockquote>\n"+f+"\n</blockquote>",b,c)})}),d.subParser("codeBlocks",function(a,b,c){"use strict";a+="~0";var e=/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g;return a=a.replace(e,function(a,e,f){var g=e,h=f,i="\n";return g=d.subParser("outdent")(g),g=d.subParser("encodeCode")(g),g=d.subParser("detab")(g),g=g.replace(/^\n+/g,""),g=g.replace(/\n+$/g,""),b.omitExtraWLInCodeBlocks&&(i=""),g="<pre><code>"+g+i+"</code></pre>",d.subParser("hashBlock")(g,b,c)+h}),a=a.replace(/~0/,"")}),d.subParser("codeSpans",function(a){"use strict";return a=a.replace(/(<code[^><]*?>)([^]*?)<\/code>/g,function(a,b,c){return c=c.replace(/^([ \t]*)/g,""),c=c.replace(/[ \t]*$/g,""),c=d.subParser("encodeCode")(c),b+c+"</code>"}),a=a.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(a,b,c,e){var f=e;return f=f.replace(/^([ \t]*)/g,""),f=f.replace(/[ \t]*$/g,""),f=d.subParser("encodeCode")(f),b+"<code>"+f+"</code>"})}),d.subParser("detab",function(a){"use strict";return a=a.replace(/\t(?=\t)/g," "),a=a.replace(/\t/g,"~A~B"),a=a.replace(/~B(.+?)~A/g,function(a,b){for(var c=b,d=4-c.length%4,e=0;d>e;e++)c+=" ";return c}),a=a.replace(/~A/g," "),a=a.replace(/~B/g,"")}),d.subParser("encodeAmpsAndAngles",function(a){"use strict";return a=a.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;"),a=a.replace(/<(?![a-z\/?\$!])/gi,"&lt;")}),d.subParser("encodeBackslashEscapes",function(a){"use strict";return a=a.replace(/\\(\\)/g,d.helper.escapeCharactersCallback),a=a.replace(/\\([`*_{}\[\]()>#+-.!])/g,d.helper.escapeCharactersCallback)}),d.subParser("encodeCode",function(a){"use strict";return a=a.replace(/&/g,"&amp;"),a=a.replace(/</g,"&lt;"),a=a.replace(/>/g,"&gt;"),a=d.helper.escapeCharacters(a,"*_{}[]\\",!1)}),d.subParser("encodeEmailAddress",function(a){"use strict";var b=[function(a){return"&#"+a.charCodeAt(0)+";"},function(a){return"&#x"+a.charCodeAt(0).toString(16)+";"},function(a){return a}];return a="mailto:"+a,a=a.replace(/./g,function(a){if("@"===a)a=b[Math.floor(2*Math.random())](a);else if(":"!==a){var c=Math.random();a=c>.9?b[2](a):c>.45?b[1](a):b[0](a)}return a}),a='<a href="'+a+'">'+a+"</a>",a=a.replace(/">.+:/g,'">')}),d.subParser("escapeSpecialCharsWithinTagAttributes",function(a){"use strict";var b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;return a=a.replace(b,function(a){var b=a.replace(/(.)<\/?code>(?=.)/g,"$1`");return b=d.helper.escapeCharacters(b,"\\`*_",!1)})}),d.subParser("githubCodeBlocks",function(a,b,c){"use strict";return b.ghCodeBlocks?(a+="~0",a=a.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,function(a,e,f){var g=b.omitExtraWLInCodeBlocks?"":"\n";return f=d.subParser("encodeCode")(f),f=d.subParser("detab")(f),f=f.replace(/^\n+/g,""),f=f.replace(/\n+$/g,""),f="<pre><code"+(e?' class="'+e+" language-"+e+'"':"")+">"+f+g+"</code></pre>",d.subParser("hashBlock")(f,b,c)}),a=a.replace(/~0/,"")):a}),d.subParser("hashBlock",function(a,b,c){"use strict";return a=a.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(c.gHtmlBlocks.push(a)-1)+"K\n\n"}),d.subParser("hashElement",function(a,b,c){"use strict";return function(a,b){var d=b;return d=d.replace(/\n\n/g,"\n"),d=d.replace(/^\n/,""),d=d.replace(/\n+$/g,""),d="\n\n~K"+(c.gHtmlBlocks.push(d)-1)+"K\n\n"}}),d.subParser("hashHTMLBlocks",function(a,b,c){"use strict";return a=a.replace(/\n/g,"\n\n"),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,d.subParser("hashElement")(a,b,c)),a=a.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside|address|audio|canvas|figure|hgroup|output|video)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,d.subParser("hashElement")(a,b,c)),a=a.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,d.subParser("hashElement")(a,b,c)),a=a.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,d.subParser("hashElement")(a,b,c)),a=a.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,d.subParser("hashElement")(a,b,c)),a=a.replace(/\n\n/g,"\n")}),d.subParser("headers",function(a,b,c){"use strict";function e(a){var b,e=a.replace(/[^\w]/g,"").toLowerCase();return c.hashLinkCounts[e]?b=e+"-"+c.hashLinkCounts[e]++:(b=e,c.hashLinkCounts[e]=1),f===!0&&(f="section"),d.helper.isString(f)?f+b:b}var f=b.prefixHeaderId,g=isNaN(parseInt(b.headerLevelStart))?1:parseInt(b.headerLevelStart),h=b.smoothLivePreview?/^(.+)[ \t]*\n={2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n=+[ \t]*\n+/gm,i=b.smoothLivePreview?/^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n-+[ \t]*\n+/gm;return a=a.replace(h,function(a,f){var h=d.subParser("spanGamut")(f,b,c),i=b.noHeaderId?"":' id="'+e(f)+'"',j=g,k="<h"+j+i+">"+h+"</h"+j+">";return d.subParser("hashBlock")(k,b,c)}),a=a.replace(i,function(a,f){var h=d.subParser("spanGamut")(f,b,c),i=b.noHeaderId?"":' id="'+e(f)+'"',j=g+1,k="<h"+j+i+">"+h+"</h"+j+">";return d.subParser("hashBlock")(k,b,c)}),a=a.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm,function(a,f,h){var i=d.subParser("spanGamut")(h,b,c),j=b.noHeaderId?"":' id="'+e(h)+'"',k=g-1+f.length,l="<h"+k+j+">"+i+"</h"+k+">";return d.subParser("hashBlock")(l,b,c)})}),d.subParser("images",function(a,b,c){"use strict";function e(a,b,e,f,g,h,i,j){var k=c.gUrls,l=c.gTitles,m=c.gDimensions;if(e=e.toLowerCase(),j||(j=""),""===f||null===f){if((""===e||null===e)&&(e=b.toLowerCase().replace(/ ?\n/g," ")),f="#"+e,d.helper.isUndefined(k[e]))return a;f=k[e],d.helper.isUndefined(l[e])||(j=l[e]),d.helper.isUndefined(m[e])||(g=m[e].width,h=m[e].height)}b=b.replace(/"/g,"&quot;"),b=d.helper.escapeCharacters(b,"*_",!1),f=d.helper.escapeCharacters(f,"*_",!1);var n='<img src="'+f+'" alt="'+b+'"';return j&&(j=j.replace(/"/g,"&quot;"),j=d.helper.escapeCharacters(j,"*_",!1),n+=' title="'+j+'"'),g&&h&&(g="*"===g?"auto":g,h="*"===h?"auto":h,n+=' width="'+g+'"',n+=' height="'+h+'"'),n+=" />"}var f=/!\[(.*?)]\s?\([ \t]*()<?(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(['"])(.*?)\6[ \t]*)?\)/g,g=/!\[(.*?)][ ]?(?:\n[ ]*)?\[(.*?)]()()()()()/g;return a=a.replace(g,e),a=a.replace(f,e)}),d.subParser("italicsAndBold",function(a,b){"use strict";return b.literalMidWordUnderscores?(a=a.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm,"$1<strong>$2</strong>"),a=a.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm,"$1<em>$2</em>"),a=a.replace(/\*\*(?=\S)([^]+?)\*\*/g,"<strong>$1</strong>"),a=a.replace(/\*(?=\S)([^]+?)\*/g,"<em>$1</em>")):(a=a.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>"),a=a.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>")),a}),d.subParser("lists",function(a,b,c){"use strict";function e(a,e){c.gListLevel++,a=a.replace(/\n{2,}$/,"\n"),a+="~0";var f=/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,g=/\n[ \t]*\n(?!~0)/.test(a);return a=a.replace(f,function(a,e,f,h,i,j,k){k=k&&""!==k.trim();var l=d.subParser("outdent")(i,b,c),m="";return j&&b.tasklists&&(m=' class="task-list-item" style="list-style-type: none;"',l=l.replace(/^[ \t]*\[(x| )?]/m,function(){var a='<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';return k&&(a+=" checked"),a+=">"})),e||l.search(/\n{2,}/)>-1?(l=d.subParser("githubCodeBlocks")(l,b,c),l=d.subParser("blockGamut")(l,b,c)):(l=d.subParser("lists")(l,b,c),l=l.replace(/\n$/,""),l=g?d.subParser("paragraphs")(l,b,c):d.subParser("spanGamut")(l,b,c)),l="\n<li"+m+">"+l+"</li>\n"}),a=a.replace(/~0/g,""),c.gListLevel--,e&&(a=a.replace(/\s+$/,"")),a}function f(a,b,c){var d="ul"===b?/^ {0,2}\d+\.[ \t]/gm:/^ {0,2}[*+-][ \t]/gm,f=[],g="";if(-1!==a.search(d)){!function i(a){var f=a.search(d);-1!==f?(g+="\n\n<"+b+">"+e(a.slice(0,f),!!c)+"</"+b+">\n\n",b="ul"===b?"ol":"ul",d="ul"===b?/^ {0,2}\d+\.[ \t]/gm:/^ {0,2}[*+-][ \t]/gm,i(a.slice(f))):g+="\n\n<"+b+">"+e(a,!!c)+"</"+b+">\n\n"}(a);for(var h=0;h<f.length;++h);}else g="\n\n<"+b+">"+e(a,!!c)+"</"+b+">\n\n";return g}a+="~0";var g=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return c.gListLevel?a=a.replace(g,function(a,b,c){var d=c.search(/[*+-]/g)>-1?"ul":"ol";return f(b,d,!0)}):(g=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,a=a.replace(g,function(a,b,c,d){var e=d.search(/[*+-]/g)>-1?"ul":"ol";return f(c,e)})),a=a.replace(/~0/,"")}),d.subParser("outdent",function(a){"use strict";return a=a.replace(/^(\t|[ ]{1,4})/gm,"~0"),a=a.replace(/~0/g,"")}),d.subParser("paragraphs",function(a,b,c){"use strict";a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,"");for(var e=a.split(/\n{2,}/g),f=[],g=e.length,h=0;g>h;h++){var i=e[h];i.search(/~K(\d+)K/g)>=0?f.push(i):i.search(/\S/)>=0&&(i=d.subParser("spanGamut")(i,b,c),i=i.replace(/^([ \t]*)/g,"<p>"),i+="</p>",f.push(i))}for(g=f.length,h=0;g>h;h++)for(;f[h].search(/~K(\d+)K/)>=0;){var j=c.gHtmlBlocks[RegExp.$1];j=j.replace(/\$/g,"$$$$"),f[h]=f[h].replace(/~K\d+K/,j)}return f.join("\n\n")}),d.subParser("runExtension",function(a,b,c,d){"use strict";if(a.filter)b=a.filter(b,d.converter,c);else if(a.regex){var e=a.regex;!e instanceof RegExp&&(e=new RegExp(e,"g")),b=b.replace(e,a.replace)}return b}),d.subParser("spanGamut",function(a,b,c){"use strict";return a=d.subParser("codeSpans")(a,b,c),a=d.subParser("escapeSpecialCharsWithinTagAttributes")(a,b,c),a=d.subParser("encodeBackslashEscapes")(a,b,c),a=d.subParser("images")(a,b,c),a=d.subParser("anchors")(a,b,c),a=d.subParser("autoLinks")(a,b,c),a=d.subParser("encodeAmpsAndAngles")(a,b,c),a=d.subParser("italicsAndBold")(a,b,c),a=d.subParser("strikethrough")(a,b,c),a=a.replace(/ +\n/g," <br />\n")}),d.subParser("strikethrough",function(a,b){"use strict";return b.strikethrough&&(a=a.replace(/(?:~T){2}([^~]+)(?:~T){2}/g,"<del>$1</del>")),a}),d.subParser("stripBlankLines",function(a){"use strict";return a.replace(/^[ \t]+$/gm,"")}),d.subParser("stripLinkDefinitions",function(a,b,c){"use strict";var e=/^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=~0))/gm;return a+="~0",a=a.replace(e,function(a,e,f,g,h,i,j){return e=e.toLowerCase(),c.gUrls[e]=d.subParser("encodeAmpsAndAngles")(f),i?i+j:(j&&(c.gTitles[e]=j.replace(/"|'/g,"&quot;")),b.parseImgDimensions&&g&&h&&(c.gDimensions[e]={width:g,height:h}),"")}),a=a.replace(/~0/,"")}),d.subParser("tables",function(a,b,c){"use strict";var e=function(){var a,e={};return e.th=function(a,e){var f="";return a=a.trim(),""===a?"":(b.tableHeaderId&&(f=' id="'+a.replace(/ /g,"_").toLowerCase()+'"'),a=d.subParser("spanGamut")(a,b,c),e=e&&""!==e.trim()?' style="'+e+'"':"","<th"+f+e+">"+a+"</th>")},e.td=function(a,e){var f=d.subParser("spanGamut")(a.trim(),b,c);return e=e&&""!==e.trim()?' style="'+e+'"':"","<td"+e+">"+f+"</td>"},e.ths=function(){var a="",b=0,c=[].slice.apply(arguments[0]),d=[].slice.apply(arguments[1]);for(b;b<c.length;b+=1)a+=e.th(c[b],d[b])+"\n";return a},e.tds=function(){var a="",b=0,c=[].slice.apply(arguments[0]),d=[].slice.apply(arguments[1]);for(b;b<c.length;b+=1)a+=e.td(c[b],d[b])+"\n";return a},e.thead=function(){var a,b=[].slice.apply(arguments[0]),c=[].slice.apply(arguments[1]);return a="<thead>\n",a+="<tr>\n",a+=e.ths.apply(this,[b,c]),a+="</tr>\n",a+="</thead>\n"},e.tr=function(){var a,b=[].slice.apply(arguments[0]),c=[].slice.apply(arguments[1]);return a="<tr>\n",a+=e.tds.apply(this,[b,c]),a+="</tr>\n"},a=function(a){var b,c,d=0,f=a.split("\n"),g=[];for(d;d<f.length;d+=1){if(b=f[d],b.trim().match(/^[|].*[|]$/)){b=b.trim();var h=[],i=f[d+1].trim(),j=[],k=0;if(i.match(/^[|][-=|: ]+[|]$/))for(j=i.substring(1,i.length-1).split("|"),k=0;k<j.length;++k)j[k]=j[k].trim(),j[k].match(/^[:][-=| ]+[:]$/)?j[k]="text-align:center;":j[k].match(/^[-=| ]+[:]$/)?j[k]="text-align:right;":j[k].match(/^[:][-=| ]+$/)?j[k]="text-align:left;":j[k]="";if(h.push("<table>"),c=b.substring(1,b.length-1).split("|"),0===j.length)for(k=0;k<c.length;++k)j.push("text-align:left");if(h.push(e.thead.apply(this,[c,j])),b=f[++d],b.trim().match(/^[|][-=|: ]+[|]$/)){for(b=f[++d],h.push("<tbody>");b.trim().match(/^[|].*[|]$/);)b=b.trim(),h.push(e.tr.apply(this,[b.substring(1,b.length-1).split("|"),j])),b=f[++d];h.push("</tbody>"),h.push("</table>"),g.push(h.join("\n"));continue}b=f[--d]}g.push(b)}return g.join("\n")},{parse:a}};if(b.tables){var f=e();return f.parse(a)}return a}),d.subParser("unescapeSpecialChars",function(a){"use strict";return a=a.replace(/~E(\d+)E/g,function(a,b){var c=parseInt(b);return String.fromCharCode(c)})});var i=this;"undefined"!=typeof module&&module.exports?module.exports=d:"function"==typeof define&&define.amd?define("showdown",function(){"use strict";return d}):i.showdown=d}).call(this);
4
+ //# sourceMappingURL=showdown.min.js.map
@@ -0,0 +1,759 @@
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.toMarkdown = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ /*
3
+ * to-markdown - an HTML to Markdown converter
4
+ *
5
+ * Copyright 2011-15, Dom Christie
6
+ * Licenced under the MIT licence
7
+ *
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ var toMarkdown;
13
+ var converters;
14
+ var mdConverters = require('./lib/md-converters');
15
+ var gfmConverters = require('./lib/gfm-converters');
16
+ var collapse = require('collapse-whitespace');
17
+
18
+ /*
19
+ * Set up window and document for Node.js
20
+ */
21
+
22
+ var _window = (typeof window !== 'undefined' ? window : this), _document;
23
+ if (typeof document === 'undefined') {
24
+ _document = require('jsdom').jsdom();
25
+ }
26
+ else {
27
+ _document = document;
28
+ }
29
+
30
+ /*
31
+ * Utilities
32
+ */
33
+
34
+ function trim(string) {
35
+ return string.replace(/^[ \r\n\t]+|[ \r\n\t]+$/g, '');
36
+ }
37
+
38
+ var blocks = ['address', 'article', 'aside', 'audio', 'blockquote', 'body',
39
+ 'canvas', 'center', 'dd', 'dir', 'div', 'dl', 'dt', 'fieldset', 'figcaption',
40
+ 'figure', 'footer', 'form', 'frameset', 'h1', 'h2', 'h3', 'h4','h5', 'h6',
41
+ 'header', 'hgroup', 'hr', 'html', 'isindex', 'li', 'main', 'menu', 'nav',
42
+ 'noframes', 'noscript', 'ol', 'output', 'p', 'pre', 'section', 'table',
43
+ 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'ul'
44
+ ];
45
+
46
+ function isBlock(node) {
47
+ return blocks.indexOf(node.nodeName.toLowerCase()) !== -1;
48
+ }
49
+
50
+ var voids = [
51
+ 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input',
52
+ 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'
53
+ ];
54
+
55
+ function isVoid(node) {
56
+ return voids.indexOf(node.nodeName.toLowerCase()) !== -1;
57
+ }
58
+
59
+ /*
60
+ * Parsing HTML strings
61
+ */
62
+
63
+ function canParseHtml() {
64
+ var Parser = _window.DOMParser, canParse = false;
65
+
66
+ // Adapted from https://gist.github.com/1129031
67
+ // Firefox/Opera/IE throw errors on unsupported types
68
+ try {
69
+ // WebKit returns null on unsupported types
70
+ if (new Parser().parseFromString('', 'text/html')) {
71
+ canParse = true;
72
+ }
73
+ } catch (e) {}
74
+ return canParse;
75
+ }
76
+
77
+ function createHtmlParser() {
78
+ var Parser = function () {};
79
+
80
+ Parser.prototype.parseFromString = function (string) {
81
+ var newDoc = _document.implementation.createHTMLDocument('');
82
+
83
+ if (string.toLowerCase().indexOf('<!doctype') > -1) {
84
+ newDoc.documentElement.innerHTML = string;
85
+ }
86
+ else {
87
+ newDoc.body.innerHTML = string;
88
+ }
89
+ return newDoc;
90
+ };
91
+ return Parser;
92
+ }
93
+
94
+ var HtmlParser = canParseHtml() ? _window.DOMParser : createHtmlParser();
95
+
96
+ function htmlToDom(string) {
97
+ var tree = new HtmlParser().parseFromString(string, 'text/html');
98
+ collapse(tree, isBlock);
99
+ return tree;
100
+ }
101
+
102
+ /*
103
+ * Flattens DOM tree into single array
104
+ */
105
+
106
+ function bfsOrder(node) {
107
+ var inqueue = [node],
108
+ outqueue = [],
109
+ elem, children, i;
110
+
111
+ while (inqueue.length > 0) {
112
+ elem = inqueue.shift();
113
+ outqueue.push(elem);
114
+ children = elem.childNodes;
115
+ for (i = 0 ; i < children.length; i++) {
116
+ if (children[i].nodeType === 1) { inqueue.push(children[i]); }
117
+ }
118
+ }
119
+ outqueue.shift();
120
+ return outqueue;
121
+ }
122
+
123
+ /*
124
+ * Contructs a Markdown string of replacement text for a given node
125
+ */
126
+
127
+ function getContent(node) {
128
+ var text = '';
129
+ for (var i = 0; i < node.childNodes.length; i++) {
130
+ if (node.childNodes[i].nodeType === 1) {
131
+ text += node.childNodes[i]._replacement;
132
+ }
133
+ else if (node.childNodes[i].nodeType === 3) {
134
+ text += node.childNodes[i].data;
135
+ }
136
+ else { continue; }
137
+ }
138
+ return text;
139
+ }
140
+
141
+ /*
142
+ * Returns the HTML string of an element with its contents converted
143
+ */
144
+
145
+ function outer(node, content) {
146
+ return node.cloneNode(false).outerHTML.replace('><', '>'+ content +'<');
147
+ }
148
+
149
+ function canConvert(node, filter) {
150
+ if (typeof filter === 'string') {
151
+ return filter === node.nodeName.toLowerCase();
152
+ }
153
+ if (Array.isArray(filter)) {
154
+ return filter.indexOf(node.nodeName.toLowerCase()) !== -1;
155
+ }
156
+ else if (typeof filter === 'function') {
157
+ return filter.call(toMarkdown, node);
158
+ }
159
+ else {
160
+ throw new TypeError('`filter` needs to be a string, array, or function');
161
+ }
162
+ }
163
+
164
+ function isFlankedByWhitespace(side, node) {
165
+ var sibling, regExp, isFlanked;
166
+
167
+ if (side === 'left') {
168
+ sibling = node.previousSibling;
169
+ regExp = / $/;
170
+ }
171
+ else {
172
+ sibling = node.nextSibling;
173
+ regExp = /^ /;
174
+ }
175
+
176
+ if (sibling) {
177
+ if (sibling.nodeType === 3) {
178
+ isFlanked = regExp.test(sibling.nodeValue);
179
+ }
180
+ else if(sibling.nodeType === 1 && !isBlock(sibling)) {
181
+ isFlanked = regExp.test(sibling.textContent);
182
+ }
183
+ }
184
+ return isFlanked;
185
+ }
186
+
187
+ function flankingWhitespace(node) {
188
+ var leading = '', trailing = '';
189
+
190
+ if (!isBlock(node)) {
191
+ var hasLeading = /^[ \r\n\t]/.test(node.innerHTML),
192
+ hasTrailing = /[ \r\n\t]$/.test(node.innerHTML);
193
+
194
+ if (hasLeading && !isFlankedByWhitespace('left', node)) {
195
+ leading = ' ';
196
+ }
197
+ if (hasTrailing && !isFlankedByWhitespace('right', node)) {
198
+ trailing = ' ';
199
+ }
200
+ }
201
+
202
+ return { leading: leading, trailing: trailing };
203
+ }
204
+
205
+ /*
206
+ * Finds a Markdown converter, gets the replacement, and sets it on
207
+ * `_replacement`
208
+ */
209
+
210
+ function process(node) {
211
+ var replacement, content = getContent(node);
212
+
213
+ // Remove blank nodes
214
+ if (!isVoid(node) && !/A/.test(node.nodeName) && /^\s*$/i.test(content)) {
215
+ node._replacement = '';
216
+ return;
217
+ }
218
+
219
+ for (var i = 0; i < converters.length; i++) {
220
+ var converter = converters[i];
221
+
222
+ if (canConvert(node, converter.filter)) {
223
+ if (typeof converter.replacement !== 'function') {
224
+ throw new TypeError(
225
+ '`replacement` needs to be a function that returns a string'
226
+ );
227
+ }
228
+
229
+ var whitespace = flankingWhitespace(node);
230
+
231
+ if (whitespace.leading || whitespace.trailing) {
232
+ content = trim(content);
233
+ }
234
+ replacement = whitespace.leading +
235
+ converter.replacement.call(toMarkdown, content, node) +
236
+ whitespace.trailing;
237
+ break;
238
+ }
239
+ }
240
+
241
+ node._replacement = replacement;
242
+ }
243
+
244
+ toMarkdown = function (input, options) {
245
+ options = options || {};
246
+
247
+ if (typeof input !== 'string') {
248
+ throw new TypeError(input + ' is not a string');
249
+ }
250
+
251
+ // Escape potential ol triggers
252
+ input = input.replace(/(\d+)\. /g, '$1\\. ');
253
+
254
+ var clone = htmlToDom(input).body,
255
+ nodes = bfsOrder(clone),
256
+ output;
257
+
258
+ converters = mdConverters.slice(0);
259
+ if (options.gfm) {
260
+ converters = gfmConverters.concat(converters);
261
+ }
262
+
263
+ if (options.converters) {
264
+ converters = options.converters.concat(converters);
265
+ }
266
+
267
+ // Process through nodes in reverse (so deepest child elements are first).
268
+ for (var i = nodes.length - 1; i >= 0; i--) {
269
+ process(nodes[i]);
270
+ }
271
+ output = getContent(clone);
272
+
273
+ return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g, '')
274
+ .replace(/\n\s+\n/g, '\n\n')
275
+ .replace(/\n{3,}/g, '\n\n');
276
+ };
277
+
278
+ toMarkdown.isBlock = isBlock;
279
+ toMarkdown.isVoid = isVoid;
280
+ toMarkdown.trim = trim;
281
+ toMarkdown.outer = outer;
282
+
283
+ module.exports = toMarkdown;
284
+
285
+ },{"./lib/gfm-converters":2,"./lib/md-converters":3,"collapse-whitespace":4,"jsdom":7}],2:[function(require,module,exports){
286
+ 'use strict';
287
+
288
+ function cell(content, node) {
289
+ var index = Array.prototype.indexOf.call(node.parentNode.childNodes, node);
290
+ var prefix = ' ';
291
+ if (index === 0) { prefix = '| '; }
292
+ return prefix + content + ' |';
293
+ }
294
+
295
+ var highlightRegEx = /highlight highlight-(\S+)/;
296
+
297
+ module.exports = [
298
+ {
299
+ filter: 'br',
300
+ replacement: function () {
301
+ return '\n';
302
+ }
303
+ },
304
+ {
305
+ filter: ['del', 's', 'strike'],
306
+ replacement: function (content) {
307
+ return '~~' + content + '~~';
308
+ }
309
+ },
310
+
311
+ {
312
+ filter: function (node) {
313
+ return node.type === 'checkbox' && node.parentNode.nodeName === 'LI';
314
+ },
315
+ replacement: function (content, node) {
316
+ return (node.checked ? '[x]' : '[ ]') + ' ';
317
+ }
318
+ },
319
+
320
+ {
321
+ filter: ['th', 'td'],
322
+ replacement: function (content, node) {
323
+ return cell(content, node);
324
+ }
325
+ },
326
+
327
+ {
328
+ filter: 'tr',
329
+ replacement: function (content, node) {
330
+ var borderCells = '';
331
+ var alignMap = { left: ':--', right: '--:', center: ':-:' };
332
+
333
+ if (node.parentNode.nodeName === 'THEAD') {
334
+ for (var i = 0; i < node.childNodes.length; i++) {
335
+ var align = node.childNodes[i].attributes.align;
336
+ var border = '---';
337
+
338
+ if (align) { border = alignMap[align.value] || border; }
339
+
340
+ borderCells += cell(border, node.childNodes[i]);
341
+ }
342
+ }
343
+ return '\n' + content + (borderCells ? '\n' + borderCells : '');
344
+ }
345
+ },
346
+
347
+ {
348
+ filter: 'table',
349
+ replacement: function (content) {
350
+ return '\n\n' + content + '\n\n';
351
+ }
352
+ },
353
+
354
+ {
355
+ filter: ['thead', 'tbody', 'tfoot'],
356
+ replacement: function (content) {
357
+ return content;
358
+ }
359
+ },
360
+
361
+ // Fenced code blocks
362
+ {
363
+ filter: function (node) {
364
+ return node.nodeName === 'PRE' &&
365
+ node.firstChild &&
366
+ node.firstChild.nodeName === 'CODE';
367
+ },
368
+ replacement: function(content, node) {
369
+ return '\n\n```\n' + node.firstChild.textContent + '\n```\n\n';
370
+ }
371
+ },
372
+
373
+ // Syntax-highlighted code blocks
374
+ {
375
+ filter: function (node) {
376
+ return node.nodeName === 'PRE' &&
377
+ node.parentNode.nodeName === 'DIV' &&
378
+ highlightRegEx.test(node.parentNode.className);
379
+ },
380
+ replacement: function (content, node) {
381
+ var language = node.parentNode.className.match(highlightRegEx)[1];
382
+ return '\n\n```' + language + '\n' + node.textContent + '\n```\n\n';
383
+ }
384
+ },
385
+
386
+ {
387
+ filter: function (node) {
388
+ return node.nodeName === 'DIV' &&
389
+ highlightRegEx.test(node.className);
390
+ },
391
+ replacement: function (content) {
392
+ return '\n\n' + content + '\n\n';
393
+ }
394
+ }
395
+ ];
396
+
397
+ },{}],3:[function(require,module,exports){
398
+ 'use strict';
399
+
400
+ module.exports = [
401
+ {
402
+ filter: 'p',
403
+ replacement: function (content) {
404
+ return '\n\n' + content + '\n\n';
405
+ }
406
+ },
407
+
408
+ {
409
+ filter: 'br',
410
+ replacement: function () {
411
+ return ' \n';
412
+ }
413
+ },
414
+
415
+ {
416
+ filter: ['h1', 'h2', 'h3', 'h4','h5', 'h6'],
417
+ replacement: function(content, node) {
418
+ var hLevel = node.nodeName.charAt(1);
419
+ var hPrefix = '';
420
+ for(var i = 0; i < hLevel; i++) {
421
+ hPrefix += '#';
422
+ }
423
+ return '\n\n' + hPrefix + ' ' + content + '\n\n';
424
+ }
425
+ },
426
+
427
+ {
428
+ filter: 'hr',
429
+ replacement: function () {
430
+ return '\n\n* * *\n\n';
431
+ }
432
+ },
433
+
434
+ {
435
+ filter: ['em', 'i'],
436
+ replacement: function (content) {
437
+ return '_' + content + '_';
438
+ }
439
+ },
440
+
441
+ {
442
+ filter: ['strong', 'b'],
443
+ replacement: function (content) {
444
+ return '**' + content + '**';
445
+ }
446
+ },
447
+
448
+ // Inline code
449
+ {
450
+ filter: function (node) {
451
+ var hasSiblings = node.previousSibling || node.nextSibling;
452
+ var isCodeBlock = node.parentNode.nodeName === 'PRE' && !hasSiblings;
453
+
454
+ return node.nodeName === 'CODE' && !isCodeBlock;
455
+ },
456
+ replacement: function(content) {
457
+ return '`' + content + '`';
458
+ }
459
+ },
460
+
461
+ {
462
+ filter: function (node) {
463
+ return node.nodeName === 'A' && node.getAttribute('href');
464
+ },
465
+ replacement: function(content, node) {
466
+ var titlePart = node.title ? ' "'+ node.title +'"' : '';
467
+ return '[' + content + '](' + node.getAttribute('href') + titlePart + ')';
468
+ }
469
+ },
470
+
471
+ {
472
+ filter: 'img',
473
+ replacement: function(content, node) {
474
+ var alt = node.alt || '';
475
+ var src = node.getAttribute('src') || '';
476
+ var title = node.title || '';
477
+ var titlePart = title ? ' "'+ title +'"' : '';
478
+ return src ? '![' + alt + ']' + '(' + src + titlePart + ')' : '';
479
+ }
480
+ },
481
+
482
+ // Code blocks
483
+ {
484
+ filter: function (node) {
485
+ return node.nodeName === 'PRE' && node.firstChild.nodeName === 'CODE';
486
+ },
487
+ replacement: function(content, node) {
488
+ return '\n\n ' + node.firstChild.textContent.replace(/\n/g, '\n ') + '\n\n';
489
+ }
490
+ },
491
+
492
+ {
493
+ filter: 'blockquote',
494
+ replacement: function (content) {
495
+ content = this.trim(content);
496
+ content = content.replace(/\n{3,}/g, '\n\n');
497
+ content = content.replace(/^/gm, '> ');
498
+ return '\n\n' + content + '\n\n';
499
+ }
500
+ },
501
+
502
+ {
503
+ filter: 'li',
504
+ replacement: function (content, node) {
505
+ content = content.replace(/^\s+/, '').replace(/\n/gm, '\n ');
506
+ var prefix = '* ';
507
+ var parent = node.parentNode;
508
+ var index = Array.prototype.indexOf.call(parent.children, node) + 1;
509
+
510
+ prefix = /ol/i.test(parent.nodeName) ? index + '. ' : '* ';
511
+ return prefix + content;
512
+ }
513
+ },
514
+
515
+ {
516
+ filter: ['ul', 'ol'],
517
+ replacement: function (content, node) {
518
+ var strings = [];
519
+ for (var i = 0; i < node.childNodes.length; i++) {
520
+ strings.push(node.childNodes[i]._replacement);
521
+ }
522
+
523
+ if (/li/i.test(node.parentNode.nodeName)) {
524
+ return '\n' + strings.join('\n');
525
+ }
526
+ return '\n\n' + strings.join('\n') + '\n\n';
527
+ }
528
+ },
529
+
530
+ {
531
+ filter: function (node) {
532
+ return this.isBlock(node);
533
+ },
534
+ replacement: function (content, node) {
535
+ return '\n\n' + this.outer(node, content) + '\n\n';
536
+ }
537
+ },
538
+
539
+ // Anything else!
540
+ {
541
+ filter: function () {
542
+ return true;
543
+ },
544
+ replacement: function (content, node) {
545
+ return this.outer(node, content);
546
+ }
547
+ }
548
+ ];
549
+ },{}],4:[function(require,module,exports){
550
+ 'use strict';
551
+
552
+ var voidElements = require('void-elements');
553
+ Object.keys(voidElements).forEach(function (name) {
554
+ voidElements[name.toUpperCase()] = 1;
555
+ });
556
+
557
+ var blockElements = {};
558
+ require('block-elements').forEach(function (name) {
559
+ blockElements[name.toUpperCase()] = 1;
560
+ });
561
+
562
+ /**
563
+ * isBlockElem(node) determines if the given node is a block element.
564
+ *
565
+ * @param {Node} node
566
+ * @return {Boolean}
567
+ */
568
+ function isBlockElem(node) {
569
+ return !!(node && blockElements[node.nodeName]);
570
+ }
571
+
572
+ /**
573
+ * isVoid(node) determines if the given node is a void element.
574
+ *
575
+ * @param {Node} node
576
+ * @return {Boolean}
577
+ */
578
+ function isVoid(node) {
579
+ return !!(node && voidElements[node.nodeName]);
580
+ }
581
+
582
+ /**
583
+ * whitespace(elem [, isBlock]) removes extraneous whitespace from an
584
+ * the given element. The function isBlock may optionally be passed in
585
+ * to determine whether or not an element is a block element; if none
586
+ * is provided, defaults to using the list of block elements provided
587
+ * by the `block-elements` module.
588
+ *
589
+ * @param {Node} elem
590
+ * @param {Function} blockTest
591
+ */
592
+ function collapseWhitespace(elem, isBlock) {
593
+ if (!elem.firstChild || elem.nodeName === 'PRE') return;
594
+
595
+ if (typeof isBlock !== 'function') {
596
+ isBlock = isBlockElem;
597
+ }
598
+
599
+ var prevText = null;
600
+ var prevVoid = false;
601
+
602
+ var prev = null;
603
+ var node = next(prev, elem);
604
+
605
+ while (node !== elem) {
606
+ if (node.nodeType === 3) {
607
+ // Node.TEXT_NODE
608
+ var text = node.data.replace(/[ \r\n\t]+/g, ' ');
609
+
610
+ if ((!prevText || / $/.test(prevText.data)) && !prevVoid && text[0] === ' ') {
611
+ text = text.substr(1);
612
+ }
613
+
614
+ // `text` might be empty at this point.
615
+ if (!text) {
616
+ node = remove(node);
617
+ continue;
618
+ }
619
+
620
+ node.data = text;
621
+ prevText = node;
622
+ } else if (node.nodeType === 1) {
623
+ // Node.ELEMENT_NODE
624
+ if (isBlock(node) || node.nodeName === 'BR') {
625
+ if (prevText) {
626
+ prevText.data = prevText.data.replace(/ $/, '');
627
+ }
628
+
629
+ prevText = null;
630
+ prevVoid = false;
631
+ } else if (isVoid(node)) {
632
+ // Avoid trimming space around non-block, non-BR void elements.
633
+ prevText = null;
634
+ prevVoid = true;
635
+ }
636
+ } else {
637
+ node = remove(node);
638
+ continue;
639
+ }
640
+
641
+ var nextNode = next(prev, node);
642
+ prev = node;
643
+ node = nextNode;
644
+ }
645
+
646
+ if (prevText) {
647
+ prevText.data = prevText.data.replace(/ $/, '');
648
+ if (!prevText.data) {
649
+ remove(prevText);
650
+ }
651
+ }
652
+ }
653
+
654
+ /**
655
+ * remove(node) removes the given node from the DOM and returns the
656
+ * next node in the sequence.
657
+ *
658
+ * @param {Node} node
659
+ * @return {Node} node
660
+ */
661
+ function remove(node) {
662
+ var next = node.nextSibling || node.parentNode;
663
+
664
+ node.parentNode.removeChild(node);
665
+
666
+ return next;
667
+ }
668
+
669
+ /**
670
+ * next(prev, current) returns the next node in the sequence, given the
671
+ * current and previous nodes.
672
+ *
673
+ * @param {Node} prev
674
+ * @param {Node} current
675
+ * @return {Node}
676
+ */
677
+ function next(prev, current) {
678
+ if (prev && prev.parentNode === current || current.nodeName === 'PRE') {
679
+ return current.nextSibling || current.parentNode;
680
+ }
681
+
682
+ return current.firstChild || current.nextSibling || current.parentNode;
683
+ }
684
+
685
+ module.exports = collapseWhitespace;
686
+
687
+ },{"block-elements":5,"void-elements":6}],5:[function(require,module,exports){
688
+ /**
689
+ * This file automatically generated from `build.js`.
690
+ * Do not manually edit.
691
+ */
692
+
693
+ module.exports = [
694
+ "address",
695
+ "article",
696
+ "aside",
697
+ "audio",
698
+ "blockquote",
699
+ "canvas",
700
+ "dd",
701
+ "div",
702
+ "dl",
703
+ "fieldset",
704
+ "figcaption",
705
+ "figure",
706
+ "footer",
707
+ "form",
708
+ "h1",
709
+ "h2",
710
+ "h3",
711
+ "h4",
712
+ "h5",
713
+ "h6",
714
+ "header",
715
+ "hgroup",
716
+ "hr",
717
+ "main",
718
+ "nav",
719
+ "noscript",
720
+ "ol",
721
+ "output",
722
+ "p",
723
+ "pre",
724
+ "section",
725
+ "table",
726
+ "tfoot",
727
+ "ul",
728
+ "video"
729
+ ];
730
+
731
+ },{}],6:[function(require,module,exports){
732
+ /**
733
+ * This file automatically generated from `pre-publish.js`.
734
+ * Do not manually edit.
735
+ */
736
+
737
+ module.exports = {
738
+ "area": true,
739
+ "base": true,
740
+ "br": true,
741
+ "col": true,
742
+ "embed": true,
743
+ "hr": true,
744
+ "img": true,
745
+ "input": true,
746
+ "keygen": true,
747
+ "link": true,
748
+ "menuitem": true,
749
+ "meta": true,
750
+ "param": true,
751
+ "source": true,
752
+ "track": true,
753
+ "wbr": true
754
+ };
755
+
756
+ },{}],7:[function(require,module,exports){
757
+
758
+ },{}]},{},[1])(1)
759
+ });