slide_hero 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/README.md +2 -2
- data/lib/slide_hero/blockquote.rb +10 -0
- data/lib/slide_hero/pluggable.rb +4 -4
- data/lib/slide_hero/plugins.rb +0 -1
- data/lib/slide_hero/presentation.rb +3 -3
- data/lib/slide_hero/slide.rb +2 -2
- data/lib/slide_hero/version.rb +1 -1
- data/lib/slide_hero/views/blockquote.html.erb +3 -0
- data/lib/slide_hero.rb +1 -0
- data/test/slide_hero/blockquote_spec.rb +13 -0
- data/test/slide_hero/plugins_spec.rb +0 -1
- data/test/slide_hero/presentation_spec.rb +2 -1
- data/test/slide_hero/slide_spec.rb +14 -3
- data/test/slide_hero_spec.rb +1 -0
- data/vendor/reveal.js/.gitignore +6 -1
- data/vendor/reveal.js/.travis.yml +1 -1
- data/vendor/reveal.js/CONTRIBUTING.md +4 -0
- data/vendor/reveal.js/Gruntfile.js +26 -24
- data/vendor/reveal.js/LICENSE +1 -1
- data/vendor/reveal.js/README.md +215 -124
- data/vendor/reveal.js/bower.json +27 -0
- data/vendor/reveal.js/css/print/paper.css +1 -1
- data/vendor/reveal.js/css/print/pdf.css +30 -27
- data/vendor/reveal.js/css/reveal.css +381 -191
- data/vendor/reveal.js/css/reveal.scss +259 -164
- data/vendor/reveal.js/css/theme/README.md +2 -6
- data/vendor/reveal.js/css/theme/beige.css +75 -49
- data/vendor/reveal.js/css/theme/black.css +64 -38
- data/vendor/reveal.js/css/theme/blood.css +75 -56
- data/vendor/reveal.js/css/theme/league.css +69 -43
- data/vendor/reveal.js/css/theme/moon.css +69 -43
- data/vendor/reveal.js/css/theme/night.css +64 -38
- data/vendor/reveal.js/css/theme/serif.css +66 -40
- data/vendor/reveal.js/css/theme/simple.css +63 -37
- data/vendor/reveal.js/css/theme/sky.css +69 -43
- data/vendor/reveal.js/css/theme/solarized.css +69 -43
- data/vendor/reveal.js/css/theme/source/black.scss +1 -1
- data/vendor/reveal.js/css/theme/source/blood.scss +3 -15
- data/vendor/reveal.js/css/theme/source/white.scss +1 -1
- data/vendor/reveal.js/css/theme/template/theme.scss +30 -23
- data/vendor/reveal.js/css/theme/white.css +69 -43
- data/vendor/reveal.js/demo.html +410 -0
- data/vendor/reveal.js/index.html +13 -371
- data/vendor/reveal.js/js/reveal.js +643 -175
- data/vendor/reveal.js/lib/css/zenburn.css +41 -78
- data/vendor/reveal.js/lib/js/head.min.js +9 -8
- data/vendor/reveal.js/package.json +20 -24
- data/vendor/reveal.js/plugin/highlight/highlight.js +4 -3
- data/vendor/reveal.js/plugin/markdown/example.html +1 -1
- data/vendor/reveal.js/plugin/markdown/markdown.js +19 -7
- data/vendor/reveal.js/plugin/markdown/marked.js +2 -33
- data/vendor/reveal.js/plugin/math/math.js +5 -2
- data/vendor/reveal.js/plugin/multiplex/client.js +1 -1
- data/vendor/reveal.js/plugin/multiplex/index.js +24 -16
- data/vendor/reveal.js/plugin/multiplex/master.js +22 -42
- data/vendor/reveal.js/plugin/multiplex/package.json +19 -0
- data/vendor/reveal.js/plugin/notes/notes.html +11 -3
- data/vendor/reveal.js/plugin/notes/notes.js +19 -5
- data/vendor/reveal.js/plugin/notes-server/client.js +6 -1
- data/vendor/reveal.js/plugin/notes-server/index.js +17 -14
- data/vendor/reveal.js/plugin/notes-server/notes.html +17 -6
- data/vendor/reveal.js/plugin/print-pdf/print-pdf.js +1 -1
- data/vendor/reveal.js/plugin/zoom-js/zoom.js +1 -1
- data/vendor/reveal.js/test/examples/slide-backgrounds.html +1 -1
- data/vendor/reveal.js/test/examples/slide-transitions.html +101 -0
- data/vendor/reveal.js/test/test-markdown-element-attributes.html +3 -3
- data/vendor/reveal.js/test/test-markdown-element-attributes.js +1 -1
- data/vendor/reveal.js/test/test.html +5 -1
- data/vendor/reveal.js/test/test.js +26 -1
- metadata +11 -5
- data/vendor/reveal.js/plugin/leap/leap.js +0 -159
- data/vendor/reveal.js/plugin/remotes/remotes.js +0 -39
@@ -7,7 +7,7 @@
|
|
7
7
|
<title>reveal.js - Markdown Demo</title>
|
8
8
|
|
9
9
|
<link rel="stylesheet" href="../../css/reveal.css">
|
10
|
-
<link rel="stylesheet" href="../../css/theme/
|
10
|
+
<link rel="stylesheet" href="../../css/theme/white.css" id="theme">
|
11
11
|
|
12
12
|
<link rel="stylesheet" href="../../lib/css/zenburn.css">
|
13
13
|
</head>
|
@@ -4,10 +4,13 @@
|
|
4
4
|
* of external markdown documents.
|
5
5
|
*/
|
6
6
|
(function( root, factory ) {
|
7
|
-
if(
|
7
|
+
if (typeof define === 'function' && define.amd) {
|
8
|
+
root.marked = require( './marked' );
|
9
|
+
root.RevealMarkdown = factory( root.marked );
|
10
|
+
root.RevealMarkdown.initialize();
|
11
|
+
} else if( typeof exports === 'object' ) {
|
8
12
|
module.exports = factory( require( './marked' ) );
|
9
|
-
}
|
10
|
-
else {
|
13
|
+
} else {
|
11
14
|
// Browser globals (root is window)
|
12
15
|
root.RevealMarkdown = factory( root.marked );
|
13
16
|
root.RevealMarkdown.initialize();
|
@@ -26,11 +29,13 @@
|
|
26
29
|
});
|
27
30
|
}
|
28
31
|
|
29
|
-
var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$',
|
32
|
+
var DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$',
|
30
33
|
DEFAULT_NOTES_SEPARATOR = 'note:',
|
31
34
|
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
|
32
35
|
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';
|
33
36
|
|
37
|
+
var SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__';
|
38
|
+
|
34
39
|
|
35
40
|
/**
|
36
41
|
* Retrieves the markdown contents of a slide section
|
@@ -43,6 +48,9 @@
|
|
43
48
|
// strip leading whitespace so it isn't evaluated as code
|
44
49
|
var text = ( template || section ).textContent;
|
45
50
|
|
51
|
+
// restore script end tags
|
52
|
+
text = text.replace( new RegExp( SCRIPT_END_PLACEHOLDER, 'g' ), '</script>' );
|
53
|
+
|
46
54
|
var leadingWs = text.match( /^\n?(\s*)/ )[1].length,
|
47
55
|
leadingTabs = text.match( /^\n?(\t*)/ )[1].length;
|
48
56
|
|
@@ -50,7 +58,7 @@
|
|
50
58
|
text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}','g'), '\n' );
|
51
59
|
}
|
52
60
|
else if( leadingWs > 1 ) {
|
53
|
-
text = text.replace( new RegExp('\\n? {' + leadingWs + '}'), '\n' );
|
61
|
+
text = text.replace( new RegExp('\\n? {' + leadingWs + '}', 'g'), '\n' );
|
54
62
|
}
|
55
63
|
|
56
64
|
return text;
|
@@ -76,7 +84,7 @@
|
|
76
84
|
if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue;
|
77
85
|
|
78
86
|
if( value ) {
|
79
|
-
result.push( name + '=' + value );
|
87
|
+
result.push( name + '="' + value + '"' );
|
80
88
|
}
|
81
89
|
else {
|
82
90
|
result.push( name );
|
@@ -112,9 +120,13 @@
|
|
112
120
|
var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) );
|
113
121
|
|
114
122
|
if( notesMatch.length === 2 ) {
|
115
|
-
content = notesMatch[0] + '<aside class="notes"
|
123
|
+
content = notesMatch[0] + '<aside class="notes">' + marked(notesMatch[1].trim()) + '</aside>';
|
116
124
|
}
|
117
125
|
|
126
|
+
// prevent script end tags in the content from interfering
|
127
|
+
// with parsing
|
128
|
+
content = content.replace( /<\/script>/g, SCRIPT_END_PLACEHOLDER );
|
129
|
+
|
118
130
|
return '<script type="text/template">' + content + '</script>';
|
119
131
|
|
120
132
|
}
|
@@ -1,37 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* marked - a markdown parser
|
3
|
-
* Copyright (c) 2011-
|
3
|
+
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
|
4
4
|
* https://github.com/chjj/marked
|
5
5
|
*/
|
6
|
-
|
7
|
-
(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){3,} *\n*/,blockquote:/^( *>[^\n]+(\n[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
|
8
|
-
text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr",/\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|@)\\b";block.html=replace(block.html)("comment",/\x3c!--[\s\S]*?--\x3e/)("closed",
|
9
|
-
/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1",
|
10
|
-
"\\2")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm)if(this.options.tables)this.rules=block.tables;else this.rules=block.gfm}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};
|
11
|
-
Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1)this.tokens.push({type:"space"})}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,
|
12
|
-
"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,
|
13
|
-
"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i<item.align.length;i++)if(/^ *-+: *$/.test(item.align[i]))item.align[i]="right";else if(/^ *:-+: *$/.test(item.align[i]))item.align[i]="center";else if(/^ *:-+ *$/.test(item.align[i]))item.align[i]="left";else item.align[i]=null;for(i=0;i<item.cells.length;i++)item.cells[i]=item.cells[i].split(/ *\| */);this.tokens.push(item);continue}if(cap=this.rules.lheading.exec(src)){src=
|
14
|
-
src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[2]==="="?1:2,text:cap[1]});continue}if(cap=this.rules.hr.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"hr"});continue}if(cap=this.rules.blockquote.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"blockquote_start"});cap=cap[0].replace(/^ *> ?/gm,"");this.token(cap,top);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);
|
15
|
-
bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i<l;i++){item=cap[i];space=item.length;item=item.replace(/^ *([*+-]|\d+\.) +/,"");if(~item.indexOf("\n ")){space-=item.length;item=!this.options.pedantic?item.replace(new RegExp("^ {1,"+space+"}","gm"),""):item.replace(/^ {1,4}/gm,"")}if(this.options.smartLists&&i!==l-1){b=block.bullet.exec(cap[i+1])[0];if(bull!==b&&!(bull.length>1&&b.length>1)){src=cap.slice(i+
|
16
|
-
1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item[item.length-1]==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:cap[1]==="pre"||cap[1]==="script",text:cap[0]});continue}if(top&&
|
17
|
-
(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i<item.align.length;i++)if(/^ *-+: *$/.test(item.align[i]))item.align[i]="right";else if(/^ *:-+: *$/.test(item.align[i]))item.align[i]=
|
18
|
-
"center";else if(/^ *:-+ *$/.test(item.align[i]))item.align[i]="left";else item.align[i]=null;for(i=0;i<item.cells.length;i++)item.cells[i]=item.cells[i].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(item);continue}if(top&&(cap=this.rules.paragraph.exec(src))){src=src.substring(cap[0].length);this.tokens.push({type:"paragraph",text:cap[1][cap[1].length-1]==="\n"?cap[1].slice(0,-1):cap[1]});continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"text",
|
19
|
-
text:cap[0]});continue}if(src)throw new Error("Infinite loop on byte: "+src.charCodeAt(0));}return this.tokens};var inline={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^\x3c!--[\s\S]*?--\x3e|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
20
|
-
code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};inline._inside=/(?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*/;inline._href=/\s*<?([^\s]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
21
|
-
em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;
|
22
|
-
if(!this.links)throw new Error("Tokens array requires a `links` property.");if(this.options.gfm)if(this.options.breaks)this.rules=inline.breaks;else this.rules=inline.gfm;else if(this.options.pedantic)this.rules=inline.pedantic}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);
|
23
|
-
out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1][6]===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+='<a href="'+href+'">'+text+"</a>";continue}if(cap=this.rules.url.exec(src)){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+='<a href="'+href+'">'+text+"</a>";continue}if(cap=this.rules.tag.exec(src)){src=src.substring(cap[0].length);
|
24
|
-
out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);out+=this.outputLink(cap,{href:cap[2],title:cap[3]});continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0][0];src=cap[0].substring(1)+src;continue}out+=this.outputLink(cap,link);continue}if(cap=this.rules.strong.exec(src)){src=
|
25
|
-
src.substring(cap[0].length);out+="<strong>"+this.output(cap[2]||cap[1])+"</strong>";continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+="<em>"+this.output(cap[2]||cap[1])+"</em>";continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+="<code>"+escape(cap[2],true)+"</code>";continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+="<br>";continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+="<del>"+
|
26
|
-
this.output(cap[1])+"</del>";continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(cap[0]);continue}if(src)throw new Error("Infinite loop on byte: "+src.charCodeAt(0));}return out};InlineLexer.prototype.outputLink=function(cap,link){if(cap[0][0]!=="!")return'<a href="'+escape(link.href)+'"'+(link.title?' title="'+escape(link.title)+'"':"")+">"+this.output(cap[1])+"</a>";else return'<img src="'+escape(link.href)+'" alt="'+escape(cap[1])+'"'+(link.title?' title="'+
|
27
|
-
escape(link.title)+'"':"")+">"};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,"\u2014").replace(/'([^']*)'/g,"\u2018$1\u2019").replace(/"([^"]*)"/g,"\u201c$1\u201d").replace(/\.{3}/g,"\u2026")};InlineLexer.prototype.mangle=function(text){var out="",l=text.length,i=0,ch;for(;i<l;i++){ch=text.charCodeAt(i);if(Math.random()>0.5)ch="x"+ch.toString(16);out+="&#"+ch+";"}return out};function Parser(options){this.tokens=[];this.token=null;
|
28
|
-
this.options=options||marked.defaults}Parser.parse=function(src,options){var parser=new Parser(options);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options);this.tokens=src.reverse();var out="";while(this.next())out+=this.tok();return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;
|
29
|
-
while(this.peek().type==="text")body+="\n"+this.next().text;return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case "space":return"";case "hr":return"<hr>\n";case "heading":return"<h"+this.token.depth+">"+this.inline.output(this.token.text)+"</h"+this.token.depth+">\n";case "code":if(this.options.highlight){var code=this.options.highlight(this.token.text,this.token.lang);if(code!=null&&code!==this.token.text){this.token.escaped=true;this.token.text=code}}if(!this.token.escaped)this.token.text=
|
30
|
-
escape(this.token.text,true);return"<pre><code"+(this.token.lang?' class="'+this.options.langPrefix+this.token.lang+'"':"")+">"+this.token.text+"</code></pre>\n";case "table":var body="",heading,i,row,cell,j;body+="<thead>\n<tr>\n";for(i=0;i<this.token.header.length;i++){heading=this.inline.output(this.token.header[i]);body+=this.token.align[i]?'<th align="'+this.token.align[i]+'">'+heading+"</th>\n":"<th>"+heading+"</th>\n"}body+="</tr>\n</thead>\n";body+="<tbody>\n";for(i=0;i<this.token.cells.length;i++){row=
|
31
|
-
this.token.cells[i];body+="<tr>\n";for(j=0;j<row.length;j++){cell=this.inline.output(row[j]);body+=this.token.align[j]?'<td align="'+this.token.align[j]+'">'+cell+"</td>\n":"<td>"+cell+"</td>\n"}body+="</tr>\n"}body+="</tbody>\n";return"<table>\n"+body+"</table>\n";case "blockquote_start":var body="";while(this.next().type!=="blockquote_end")body+=this.tok();return"<blockquote>\n"+body+"</blockquote>\n";case "list_start":var type=this.token.ordered?"ol":"ul",body="";while(this.next().type!=="list_end")body+=
|
32
|
-
this.tok();return"<"+type+">\n"+body+"</"+type+">\n";case "list_item_start":var body="";while(this.next().type!=="list_item_end")body+=this.token.type==="text"?this.parseText():this.tok();return"<li>"+body+"</li>\n";case "loose_item_start":var body="";while(this.next().type!=="list_item_end")body+=this.tok();return"<li>"+body+"</li>\n";case "html":return!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text;case "paragraph":return"<p>"+this.inline.output(this.token.text)+
|
33
|
-
"</p>\n";case "text":return"<p>"+this.parseText()+"</p>\n"}};function escape(html,encode){return html.replace(!encode?/&(?!#?\w+;)/g:/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=
|
34
|
-
1,target,key;for(;i<arguments.length;i++){target=arguments[i];for(key in target)if(Object.prototype.hasOwnProperty.call(target,key))obj[key]=target[key]}return obj}function marked(src,opt,callback){if(callback||typeof opt==="function"){if(!callback){callback=opt;opt=null}if(opt)opt=merge({},marked.defaults,opt);var tokens=Lexer.lex(tokens,opt),highlight=opt.highlight,pending=0,l=tokens.length,i=0;if(!highlight||highlight.length<3)return callback(null,Parser.parse(tokens,opt));var done=function(){delete opt.highlight;
|
35
|
-
var out=Parser.parse(tokens,opt);opt.highlight=highlight;return callback(null,out)};for(;i<l;i++)(function(token){if(token.type!=="code")return;pending++;return highlight(token.text,token.lang,function(err,code){if(code==null||code===token.text)return--pending||done();token.text=code;token.escaped=true;--pending||done()})})(tokens[i]);return}try{if(opt)opt=merge({},marked.defaults,opt);return Parser.parse(Lexer.lex(src,opt),opt)}catch(e){e.message+="\nPlease report this to https://github.com/chjj/marked.";
|
36
|
-
if((opt||marked.defaults).silent)return"<p>An error occured:</p><pre>"+escape(e.message+"",true)+"</pre>";throw e;}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:""};marked.Parser=Parser;marked.parser=Parser.parse;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;
|
37
|
-
marked.parse=marked;if(typeof exports==="object")module.exports=marked;else if(typeof define==="function"&&define.amd)define(function(){return marked});else this.marked=marked}).call(function(){return this||(typeof window!=="undefined"?window:global)}());
|
6
|
+
(function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||a.defaults,this.rules=p.normal,this.options.gfm&&(this.rules=this.options.tables?p.tables:p.gfm)}function t(e,t){if(this.options=t||a.defaults,this.links=e,this.rules=u.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?u.breaks:u.gfm:this.options.pedantic&&(this.rules=u.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||a.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function s(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function i(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?String.fromCharCode("x"===t.charAt(1)?parseInt(t.substring(2),16):+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function n(r,s){return r?(s=s.source||s,s=s.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,s),n):new RegExp(e,t)}}function o(){}function h(e){for(var t,n,r=1;r<arguments.length;r++){t=arguments[r];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function a(t,n,i){if(i||"function"==typeof n){i||(i=n,n=null),n=h({},a.defaults,n||{});var l,o,p=n.highlight,u=0;try{l=e.lex(t,n)}catch(c){return i(c)}o=l.length;var g=function(e){if(e)return n.highlight=p,i(e);var t;try{t=r.parse(l,n)}catch(s){e=s}return n.highlight=p,e?i(e):i(null,t)};if(!p||p.length<3)return g();if(delete n.highlight,!o)return g();for(;u<l.length;u++)!function(e){return"code"!==e.type?--o||g():p(e.text,e.lang,function(t,n){return t?g(t):null==n||n===e.text?--o||g():(e.text=n,e.escaped=!0,void(--o||g()))})}(l[u])}else try{return n&&(n=h({},a.defaults,n)),r.parse(e.lex(t,n),n)}catch(c){if(c.message+="\nPlease report this to https://github.com/chjj/marked.",(n||a.defaults).silent)return"<p>An error occured:</p><pre>"+s(c.message+"",!0)+"</pre>";throw c}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:o,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:o,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:o,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=l(p.item,"gm")(/bull/g,p.bullet)(),p.list=l(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=l(p.blockquote)("def",p.def)(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",p.html=l(p.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,p._tag)(),p.paragraph=l(p.paragraph)("hr",p.hr)("heading",p.heading)("lheading",p.lheading)("blockquote",p.blockquote)("tag","<"+p._tag)("def",p.def)(),p.normal=h({},p),p.gfm=h({},p.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),p.gfm.paragraph=l(p.paragraph)("(?!","(?!"+p.gfm.fences.source.replace("\\1","\\2")+"|"+p.list.source.replace("\\1","\\3")+"|")(),p.tables=h({},p.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=p,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,s,i,l,o,h,a,u,c,e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e))e=e.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"code",lang:i[2],text:i[3]});else if(i=this.rules.heading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if(t&&(i=this.rules.nptable.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/\n$/,"").split("\n")},u=0;u<h.align.length;u++)h.align[u]=/^ *-+: *$/.test(h.align[u])?"right":/^ *:-+: *$/.test(h.align[u])?"center":/^ *:-+ *$/.test(h.align[u])?"left":null;for(u=0;u<h.cells.length;u++)h.cells[u]=h.cells[u].split(/ *\| */);this.tokens.push(h)}else if(i=this.rules.lheading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:"="===i[2]?1:2,text:i[1]});else if(i=this.rules.hr.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"hr"});else if(i=this.rules.blockquote.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"blockquote_start"}),i=i[0].replace(/^ *> ?/gm,""),this.token(i,t,!0),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(e)){for(e=e.substring(i[0].length),l=i[2],this.tokens.push({type:"list_start",ordered:l.length>1}),i=i[0].match(this.rules.item),r=!1,c=i.length,u=0;c>u;u++)h=i[u],a=h.length,h=h.replace(/^ *([*+-]|\d+\.) +/,""),~h.indexOf("\n ")&&(a-=h.length,h=this.options.pedantic?h.replace(/^ {1,4}/gm,""):h.replace(new RegExp("^ {1,"+a+"}","gm"),"")),this.options.smartLists&&u!==c-1&&(o=p.bullet.exec(i[u+1])[0],l===o||l.length>1&&o.length>1||(e=i.slice(u+1).join("\n")+e,u=c-1)),s=r||/\n\n(?!\s*$)/.test(h),u!==c-1&&(r="\n"===h.charAt(h.length-1),s||(s=r)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(h,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(i=this.rules.html.exec(e))e=e.substring(i[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===i[1]||"script"===i[1]||"style"===i[1],text:i[0]});else if(!n&&t&&(i=this.rules.def.exec(e)))e=e.substring(i[0].length),this.tokens.links[i[1].toLowerCase()]={href:i[2],title:i[3]};else if(t&&(i=this.rules.table.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u<h.align.length;u++)h.align[u]=/^ *-+: *$/.test(h.align[u])?"right":/^ *:-+: *$/.test(h.align[u])?"center":/^ *:-+ *$/.test(h.align[u])?"left":null;for(u=0;u<h.cells.length;u++)h.cells[u]=h.cells[u].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(h)}else if(t&&(i=this.rules.paragraph.exec(e)))e=e.substring(i[0].length),this.tokens.push({type:"paragraph",text:"\n"===i[1].charAt(i[1].length-1)?i[1].slice(0,-1):i[1]});else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"text",text:i[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var u={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:o,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:o,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};u._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,u._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,u.link=l(u.link)("inside",u._inside)("href",u._href)(),u.reflink=l(u.reflink)("inside",u._inside)(),u.normal=h({},u),u.pedantic=h({},u.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),u.gfm=h({},u.normal,{escape:l(u.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(u.text)("]|","~]|")("|","|https?://|")()}),u.breaks=h({},u.gfm,{br:l(u.br)("{2,}","*")(),text:l(u.gfm.text)("{2,}","*")()}),t.rules=u,t.output=function(e,n,r){var s=new t(n,r);return s.output(e)},t.prototype.output=function(e){for(var t,n,r,i,l="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),l+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=this.mangle(":"===i[1].charAt(6)?i[1].substring(7):i[1]),r=this.mangle("mailto:")+n):(n=s(i[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(i[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),l+=this.options.sanitize?s(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,l+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),l+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),l+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),l+=this.renderer.codespan(s(i[2],!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),l+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),l+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),l+=s(this.smartypants(i[0]));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=s(i[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=s(t.href),r=t.title?s(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,s(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){for(var t,n="",r=e.length,s=0;r>s;s++)t=e.charCodeAt(s),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'<pre><code class="'+this.options.langPrefix+s(t,!0)+'">'+(n?e:s(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:s(e,!0))+"\n</code></pre>"},n.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},n.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},n.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},n.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},n.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},n.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"</"+n+">\n"},n.prototype.strong=function(e){return"<strong>"+e+"</strong>"},n.prototype.em=function(e){return"<em>"+e+"</em>"},n.prototype.codespan=function(e){return"<code>"+e+"</code>"},n.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},n.prototype.del=function(e){return"<del>"+e+"</del>"},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(i(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(s){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var l='<a href="'+e+'"';return t&&(l+=' title="'+t+'"'),l+=">"+n+"</a>"},n.prototype.image=function(e,t,n){var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},r.parse=function(e,t,n){var s=new r(t,n);return s.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s,i="",l="";for(n="",e=0;e<this.token.header.length;e++)r={header:!0,align:this.token.align[e]},n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(i+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",s=0;s<t.length;s++)n+=this.renderer.tablecell(this.inline.output(t[s]),{header:!1,align:this.token.align[s]});l+=this.renderer.tablerow(n)}return this.renderer.table(i,l);case"blockquote_start":for(var l="";"blockquote_end"!==this.next().type;)l+=this.tok();return this.renderer.blockquote(l);case"list_start":for(var l="",o=this.token.ordered;"list_end"!==this.next().type;)l+=this.tok();return this.renderer.list(l,o);case"list_item_start":for(var l="";"list_item_end"!==this.next().type;)l+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(l);case"loose_item_start":for(var l="";"list_item_end"!==this.next().type;)l+=this.tok();return this.renderer.listitem(l);case"html":var h=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(h);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}},o.exec=o,a.options=a.setOptions=function(e){return h(a.defaults,e),a},a.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new n,xhtml:!1},a.Parser=r,a.parser=r.parse,a.Renderer=n,a.Lexer=e,a.lexer=e.lex,a.InlineLexer=t,a.inlineLexer=t.output,a.parse=a,"undefined"!=typeof module&&"object"==typeof exports?module.exports=a:"function"==typeof define&&define.amd?define(function(){return a}):this.marked=a}).call(function(){return this||("undefined"!=typeof window?window:global)}());
|
@@ -7,14 +7,17 @@
|
|
7
7
|
var RevealMath = window.RevealMath || (function(){
|
8
8
|
|
9
9
|
var options = Reveal.getConfig().math || {};
|
10
|
-
options.mathjax = options.mathjax || '
|
10
|
+
options.mathjax = options.mathjax || 'https://cdn.mathjax.org/mathjax/latest/MathJax.js';
|
11
11
|
options.config = options.config || 'TeX-AMS_HTML-full';
|
12
12
|
|
13
13
|
loadScript( options.mathjax + '?config=' + options.config, function() {
|
14
14
|
|
15
15
|
MathJax.Hub.Config({
|
16
16
|
messageStyle: 'none',
|
17
|
-
tex2jax: {
|
17
|
+
tex2jax: {
|
18
|
+
inlineMath: [['$','$'],['\\(','\\)']] ,
|
19
|
+
skipTags: ['script','noscript','style','textarea','pre']
|
20
|
+
},
|
18
21
|
skipStartupTypeset: true
|
19
22
|
});
|
20
23
|
|
@@ -1,37 +1,45 @@
|
|
1
|
+
var http = require('http');
|
1
2
|
var express = require('express');
|
2
3
|
var fs = require('fs');
|
3
4
|
var io = require('socket.io');
|
4
5
|
var crypto = require('crypto');
|
5
6
|
|
6
|
-
var app
|
7
|
-
var staticDir
|
7
|
+
var app = express();
|
8
|
+
var staticDir = express.static;
|
9
|
+
var server = http.createServer(app);
|
8
10
|
|
9
|
-
io
|
11
|
+
io = io(server);
|
10
12
|
|
11
13
|
var opts = {
|
12
|
-
port: 1948,
|
14
|
+
port: process.env.PORT || 1948,
|
13
15
|
baseDir : __dirname + '/../../'
|
14
16
|
};
|
15
17
|
|
16
|
-
io.
|
17
|
-
socket.on('
|
18
|
-
if (typeof
|
19
|
-
if (createHash(
|
20
|
-
|
21
|
-
socket.broadcast.emit(
|
18
|
+
io.on( 'connection', function( socket ) {
|
19
|
+
socket.on('multiplex-statechanged', function(data) {
|
20
|
+
if (typeof data.secret == 'undefined' || data.secret == null || data.secret === '') return;
|
21
|
+
if (createHash(data.secret) === data.socketId) {
|
22
|
+
data.secret = null;
|
23
|
+
socket.broadcast.emit(data.socketId, data);
|
22
24
|
};
|
23
25
|
});
|
24
26
|
});
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
app.use('/' + dir, staticDir(opts.baseDir + dir));
|
29
|
-
});
|
28
|
+
[ 'css', 'js', 'plugin', 'lib' ].forEach(function(dir) {
|
29
|
+
app.use('/' + dir, staticDir(opts.baseDir + dir));
|
30
30
|
});
|
31
31
|
|
32
32
|
app.get("/", function(req, res) {
|
33
33
|
res.writeHead(200, {'Content-Type': 'text/html'});
|
34
|
-
|
34
|
+
|
35
|
+
var stream = fs.createReadStream(opts.baseDir + '/index.html');
|
36
|
+
stream.on('error', function( error ) {
|
37
|
+
res.write('<style>body{font-family: sans-serif;}</style><h2>reveal.js multiplex server.</h2><a href="/token">Generate token</a>');
|
38
|
+
res.end();
|
39
|
+
});
|
40
|
+
stream.on('readable', function() {
|
41
|
+
stream.pipe(res);
|
42
|
+
});
|
35
43
|
});
|
36
44
|
|
37
45
|
app.get("/token", function(req,res) {
|
@@ -47,7 +55,7 @@ var createHash = function(secret) {
|
|
47
55
|
};
|
48
56
|
|
49
57
|
// Actually listen
|
50
|
-
|
58
|
+
server.listen( opts.port || null );
|
51
59
|
|
52
60
|
var brown = '\033[33m',
|
53
61
|
green = '\033[32m',
|
@@ -1,51 +1,31 @@
|
|
1
1
|
(function() {
|
2
|
+
|
2
3
|
// Don't emit events from inside of notes windows
|
3
4
|
if ( window.location.search.match( /receiver/gi ) ) { return; }
|
4
5
|
|
5
6
|
var multiplex = Reveal.getConfig().multiplex;
|
6
7
|
|
7
|
-
var socket = io.connect(multiplex.url);
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') {
|
20
|
-
nextindexh = indexh;
|
21
|
-
nextindexv = indexv + 1;
|
22
|
-
} else {
|
23
|
-
nextindexh = indexh + 1;
|
24
|
-
nextindexv = 0;
|
25
|
-
}
|
26
|
-
|
27
|
-
var slideData = {
|
28
|
-
indexh : indexh,
|
29
|
-
indexv : indexv,
|
30
|
-
indexf : fragmentindex,
|
31
|
-
nextindexh : nextindexh,
|
32
|
-
nextindexv : nextindexv,
|
33
|
-
secret: multiplex.secret,
|
34
|
-
socketId : multiplex.id
|
35
|
-
};
|
36
|
-
|
37
|
-
socket.emit('slidechanged', slideData);
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
Reveal.addEventListener( 'slidechanged', function( event ) {
|
42
|
-
notify( event.currentSlide, event.indexh, event.indexv, event.origin );
|
43
|
-
} );
|
44
|
-
|
45
|
-
var fragmentNotify = function( event ) {
|
46
|
-
notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin );
|
8
|
+
var socket = io.connect( multiplex.url );
|
9
|
+
|
10
|
+
function post() {
|
11
|
+
|
12
|
+
var messageData = {
|
13
|
+
state: Reveal.getState(),
|
14
|
+
secret: multiplex.secret,
|
15
|
+
socketId: multiplex.id
|
16
|
+
};
|
17
|
+
|
18
|
+
socket.emit( 'multiplex-statechanged', messageData );
|
19
|
+
|
47
20
|
};
|
48
21
|
|
49
|
-
|
50
|
-
Reveal.addEventListener( '
|
22
|
+
// Monitor events that trigger a change in state
|
23
|
+
Reveal.addEventListener( 'slidechanged', post );
|
24
|
+
Reveal.addEventListener( 'fragmentshown', post );
|
25
|
+
Reveal.addEventListener( 'fragmenthidden', post );
|
26
|
+
Reveal.addEventListener( 'overviewhidden', post );
|
27
|
+
Reveal.addEventListener( 'overviewshown', post );
|
28
|
+
Reveal.addEventListener( 'paused', post );
|
29
|
+
Reveal.addEventListener( 'resumed', post );
|
30
|
+
|
51
31
|
}());
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "reveal-js-multiplex",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "reveal.js multiplex server",
|
5
|
+
"homepage": "http://lab.hakim.se/reveal-js",
|
6
|
+
"scripts": {
|
7
|
+
"start": "node index.js"
|
8
|
+
},
|
9
|
+
"engines": {
|
10
|
+
"node": "~4.1.1"
|
11
|
+
},
|
12
|
+
"dependencies": {
|
13
|
+
"express": "~4.13.3",
|
14
|
+
"grunt-cli": "~0.1.13",
|
15
|
+
"mustache": "~2.2.1",
|
16
|
+
"socket.io": "~1.3.7"
|
17
|
+
},
|
18
|
+
"license": "MIT"
|
19
|
+
}
|
@@ -188,6 +188,10 @@
|
|
188
188
|
|
189
189
|
var data = JSON.parse( event.data );
|
190
190
|
|
191
|
+
// The overview mode is only useful to the reveal.js instance
|
192
|
+
// where navigation occurs so we don't sync it
|
193
|
+
if( data.state ) delete data.state.overview;
|
194
|
+
|
191
195
|
// Messages sent by the notes plugin inside of the main window
|
192
196
|
if( data && data.namespace === 'reveal-notes' ) {
|
193
197
|
if( data.type === 'connect' ) {
|
@@ -203,8 +207,10 @@
|
|
203
207
|
// Send a message back to notify that the handshake is complete
|
204
208
|
window.opener.postMessage( JSON.stringify({ namespace: 'reveal-notes', type: 'connected'} ), '*' );
|
205
209
|
}
|
206
|
-
else if( /slidechanged|fragmentshown|fragmenthidden|
|
210
|
+
else if( /slidechanged|fragmentshown|fragmenthidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) {
|
211
|
+
|
207
212
|
window.opener.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ]} ), '*' );
|
213
|
+
|
208
214
|
}
|
209
215
|
}
|
210
216
|
|
@@ -239,6 +245,7 @@
|
|
239
245
|
// No need for updating the notes in case of fragment changes
|
240
246
|
if ( data.notes ) {
|
241
247
|
notes.classList.remove( 'hidden' );
|
248
|
+
notesValue.style.whiteSpace = data.whitespace;
|
242
249
|
if( data.markdown ) {
|
243
250
|
notesValue.innerHTML = marked( data.notes );
|
244
251
|
}
|
@@ -287,9 +294,10 @@
|
|
287
294
|
'backgroundTransition=none'
|
288
295
|
].join( '&' );
|
289
296
|
|
297
|
+
var urlSeparator = /\?/.test(data.url) ? '&' : '?';
|
290
298
|
var hash = '#/' + data.state.indexh + '/' + data.state.indexv;
|
291
|
-
var currentURL = data.url +
|
292
|
-
var upcomingURL = data.url +
|
299
|
+
var currentURL = data.url + urlSeparator + params + '&postMessageEvents=true' + hash;
|
300
|
+
var upcomingURL = data.url + urlSeparator + params + '&controls=false' + hash;
|
293
301
|
|
294
302
|
currentSlide = document.createElement( 'iframe' );
|
295
303
|
currentSlide.setAttribute( 'width', 1280 );
|
@@ -11,10 +11,15 @@
|
|
11
11
|
*/
|
12
12
|
var RevealNotes = (function() {
|
13
13
|
|
14
|
-
function openNotes() {
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
function openNotes( notesFilePath ) {
|
15
|
+
|
16
|
+
if( !notesFilePath ) {
|
17
|
+
var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path
|
18
|
+
jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, ''); // the js folder path
|
19
|
+
notesFilePath = jsFileLocation + 'notes.html';
|
20
|
+
}
|
21
|
+
|
22
|
+
var notesPopup = window.open( notesFilePath, 'reveal.js - Notes', 'width=1100,height=700' );
|
18
23
|
|
19
24
|
/**
|
20
25
|
* Connect to the notes window through a postmessage handshake.
|
@@ -28,7 +33,7 @@ var RevealNotes = (function() {
|
|
28
33
|
notesPopup.postMessage( JSON.stringify( {
|
29
34
|
namespace: 'reveal-notes',
|
30
35
|
type: 'connect',
|
31
|
-
url: window.location.protocol + '//' + window.location.host + window.location.pathname,
|
36
|
+
url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search,
|
32
37
|
state: Reveal.getState()
|
33
38
|
} ), '*' );
|
34
39
|
}, 500 );
|
@@ -55,12 +60,14 @@ var RevealNotes = (function() {
|
|
55
60
|
type: 'state',
|
56
61
|
notes: '',
|
57
62
|
markdown: false,
|
63
|
+
whitespace: 'normal',
|
58
64
|
state: Reveal.getState()
|
59
65
|
};
|
60
66
|
|
61
67
|
// Look for notes defined in a slide attribute
|
62
68
|
if( slideElement.hasAttribute( 'data-notes' ) ) {
|
63
69
|
messageData.notes = slideElement.getAttribute( 'data-notes' );
|
70
|
+
messageData.whitespace = 'pre-wrap';
|
64
71
|
}
|
65
72
|
|
66
73
|
// Look for notes defined in an aside element
|
@@ -94,6 +101,7 @@ var RevealNotes = (function() {
|
|
94
101
|
}
|
95
102
|
|
96
103
|
connect();
|
104
|
+
|
97
105
|
}
|
98
106
|
|
99
107
|
if( !/receiver/i.test( window.location.search ) ) {
|
@@ -109,12 +117,18 @@ var RevealNotes = (function() {
|
|
109
117
|
// modifier is present
|
110
118
|
if ( document.querySelector( ':focus' ) !== null || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return;
|
111
119
|
|
120
|
+
// Disregard the event if keyboard is disabled
|
121
|
+
if ( Reveal.getConfig().keyboard === false ) return;
|
122
|
+
|
112
123
|
if( event.keyCode === 83 ) {
|
113
124
|
event.preventDefault();
|
114
125
|
openNotes();
|
115
126
|
}
|
116
127
|
}, false );
|
117
128
|
|
129
|
+
// Show our keyboard shortcut in the reveal.js help overlay
|
130
|
+
if( window.Reveal ) Reveal.registerKeyboardShortcut( 'S', 'Speaker notes view' );
|
131
|
+
|
118
132
|
}
|
119
133
|
|
120
134
|
return { open: openNotes };
|
@@ -41,10 +41,15 @@
|
|
41
41
|
}
|
42
42
|
|
43
43
|
// When a new notes window connects, post our current state
|
44
|
-
socket.on( '
|
44
|
+
socket.on( 'new-subscriber', function( data ) {
|
45
45
|
post();
|
46
46
|
} );
|
47
47
|
|
48
|
+
// When the state changes from inside of the speaker view
|
49
|
+
socket.on( 'statechanged-speaker', function( data ) {
|
50
|
+
Reveal.setState( data.state );
|
51
|
+
} );
|
52
|
+
|
48
53
|
// Monitor events that trigger a change in state
|
49
54
|
Reveal.addEventListener( 'slidechanged', post );
|
50
55
|
Reveal.addEventListener( 'fragmentshown', post );
|
@@ -1,39 +1,42 @@
|
|
1
|
+
var http = require('http');
|
1
2
|
var express = require('express');
|
2
3
|
var fs = require('fs');
|
3
4
|
var io = require('socket.io');
|
4
|
-
var _ = require('underscore');
|
5
5
|
var Mustache = require('mustache');
|
6
6
|
|
7
|
-
var app = express
|
7
|
+
var app = express();
|
8
8
|
var staticDir = express.static;
|
9
|
+
var server = http.createServer(app);
|
9
10
|
|
10
|
-
io
|
11
|
+
io = io(server);
|
11
12
|
|
12
13
|
var opts = {
|
13
14
|
port : 1947,
|
14
15
|
baseDir : __dirname + '/../../'
|
15
16
|
};
|
16
17
|
|
17
|
-
io.
|
18
|
+
io.on( 'connection', function( socket ) {
|
18
19
|
|
19
|
-
socket.on( '
|
20
|
-
socket.broadcast.emit( '
|
20
|
+
socket.on( 'new-subscriber', function( data ) {
|
21
|
+
socket.broadcast.emit( 'new-subscriber', data );
|
21
22
|
});
|
22
23
|
|
23
24
|
socket.on( 'statechanged', function( data ) {
|
25
|
+
delete data.state.overview;
|
24
26
|
socket.broadcast.emit( 'statechanged', data );
|
25
27
|
});
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
[ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) {
|
32
|
-
app.use( '/' + dir, staticDir( opts.baseDir + dir ) );
|
29
|
+
socket.on( 'statechanged-speaker', function( data ) {
|
30
|
+
delete data.state.overview;
|
31
|
+
socket.broadcast.emit( 'statechanged-speaker', data );
|
33
32
|
});
|
34
33
|
|
35
34
|
});
|
36
35
|
|
36
|
+
[ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) {
|
37
|
+
app.use( '/' + dir, staticDir( opts.baseDir + dir ) );
|
38
|
+
});
|
39
|
+
|
37
40
|
app.get('/', function( req, res ) {
|
38
41
|
|
39
42
|
res.writeHead( 200, { 'Content-Type': 'text/html' } );
|
@@ -52,7 +55,7 @@ app.get( '/notes/:socketId', function( req, res ) {
|
|
52
55
|
});
|
53
56
|
|
54
57
|
// Actually listen
|
55
|
-
|
58
|
+
server.listen( opts.port || null );
|
56
59
|
|
57
60
|
var brown = '\033[33m',
|
58
61
|
green = '\033[32m',
|
@@ -62,5 +65,5 @@ var slidesLocation = 'http://localhost' + ( opts.port ? ( ':' + opts.port ) : ''
|
|
62
65
|
|
63
66
|
console.log( brown + 'reveal.js - Speaker Notes' + reset );
|
64
67
|
console.log( '1. Open the slides at ' + green + slidesLocation + reset );
|
65
|
-
console.log( '2. Click on the link your JS console to go to the notes page' );
|
68
|
+
console.log( '2. Click on the link in your JS console to go to the notes page' );
|
66
69
|
console.log( '3. Advance through your slides and your notes will advance automatically' );
|