1
0
mirror of https://github.com/hakimel/reveal.js.git synced 2025-09-18 18:41:38 +02:00

Compare commits

..

28 Commits
2.6.0 ... 2.6.2

Author SHA1 Message Date
Hakim El Hattab
9da952fea3 Merge pull request #832 from craigcitro/patch-1
tweak layout in readme installation markup
2014-03-25 21:36:09 +01:00
Hakim El Hattab
7285653b01 update version to 2.6.2 to fix broken tarball on npm #506 2014-03-18 15:07:42 +01:00
Craig Citro
da949c33e0 Tweak layout in README.md installation markup.
Some code blocks weren't indented, so they ended up messing up the numbering. Indenting them fixed it.
2014-03-14 23:21:23 -07:00
Hakim El Hattab
55dceaaa0a update (c) year 2014-03-13 09:23:45 +01:00
Hakim El Hattab
08fb6cb2f9 fix pdf print bug in chrome 33 #808 2014-02-28 12:16:14 +01:00
Alex Juarez
8b8cc607d4 The index.html page had the simple theme listed twice. The duplicate was removed.
For the Moon and Solarized themes they had .css appended to them which was causing them to not come up.
2013-12-15 19:53:08 +01:00
Hakim El Hattab
4068c5221d add instructions to features that require a local web server (closes #732, #673, #559) 2013-12-02 21:33:44 +01:00
Hakim El Hattab
e6069caa86 2.6.1 #734 2013-12-02 12:24:18 +01:00
Hakim El Hattab
552525c7a5 rename markdown attribute test files to same format 2013-12-02 12:23:18 +01:00
Hakim El Hattab
9a9ce672b7 add example of markdown slide and element attributes 2013-12-02 12:20:48 +01:00
Hakim El Hattab
bc62963c8f readme correction for #734 2013-12-02 12:20:29 +01:00
Hakim El Hattab
65bd155c34 Merge branch 'attributes' of https://github.com/VonC/reveal.js into dev 2013-12-02 12:12:27 +01:00
VonC
fdb03b4f10 README.md mentions the new default separators.
- new default separator for slide attributes
- new default separator for element attributes
Illustrate both, in html comments.
2013-11-30 23:12:42 +01:00
VonC
78dfbf5202 test-markdown-element-attributes: formats and test.
- Reformat
- Use new default separator format: '.element: x=y'
- Add new tests for testing that default format
2013-11-30 23:12:41 +01:00
VonC
d4e04b82dc test-markdown-attributes.*, new default separator
- Reformat.
- Change default separator test 'slide: x=y'
2013-11-30 23:12:41 +01:00
VonC
f2097417da Simpler default syntax for markdown attributes.
- on slides: .slide x=y
- on elements: .element x=y

Those are detected in html comment, in order to not be visible
if a markdown is edited in an html editor.
2013-11-30 23:12:40 +01:00
VonC
13da34cc6b Removes console.log calls. 2013-11-30 23:12:40 +01:00
VonC
d52eb599d1 Fix previous element selection. 2013-11-30 23:12:39 +01:00
VonC
8ad633e4f3 Fix element attributes, except for multi-line. 2013-11-30 23:12:39 +01:00
VonC
3330c2a764 Remove section attribute implementation. 2013-11-30 23:12:38 +01:00
VonC
dd9fa3e22b First refactoring 2013-11-30 23:12:38 +01:00
Hakim El Hattab
31438c88ba Merge branch 'dev' of github.com:hakimel/reveal.js 2013-11-28 16:48:46 -05:00
Hakim El Hattab
3d2549d4f4 documentation for slide numbers 2013-11-28 16:48:36 -05:00
Hakim El Hattab
f1a416d07c tests for initial section classes 2013-11-28 11:31:16 -05:00
Hakim El Hattab
599bef5fdf Merge branch 'dev' of github.com:hakimel/reveal.js 2013-11-28 09:35:28 -05:00
Hakim El Hattab
f7b612b1e4 only run vertical slide setup during startup #726 2013-11-28 09:35:04 -05:00
Hakim El Hattab
0eba619c1a add example for parallax backgrounds 2013-11-27 14:49:39 -05:00
Hakim El Hattab
b314cf7b27 improvement to query string parsing 2013-11-27 13:16:03 -05:00
17 changed files with 346 additions and 226 deletions

View File

@@ -11,7 +11,7 @@ module.exports = function(grunt) {
' * http://lab.hakim.se/reveal-js\n' + ' * http://lab.hakim.se/reveal-js\n' +
' * MIT licensed\n' + ' * MIT licensed\n' +
' *\n' + ' *\n' +
' * Copyright (C) 2013 Hakim El Hattab, http://hakim.se\n' + ' * Copyright (C) 2014 Hakim El Hattab, http://hakim.se\n' +
' */' ' */'
}, },
@@ -69,7 +69,8 @@ module.exports = function(grunt) {
globals: { globals: {
head: false, head: false,
module: false, module: false,
console: false console: false,
unescape: false
} }
}, },
files: [ 'Gruntfile.js', 'js/reveal.js' ] files: [ 'Gruntfile.js', 'js/reveal.js' ]

View File

@@ -1,4 +1,4 @@
Copyright (C) 2013 Hakim El Hattab, http://hakim.se Copyright (C) 2014 Hakim El Hattab, http://hakim.se
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@@ -54,31 +54,38 @@ This is based on [data-markdown](https://gist.github.com/1343518) from [Paul Iri
You can write your content as a separate file and have reveal.js load it at runtime. Note the separator arguments which determine how slides are delimited in the external file. The ```data-charset``` attribute is optional and specifies which charset to use when loading the external file. You can write your content as a separate file and have reveal.js load it at runtime. Note the separator arguments which determine how slides are delimited in the external file. The ```data-charset``` attribute is optional and specifies which charset to use when loading the external file.
When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup).
```html ```html
<section data-markdown="example.md" data-separator="^\n\n\n" data-vertical="^\n\n" data-notes="^Note:" data-charset="iso-8859-15"></section> <section data-markdown="example.md"
data-separator="^\n\n\n"
data-vertical="^\n\n"
data-notes="^Note:"
data-charset="iso-8859-15">
</section>
``` ```
#### Element Attributes #### Element Attributes
Special syntax is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things. Special syntax (in html comment) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things.
```html ```html
<section data-markdown> <section data-markdown>
<script type="text/template"> <script type="text/template">
- Item 1 {.class="fragment" data-fragment-index="2"} - Item 1 <!-- .element: class="fragment" data-fragment-index="2" -->
- Item 2 {.class="fragment" data-fragment-index="1"} - Item 2 <!-- .element: class="fragment" data-fragment-index="1" -->
</script> </script>
</section> </section>
``` ```
#### Slide Attributes #### Slide Attributes
Special syntax is available for adding attributes to the slide `<section>` elements generated by your Markdown. Special syntax (in html comment) is available for adding attributes to the slide `<section>` elements generated by your Markdown.
```html ```html
<section data-markdown> <section data-markdown>
<script type="text/template"> <script type="text/template">
<!-- slide-attributes: data-background="#ff0000" --> <!-- .slide: data-background="#ff0000" -->
Mardown content Mardown content
</script> </script>
</section> </section>
@@ -388,7 +395,7 @@ Reveal.initialize({
}); });
``` ```
Make sure that the background size is much bigger than screen size to allow for some scrolling. Make sure that the background size is much bigger than screen size to allow for some scrolling. [View example](http://lab.hakim.se/reveal-js/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg&parallaxBackgroundSize=2100px%20900px).
@@ -499,6 +506,13 @@ By default, Reveal is configured with [highlight.js](http://softwaremaniacs.org/
</section> </section>
``` ```
### Slide number
If you would like to display the page number of the current slide you can do so using the ```slideNumber``` configuration value.
```javascript
Reveal.configure({ slideNumber: true });
```
### Overview mode ### Overview mode
@@ -585,6 +599,8 @@ reveal.js comes with a speaker notes plugin which can be used to present per-sli
Notes are defined by appending an ```<aside>``` element to a slide as seen below. You can add the ```data-markdown``` attribute to the aside element if you prefer writing notes using Markdown. Notes are defined by appending an ```<aside>``` element to a slide as seen below. You can add the ```data-markdown``` attribute to the aside element if you prefer writing notes using Markdown.
When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup).
```html ```html
<section> <section>
<h2>Some Slide</h2> <h2>Some Slide</h2>
@@ -855,35 +871,35 @@ The core of reveal.js is very easy to install. You'll simply need to download a
### Full setup ### Full setup
Some reveal.js features, like external markdown, require that presentations run from a local web server. The following instructions will set up such a server as well as all of the development tasks needed to make edits to the reveal.js source code. Some reveal.js features, like external markdown and speaker notes, require that presentations run from a local web server. The following instructions will set up such a server as well as all of the development tasks needed to make edits to the reveal.js source code.
1. Install [Node.js](http://nodejs.org/) 1. Install [Node.js](http://nodejs.org/)
2. Install [Grunt](http://gruntjs.com/getting-started#installing-the-cli) 2. Install [Grunt](http://gruntjs.com/getting-started#installing-the-cli)
4. Clone the reveal.js repository 4. Clone the reveal.js repository
```sh ```sh
$ git clone https://github.com/hakimel/reveal.js.git $ git clone https://github.com/hakimel/reveal.js.git
``` ```
5. Navigate to the reveal.js folder 5. Navigate to the reveal.js folder
```sh ```sh
$ cd reveal.js $ cd reveal.js
``` ```
6. Install dependencies 6. Install dependencies
```sh ```sh
$ npm install $ npm install
``` ```
7. Serve the presentation and monitor source files for changes 7. Serve the presentation and monitor source files for changes
```sh ```sh
$ grunt serve $ grunt serve
``` ```
8. Open <http://localhost:8000> to view your presentation 8. Open <http://localhost:8000> to view your presentation
You can change the port by using `grunt serve --port 8001`. You can change the port by using `grunt serve --port 8001`.
### Folder Structure ### Folder Structure
@@ -914,4 +930,4 @@ If you have personal support questions use [StackOverflow](http://stackoverflow.
MIT licensed MIT licensed
Copyright (C) 2013 Hakim El Hattab, http://hakim.se Copyright (C) 2014 Hakim El Hattab, http://hakim.se

View File

@@ -5,7 +5,7 @@
* http://lab.hakim.se/reveal-js * http://lab.hakim.se/reveal-js
* MIT licensed * MIT licensed
* *
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se * Copyright (C) 2014 Hakim El Hattab, http://hakim.se
*/ */

2
css/reveal.min.css vendored

File diff suppressed because one or more lines are too long

View File

@@ -20,9 +20,15 @@
<!-- For syntax highlighting --> <!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css"> <link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet --> <!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script> <script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' ); if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script> </script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
@@ -173,9 +179,8 @@
<a href="?theme=simple#/themes">Simple</a> - <a href="?theme=simple#/themes">Simple</a> -
<a href="?theme=serif#/themes">Serif</a> - <a href="?theme=serif#/themes">Serif</a> -
<a href="?theme=night#/themes">Night</a> <br> <a href="?theme=night#/themes">Night</a> <br>
<a href="?theme=moon.css#/themes">Moon</a> - <a href="?theme=moon#/themes">Moon</a> -
<a href="?theme=simple.css#/themes">Simple</a> - <a href="?theme=solarized#/themes">Solarized</a>
<a href="?theme=solarized.css#/themes">Solarized</a>
</p> </p>
<p> <p>
<small> <small>

View File

@@ -3,7 +3,7 @@
* http://lab.hakim.se/reveal-js * http://lab.hakim.se/reveal-js
* MIT licensed * MIT licensed
* *
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se * Copyright (C) 2014 Hakim El Hattab, http://hakim.se
*/ */
var Reveal = (function(){ var Reveal = (function(){
@@ -316,8 +316,8 @@ var Reveal = (function(){
// Make sure we've got all the DOM elements we need // Make sure we've got all the DOM elements we need
setupDOM(); setupDOM();
// Decorate the slide DOM elements with state classes (past/future) // Resets all vertical slides so that only the first is visible
formatSlides(); resetVerticalSlides();
// Updates the presentation to match the current configuration values // Updates the presentation to match the current configuration values
configure(); configure();
@@ -1603,7 +1603,7 @@ var Reveal = (function(){
// Re-create the slide backgrounds // Re-create the slide backgrounds
createBackgrounds(); createBackgrounds();
formatSlides(); sortAllFragments();
updateControls(); updateControls();
updateProgress(); updateProgress();
@@ -1613,10 +1613,10 @@ var Reveal = (function(){
} }
/** /**
* Iterates through and decorates slides DOM elements with * Resets all vertical slides so that only the first
* appropriate classes. * is visible.
*/ */
function formatSlides() { function resetVerticalSlides() {
var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ); var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
horizontalSlides.forEach( function( horizontalSlide ) { horizontalSlides.forEach( function( horizontalSlide ) {
@@ -1624,7 +1624,29 @@ var Reveal = (function(){
var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ); var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
verticalSlides.forEach( function( verticalSlide, y ) { verticalSlides.forEach( function( verticalSlide, y ) {
if( y > 0 ) verticalSlide.classList.add( 'future' ); if( y > 0 ) {
verticalSlide.classList.remove( 'present' );
verticalSlide.classList.remove( 'past' );
verticalSlide.classList.add( 'future' );
}
} );
} );
}
/**
* Sorts and formats all of fragments in the
* presentation.
*/
function sortAllFragments() {
var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
horizontalSlides.forEach( function( horizontalSlide ) {
var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
verticalSlides.forEach( function( verticalSlide, y ) {
sortFragments( verticalSlide.querySelectorAll( '.fragment' ) ); sortFragments( verticalSlide.querySelectorAll( '.fragment' ) );
@@ -3300,17 +3322,20 @@ var Reveal = (function(){
getQueryHash: function() { getQueryHash: function() {
var query = {}; var query = {};
location.search.replace( /[A-Z0-9]+?=(\w*)/gi, function(a) { location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, function(a) {
query[ a.split( '=' ).shift() ] = a.split( '=' ).pop(); query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
} ); } );
// Basic deserialization // Basic deserialization
for( var i in query ) { for( var i in query ) {
var value = query[ i ]; var value = query[ i ];
query[ i ] = unescape( value );
if( value === 'null' ) query[ i ] = null; if( value === 'null' ) query[ i ] = null;
else if( value === 'true' ) query[ i ] = true; else if( value === 'true' ) query[ i ] = true;
else if( value === 'false' ) query[ i ] = false; else if( value === 'false' ) query[ i ] = false;
else if( !isNaN( parseFloat( value ) ) ) query[ i ] = parseFloat( value ); else if( value.match( /^\d+$/ ) ) query[ i ] = parseFloat( value );
} }
return query; return query;

8
js/reveal.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "reveal.js", "name": "reveal.js",
"version": "2.6.0", "version": "2.6.2",
"description": "The HTML Presentation Framework", "description": "The HTML Presentation Framework",
"homepage": "http://lab.hakim.se/reveal-js", "homepage": "http://lab.hakim.se/reveal-js",
"subdomain": "revealjs", "subdomain": "revealjs",

View File

@@ -68,20 +68,35 @@
</script> </script>
</section> </section>
<!-- Slide attributes -->
<section data-markdown>
<script type="text/template">
<!-- .slide: data-background="#000000" -->
## Slide attributes
</script>
</section>
<!-- Element attributes -->
<section data-markdown>
<script type="text/template">
## Element attributes
- Item 1 <!-- .element: class="fragment" data-fragment-index="2" -->
- Item 2 <!-- .element: class="fragment" data-fragment-index="1" -->
</script>
</section>
<!-- Code --> <!-- Code -->
<section> <section data-markdown>
<section data-markdown> <script type="text/template">
<script type="text/template"> ```php
```php public function foo()
public function foo() {
{ $foo = array(
$foo = array( 'bar' => 'bar'
'bar' => 'bar' )
) }
} ```
``` </script>
</script>
</section>
</section> </section>
</div> </div>

View File

@@ -28,8 +28,8 @@
var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$', var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$',
DEFAULT_NOTES_SEPARATOR = 'note:', DEFAULT_NOTES_SEPARATOR = 'note:',
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '{\\\.\s*?([^}]+?)}', DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '^.*?<!--\\\sslide-attributes:\\\s(.*?)-->'; DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';
/** /**
@@ -73,7 +73,7 @@
value = attributes[i].value; value = attributes[i].value;
// disregard attributes that are used for markdown loading/parsing // disregard attributes that are used for markdown loading/parsing
if( /data\-(markdown|separator|vertical|notes|attributes)/gi.test( name ) ) continue; if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue;
if( value ) { if( value ) {
result.push( name + '=' + value ); result.push( name + '=' + value );
@@ -97,7 +97,6 @@
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR; options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR; options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
options.attributes = options.attributes || ''; options.attributes = options.attributes || '';
options.slideAttributesSeparator = options.slideAttributesSeparator || DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR;
return options; return options;
@@ -129,17 +128,14 @@
options = getSlidifyOptions( options ); options = getSlidifyOptions( options );
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ), var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
horizontalSeparatorRegex = new RegExp( options.separator ), horizontalSeparatorRegex = new RegExp( options.separator );
slideAttributesSeparatorRegex = new RegExp( options.slideAttributesSeparator, 'm' );
var matches, var matches,
lastIndex = 0, lastIndex = 0,
isHorizontal, isHorizontal,
wasHorizontal = true, wasHorizontal = true,
content, content,
sectionStack = [], sectionStack = [];
matchAttributes,
slideAttributes = "";
// iterate until all blocks between separators are stacked up // iterate until all blocks between separators are stacked up
while( matches = separatorRegex.exec( markdown ) ) { while( matches = separatorRegex.exec( markdown ) ) {
@@ -178,35 +174,19 @@
for( var i = 0, len = sectionStack.length; i < len; i++ ) { for( var i = 0, len = sectionStack.length; i < len; i++ ) {
// vertical // vertical
if( sectionStack[i] instanceof Array ) { if( sectionStack[i] instanceof Array ) {
// The 'data-xxx' attributes of the first child must be set on the wrapping parent section to be effective markdownSections += '<section '+ options.attributes +'>';
// Mainly for data-transition (otherwise, it is ignored for the first vertical slide)
firstChild = sectionStack[i][0];
matchAttributes = slideAttributesSeparatorRegex.exec( firstChild );
slideAttributes = matchAttributes ? matchAttributes[1] : "";
dataAttributes = "";
if( slideAttributes != "" ) {
// http://stackoverflow.com/questions/18025762/javascript-regex-replace-all-word-characters-except-word-characters-between-ch
// Keep only data-attributes for the parent slide section.
dataAttributes = slideAttributes.replace( /(data-\S+=\"[^\"]+?\")|\w|[\"=]/g, function(a, b) { return b || ''; });
}
markdownSections += '<section '+ options.attributes + ' ' + dataAttributes + '>';
sectionStack[i].forEach( function( child ) { sectionStack[i].forEach( function( child ) {
matchAttributes = slideAttributesSeparatorRegex.exec( child ); markdownSections += '<section data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
slideAttributes = matchAttributes ? matchAttributes[1] : "";
child = matchAttributes ? child.replace( slideAttributesSeparatorRegex,"" ) : child
markdownSections += '<section ' + slideAttributes + ' data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
} ); } );
markdownSections += '</section>'; markdownSections += '</section>';
} }
else { else {
matchAttributes = slideAttributesSeparatorRegex.exec( sectionStack[i] ); markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i], options ) + '</section>';
slideAttributes = matchAttributes ? matchAttributes[1] : "";
content = matchAttributes ? sectionStack[i].replace( slideAttributesSeparatorRegex,"" ) : sectionStack[i]
markdownSections += '<section '+ options.attributes + ' ' + slideAttributes +' data-markdown>' + createMarkdownSlide( content, options ) + '</section>';
} }
} }
return markdownSections; return markdownSections;
} }
@@ -240,12 +220,12 @@
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if( xhr.readyState === 4 ) { if( xhr.readyState === 4 ) {
if ( xhr.status >= 200 && xhr.status < 300 ) { if ( xhr.status >= 200 && xhr.status < 300 ) {
section.outerHTML = slidify( xhr.responseText, { section.outerHTML = slidify( xhr.responseText, {
separator: section.getAttribute( 'data-separator' ), separator: section.getAttribute( 'data-separator' ),
verticalSeparator: section.getAttribute( 'data-vertical' ), verticalSeparator: section.getAttribute( 'data-vertical' ),
notesSeparator: section.getAttribute( 'data-notes' ), notesSeparator: section.getAttribute( 'data-notes' ),
attributes: getForwardedAttributes( section ), attributes: getForwardedAttributes( section )
slideAttributesSeparator: section.getAttribute( 'data-attributes' ),
}); });
} }
@@ -277,24 +257,12 @@
separator: section.getAttribute( 'data-separator' ), separator: section.getAttribute( 'data-separator' ),
verticalSeparator: section.getAttribute( 'data-vertical' ), verticalSeparator: section.getAttribute( 'data-vertical' ),
notesSeparator: section.getAttribute( 'data-notes' ), notesSeparator: section.getAttribute( 'data-notes' ),
attributes: getForwardedAttributes( section ), attributes: getForwardedAttributes( section )
slideAttributesSeparator: section.getAttribute( 'data-attributes' ),
}); });
} }
else { else {
var content = getMarkdownFromSlide( section ); section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) );
var slideAttributesSeparatorRegex = new RegExp( section.getAttribute( 'data-attributes' ) || DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR, 'm' );
var matchAttributes = slideAttributesSeparatorRegex.exec( content );
if ( matchAttributes ) {
var slideAttributes = matchAttributes[1];
content = content.replace( slideAttributesSeparatorRegex,"" );
var slideAttributesRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
while( matchesAttributes = slideAttributesRegex.exec( slideAttributes ) ) {
section.setAttribute( matchesAttributes[1], matchesAttributes[2] );
}
}
section.innerHTML = createMarkdownSlide( content );
} }
} }
@@ -319,40 +287,51 @@
var classes = matches[1]; var classes = matches[1];
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex ); nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
node.nodeValue = nodeValue; node.nodeValue = nodeValue;
while( matchesClass = mardownClassRegex.exec( classes ) ) { while( matchesClass = mardownClassRegex.exec( classes ) ) {
elementTarget.setAttribute( matchesClass[1], matchesClass[2] ); elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
} }
return true;
} }
return false;
} }
/** /**
* Add attributes to the parent element of a text node, * Add attributes to the parent element of a text node,
* or the element of an attribute node. * or the element of an attribute node.
*/ */
function addAttributes( element, separator ) { function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
if( element.childNodes.length > 0 ) { if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
previousParentElement = element;
for( var i = 0; i < element.childNodes.length; i++ ) { for( var i = 0; i < element.childNodes.length; i++ ) {
addAttributes( element.childNodes[i], separator ); childElement = element.childNodes[i];
if ( i > 0 ) {
j = i - 1;
while ( j >= 0 ) {
aPreviousChildElement = element.childNodes[j];
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) {
previousParentElement = aPreviousChildElement;
break;
}
j = j - 1;
}
}
parentSection = section;
if( childElement.nodeName == "section" ) {
parentSection = childElement ;
previousParentElement = childElement ;
}
if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) {
addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
}
} }
} }
var nodeValue; if ( element.nodeType == Node.COMMENT_NODE ) {
var elementTarget; if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) {
addAttributeInElement( element, section, separatorSectionAttributes );
// From http://stackoverflow.com/questions/9178174/find-all-text-nodes
if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
addAttributeInElement( element, element.parentNode, separator );
}
if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
for( var j = 0; j < element.attributes.length; j++ ){
var attr = element.attributes[j];
addAttributeInElement( attr, element, separator );
} }
} }
} }
/** /**
@@ -376,9 +355,12 @@
var markdown = getMarkdownFromSlide( section ); var markdown = getMarkdownFromSlide( section );
section.innerHTML = marked( markdown ); section.innerHTML = marked( markdown );
addAttributes( section, section.getAttribute( 'data-element-attributes' ) || addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) ||
section.parentNode.getAttribute( 'data-element-attributes' ) || section.parentNode.getAttribute( 'data-element-attributes' ) ||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR ); DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR,
section.getAttribute( 'data-attributes' ) ||
section.parentNode.getAttribute( 'data-attributes' ) ||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR);
// If there were notes, we need to re-add them after // If there were notes, we need to re-add them after
// having overwritten the section's HTML // having overwritten the section's HTML

View File

@@ -1,47 +0,0 @@
Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' );
test( 'Vertical separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 6, 'found six vertical slides' );
});
test( 'Id on slide', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section#slide2' ).length, 1, 'found one slide with id slide2' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section a[href="#/slide2"]' ).length, 1, 'found one slide with a link to slide2' );
});
test( 'data-background attributes', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A0C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#ff0000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C6916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
});
test( 'data-transition attributes', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="zoom"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="fade"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="zoom"]' ).length, 1, 'found one slide with data-transition="zoom"' );
});
test( 'data-background attributes with default separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A7C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#f70000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C7916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
});
test( 'data-transition attributes with default separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="concave"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="page"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="concave"]' ).length, 1, 'found one slide with data-transition="zoom"' );
});
test( 'data-transition attributes with inline content', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#ff0000"]' ).length, 3, 'found three horizontal slides with data-background="#ff0000"' );
});
} );
Reveal.initialize();

View File

@@ -4,7 +4,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>reveal.js - Test Markdown</title> <title>reveal.js - Test Markdown Element Attributes</title>
<link rel="stylesheet" href="../css/reveal.min.css"> <link rel="stylesheet" href="../css/reveal.min.css">
<link rel="stylesheet" href="qunit-1.12.0.css"> <link rel="stylesheet" href="qunit-1.12.0.css">
@@ -13,7 +13,7 @@
<body style="overflow: auto;"> <body style="overflow: auto;">
<div id="qunit"></div> <div id="qunit"></div>
<div id="qunit-fixture"></div> <div id="qunit-fixture"></div>
<div class="reveal" style="display: none;"> <div class="reveal" style="display: none;">
@@ -24,19 +24,23 @@
<!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes --> <!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
<section data-markdown data-separator="^\n---\n$" data-vertical="^\n--\n$" data-element-attributes="{_\s*?([^}]+?)}">> <section data-markdown data-separator="^\n---\n$" data-vertical="^\n--\n$" data-element-attributes="{_\s*?([^}]+?)}">>
<script type="text/template"> <script type="text/template">
## Slide 1.1 {_class="fragment fade-out" data-fragment-index="1"} ## Slide 1.1
<!-- {_class="fragment fade-out" data-fragment-index="1"} -->
-- --
## Slide 1.2 {_class="fragment shrink"} ## Slide 1.2
<!-- {_class="fragment shrink"} -->
Paragraph 1 {_class="fragment grow"} Paragraph 1
<!-- {_class="fragment grow"} -->
Paragraph 2 {_class="fragment grow"} Paragraph 2
<!-- {_class="fragment grow"} -->
- list item 1 {_class="fragment roll-in"} - list item 1 <!-- {_class="fragment roll-in"} -->
- list item 2 {_class="fragment roll-in"} - list item 2 <!-- {_class="fragment roll-in"} -->
- list item 3 {_class="fragment roll-in"} - list item 3 <!-- {_class="fragment roll-in"} -->
--- ---
@@ -45,27 +49,75 @@
Paragraph 1.2 Paragraph 1.2
multi-line {_class="fragment highlight-red"} multi-line <!-- {_class="fragment highlight-red"} -->
Paragraph 2.2 {_class="fragment highlight-red"} Paragraph 2.2 <!-- {_class="fragment highlight-red"} -->
Paragraph 2.3 {_class="fragment highlight-red"} Paragraph 2.3 <!-- {_class="fragment highlight-red"} -->
Paragraph 2.4 {_class="fragment highlight-red"} Paragraph 2.4 <!-- {_class="fragment highlight-red"} -->
- list item 1 {_class="fragment highlight-green"} - list item 1 <!-- {_class="fragment highlight-green"} -->
- list item 2 {_class="fragment highlight-green"} - list item 2<!-- {_class="fragment highlight-green"} -->
- list item 3 {_class="fragment highlight-green"} - list item 3<!-- {_class="fragment highlight-green"} -->
- list item 4 {_class="fragment highlight-green"} - list item 4
- list item 5 {_class="fragment highlight-green"} <!-- {_class="fragment highlight-green"} -->
- list item 5<!-- {_class="fragment highlight-green"} -->
Test Test
![Example Picture{_class="reveal stretch"}](assets/image2.png) ![Example Picture](examples/assets/image2.png)
<!-- {_class="reveal stretch"} -->
</script> </script>
</section> </section>
<section data-markdown data-separator="^\n\n\n"
data-vertical="^\n\n"
data-notes="^Note:"
data-charset="utf-8">
<script type="text/template">
# Test attributes in Markdown with default separator
## Slide 1 Def <!-- .element: class="fragment highlight-red" data-fragment-index="1" -->
## Slide 2 Def
<!-- .element: class="fragment highlight-red" -->
</script>
</section>
<section data-markdown>
<script type="text/template">
## Hello world
A paragraph
<!-- .element: class="fragment highlight-blue" -->
</script>
</section>
<section data-markdown>
<script type="text/template">
## Hello world
Multiple
Line
<!-- .element: class="fragment highlight-blue" -->
</script>
</section>
<section data-markdown>
<script type="text/template">
## Hello world
Test<!-- .element: class="fragment highlight-blue" -->
More Test
</script>
</section>
</div> </div>
</div> </div>

View File

@@ -5,33 +5,41 @@ Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' ); QUnit.module( 'Markdown' );
test( 'Vertical separator', function() { test( 'Vertical separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' ); strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 4, 'found four slides' );
}); });
test( 'Attributes on vertical slides header', function() { test( 'Attributes on element header in vertical slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' ); strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' );
strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.shrink' ).length, 1, 'found one vertical slide with class fragment.shrink on header' ); strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.shrink' ).length, 1, 'found one vertical slide with class fragment.shrink on header' );
}); });
test( 'Attributes on vertical slides paragraphs', function() { test( 'Attributes on element paragraphs in vertical slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section>section p.fragment.grow' ).length, 2, 'found a vertical slide with two paragraphs with class fragment.grow' ); strictEqual( document.querySelectorAll( '.reveal .slides section>section p.fragment.grow' ).length, 2, 'found a vertical slide with two paragraphs with class fragment.grow' );
}); });
test( 'Attributes on vertical slides list items', function() { test( 'Attributes on element list items in vertical slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section>section li.fragment.roll-in' ).length, 3, 'found a vertical slide with three list items with class fragment.roll-in' ); strictEqual( document.querySelectorAll( '.reveal .slides section>section li.fragment.roll-in' ).length, 3, 'found a vertical slide with three list items with class fragment.roll-in' );
}); });
test( 'Attributes on horizontal slides paragraphs', function() { test( 'Attributes on element paragraphs in horizontal slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-red' ).length, 4, 'found a horizontal slide with four paragraphs with class fragment.grow' ); strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-red' ).length, 4, 'found a horizontal slide with four paragraphs with class fragment.grow' );
}); });
test( 'Attributes on horizontal slides list items', function() { test( 'Attributes on element list items in horizontal slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section li.fragment.highlight-green' ).length, 5, 'found a horizontal slide with five list items with class fragment.roll-in' ); strictEqual( document.querySelectorAll( '.reveal .slides section li.fragment.highlight-green' ).length, 5, 'found a horizontal slide with five list items with class fragment.roll-in' );
}); });
test( 'Attributes on horizontal slides list items', function() { test( 'Attributes on element list items in horizontal slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section img.reveal.stretch' ).length, 1, 'found a horizontal slide with stretched image, class img.reveal.stretch' ); strictEqual( document.querySelectorAll( '.reveal .slides section img.reveal.stretch' ).length, 1, 'found a horizontal slide with stretched image, class img.reveal.stretch' );
}); });
test( 'Attributes on elements in vertical slides with default element attribute separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section h2.fragment.highlight-red' ).length, 2, 'found two h2 titles with fragment highlight-red in vertical slides with default element attribute separator' );
});
test( 'Attributes on elements in single slides with default element attribute separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-blue' ).length, 3, 'found three elements with fragment highlight-blue in single slide with default element attribute separator' );
});
} ); } );
Reveal.initialize(); Reveal.initialize();

View File

@@ -13,7 +13,7 @@
<body style="overflow: auto;"> <body style="overflow: auto;">
<div id="qunit"></div> <div id="qunit"></div>
<div id="qunit-fixture"></div> <div id="qunit-fixture"></div>
<div class="reveal" style="display: none;"> <div class="reveal" style="display: none;">
@@ -25,7 +25,7 @@
<section data-markdown data-separator="^\n\n\n" <section data-markdown data-separator="^\n\n\n"
data-vertical="^\n\n" data-vertical="^\n\n"
data-notes="^Note:" data-notes="^Note:"
data-attributes="^\s*?--\s(.*?)$" data-attributes="--\s(.*?)$"
data-charset="utf-8"> data-charset="utf-8">
<script type="text/template"> <script type="text/template">
# Test attributes in Markdown # Test attributes in Markdown
@@ -34,11 +34,11 @@
## Slide 2 ## Slide 2
-- id="slide2" data-transition="zoom" data-background="#A0C66B" <!-- -- id="slide2" data-transition="zoom" data-background="#A0C66B" -->
## Slide 2.1 ## Slide 2.1
-- data-background="#ff0000" data-transition="fade" <!-- -- data-background="#ff0000" data-transition="fade" -->
## Slide 2.2 ## Slide 2.2
@@ -47,7 +47,7 @@
## Slide 3 ## Slide 3
-- data-transition="zoom" data-background="#C6916B" <!-- -- data-transition="zoom" data-background="#C6916B" -->
@@ -66,11 +66,11 @@
## Slide 2 Def ## Slide 2 Def
<!-- slide-attributes: id="slide2def" data-transition="concave" data-background="#A7C66B" --> <!-- .slide: id="slide2def" data-transition="concave" data-background="#A7C66B" -->
## Slide 2.1 Def ## Slide 2.1 Def
<!-- slide-attributes: data-background="#f70000" data-transition="page" --> <!-- .slide: data-background="#f70000" data-transition="page" -->
## Slide 2.2 Def ## Slide 2.2 Def
@@ -79,7 +79,7 @@
## Slide 3 Def ## Slide 3 Def
<!-- slide-attributes: data-transition="concave" data-background="#C7916B" --> <!-- .slide: data-transition="concave" data-background="#C7916B" -->
@@ -87,30 +87,30 @@
</script> </script>
</section> </section>
<section data-markdown> <section data-markdown>
<script type="text/template"> <script type="text/template">
<!-- slide-attributes: data-background="#ff0000" --> <!-- .slide: data-background="#ff0000" -->
## Hello world ## Hello world
</script> </script>
</section> </section>
<section data-markdown> <section data-markdown>
<script type="text/template"> <script type="text/template">
## Hello world ## Hello world
<!-- slide-attributes: data-background="#ff0000" --> <!-- .slide: data-background="#ff0000" -->
</script> </script>
</section> </section>
<section data-markdown> <section data-markdown>
<script type="text/template"> <script type="text/template">
## Hello world ## Hello world
Test Test
<!-- slide-attributes: data-background="#ff0000" --> <!-- .slide: data-background="#ff0000" -->
More Test More Test
</script> </script>
</section> </section>
</div> </div>
@@ -122,7 +122,7 @@
<script src="../plugin/markdown/markdown.js"></script> <script src="../plugin/markdown/markdown.js"></script>
<script src="qunit-1.12.0.js"></script> <script src="qunit-1.12.0.js"></script>
<script src="test-markdown-attributes.js"></script> <script src="test-markdown-slide-attributes.js"></script>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,47 @@
Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' );
test( 'Vertical separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 6, 'found six vertical slides' );
});
test( 'Id on slide', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section#slide2' ).length, 1, 'found one slide with id slide2' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section a[href="#/slide2"]' ).length, 1, 'found one slide with a link to slide2' );
});
test( 'data-background attributes', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A0C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#ff0000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C6916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
});
test( 'data-transition attributes', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="zoom"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="fade"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="zoom"]' ).length, 1, 'found one slide with data-transition="zoom"' );
});
test( 'data-background attributes with default separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A7C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#f70000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C7916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
});
test( 'data-transition attributes with default separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="concave"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="page"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="concave"]' ).length, 1, 'found one slide with data-transition="zoom"' );
});
test( 'data-transition attributes with inline content', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#ff0000"]' ).length, 3, 'found three horizontal slides with data-background="#ff0000"' );
});
} );
Reveal.initialize();

View File

@@ -11,6 +11,22 @@
Reveal.addEventListener( 'ready', function() { Reveal.addEventListener( 'ready', function() {
// ---------------------------------------------------------------
// DOM TESTS
QUnit.module( 'DOM' );
test( 'Initial slides classes', function() {
var horizontalSlides = document.querySelectorAll( '.reveal .slides>section' )
strictEqual( document.querySelectorAll( '.reveal .slides section.past' ).length, 0, 'no .past slides' );
strictEqual( document.querySelectorAll( '.reveal .slides section.present' ).length, 1, 'one .present slide' );
strictEqual( document.querySelectorAll( '.reveal .slides>section.future' ).length, horizontalSlides.length - 1, 'remaining horizontal slides are .future' );
strictEqual( document.querySelectorAll( '.reveal .slides section.stack' ).length, 2, 'two .stacks' );
ok( document.querySelectorAll( '.reveal .slides section.stack' )[0].querySelectorAll( '.future' ).length > 0, 'vertical slides are given .future' );
});
// --------------------------------------------------------------- // ---------------------------------------------------------------
// API TESTS // API TESTS