Merge branch 'hakimel:master' into main
This commit is contained in:
@@ -36,7 +36,6 @@ html.print-pdf {
|
|||||||
|
|
||||||
.reveal pre code {
|
.reveal pre code {
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
font-family: Courier, 'Courier New', monospace !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.reveal {
|
.reveal {
|
||||||
|
|||||||
@@ -86,47 +86,21 @@ $codeFont: "Fira Code", $systemFontsMono;
|
|||||||
--r-list-bullet-color: #{$listBulletColor};
|
--r-list-bullet-color: #{$listBulletColor};
|
||||||
}
|
}
|
||||||
|
|
||||||
.reveal strong, .reveal b {
|
.reveal {
|
||||||
color: var(--r-bold-color);
|
strong, b {
|
||||||
|
color: var(--r-bold-color);
|
||||||
|
}
|
||||||
|
em, i, blockquote {
|
||||||
|
color: var(--r-italic-color);
|
||||||
|
}
|
||||||
|
code {
|
||||||
|
color: var(--r-inline-code-color);
|
||||||
|
}
|
||||||
|
// Dracula colored list bullets and numbers
|
||||||
|
ul, ol {
|
||||||
|
li::marker {
|
||||||
|
color: var(--r-list-bullet-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.reveal em, .reveal i, .reveal blockquote {
|
|
||||||
color: var(--r-italic-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal code {
|
|
||||||
color: var(--r-inline-code-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dracula colored list bullets and numbers
|
|
||||||
.reveal ul {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal ul li::before {
|
|
||||||
content: "•";
|
|
||||||
color: var(--r-list-bullet-color);
|
|
||||||
display: inline-block;
|
|
||||||
width: 1em;
|
|
||||||
margin-left: -1em
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal ol {
|
|
||||||
list-style: none;
|
|
||||||
counter-reset: li;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal ol li::before {
|
|
||||||
content: counter(li) ".";
|
|
||||||
color: var(--r-list-bullet-color);
|
|
||||||
display: inline-block;
|
|
||||||
width: 2em;
|
|
||||||
|
|
||||||
margin-left: -2.5em;
|
|
||||||
margin-right: 0.5em;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal ol li {
|
|
||||||
counter-increment: li
|
|
||||||
}
|
|
||||||
|
|||||||
22
demo.html
22
demo.html
@@ -249,17 +249,17 @@
|
|||||||
<p>
|
<p>
|
||||||
reveal.js comes with a few themes built in: <br>
|
reveal.js comes with a few themes built in: <br>
|
||||||
<!-- Hacks to swap themes after the page has loaded. Not flexible and only intended for the reveal.js demo deck. -->
|
<!-- Hacks to swap themes after the page has loaded. Not flexible and only intended for the reveal.js demo deck. -->
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/black.css'); return false;">Black (default)</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/black.css'); return false;">Black (default)</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/white.css'); return false;">White</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/white.css'); return false;">White</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/league.css'); return false;">League</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/league.css'); return false;">League</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/sky.css'); return false;">Sky</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/sky.css'); return false;">Sky</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/beige.css'); return false;">Beige</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/beige.css'); return false;">Beige</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/simple.css'); return false;">Simple</a> <br>
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/simple.css'); return false;">Simple</a> <br>
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/serif.css'); return false;">Serif</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/serif.css'); return false;">Serif</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/blood.css'); return false;">Blood</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/blood.css'); return false;">Blood</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/night.css'); return false;">Night</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/night.css'); return false;">Night</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/moon.css'); return false;">Moon</a> -
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/moon.css'); return false;">Moon</a> -
|
||||||
<a href="#" onclick="document.getElementById('theme').setAttribute('href','dist/theme/solarized.css'); return false;">Solarized</a>
|
<a href="#/themes" onclick="document.getElementById('theme').setAttribute('href','dist/theme/solarized.css'); return false;">Solarized</a>
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
2
dist/reveal.css
vendored
2
dist/reveal.css
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.esm.js
vendored
2
dist/reveal.esm.js
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.esm.js.map
vendored
2
dist/reveal.esm.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.js
vendored
2
dist/reveal.js
vendored
File diff suppressed because one or more lines are too long
2
dist/reveal.js.map
vendored
2
dist/reveal.js.map
vendored
File diff suppressed because one or more lines are too long
33
dist/theme/dracula.css
vendored
33
dist/theme/dracula.css
vendored
@@ -1,4 +1,3 @@
|
|||||||
@charset "UTF-8";
|
|
||||||
/**
|
/**
|
||||||
* Dracula Dark theme for reveal.js.
|
* Dracula Dark theme for reveal.js.
|
||||||
* Based on https://draculatheme.com
|
* Based on https://draculatheme.com
|
||||||
@@ -373,42 +372,12 @@ section.has-light-background, section.has-light-background h1, section.has-light
|
|||||||
.reveal strong, .reveal b {
|
.reveal strong, .reveal b {
|
||||||
color: var(--r-bold-color);
|
color: var(--r-bold-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.reveal em, .reveal i, .reveal blockquote {
|
.reveal em, .reveal i, .reveal blockquote {
|
||||||
color: var(--r-italic-color);
|
color: var(--r-italic-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.reveal code {
|
.reveal code {
|
||||||
color: var(--r-inline-code-color);
|
color: var(--r-inline-code-color);
|
||||||
}
|
}
|
||||||
|
.reveal ul li::marker, .reveal ol li::marker {
|
||||||
.reveal ul {
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal ul li::before {
|
|
||||||
content: "•";
|
|
||||||
color: var(--r-list-bullet-color);
|
color: var(--r-list-bullet-color);
|
||||||
display: inline-block;
|
|
||||||
width: 1em;
|
|
||||||
margin-left: -1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal ol {
|
|
||||||
list-style: none;
|
|
||||||
counter-reset: li;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal ol li::before {
|
|
||||||
content: counter(li) ".";
|
|
||||||
color: var(--r-list-bullet-color);
|
|
||||||
display: inline-block;
|
|
||||||
width: 2em;
|
|
||||||
margin-left: -2.5em;
|
|
||||||
margin-right: 0.5em;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reveal ol li {
|
|
||||||
counter-increment: li;
|
|
||||||
}
|
}
|
||||||
16
gulpfile.js
16
gulpfile.js
@@ -164,11 +164,10 @@ function compileSass() {
|
|||||||
|
|
||||||
sass.render({
|
sass.render({
|
||||||
data: transformedFile.contents.toString(),
|
data: transformedFile.contents.toString(),
|
||||||
includePaths: ['css/', 'css/theme/template']
|
file: transformedFile.path,
|
||||||
}, ( err, result ) => {
|
}, ( err, result ) => {
|
||||||
if( err ) {
|
if( err ) {
|
||||||
console.log( vinylFile.path );
|
callback(err);
|
||||||
console.log( err.formatted );
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
transformedFile.extname = '.css';
|
transformedFile.extname = '.css';
|
||||||
@@ -286,7 +285,7 @@ gulp.task('package', gulp.series(() =>
|
|||||||
|
|
||||||
))
|
))
|
||||||
|
|
||||||
gulp.task('reload', () => gulp.src(['**/*.html', '**/*.md'])
|
gulp.task('reload', () => gulp.src(['index.html'])
|
||||||
.pipe(connect.reload()));
|
.pipe(connect.reload()));
|
||||||
|
|
||||||
gulp.task('serve', () => {
|
gulp.task('serve', () => {
|
||||||
@@ -298,14 +297,19 @@ gulp.task('serve', () => {
|
|||||||
livereload: true
|
livereload: true
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.watch(['**/*.html', '**/*.md'], gulp.series('reload'))
|
const slidesRoot = root.endsWith('/') ? root : root + '/'
|
||||||
|
gulp.watch([
|
||||||
|
slidesRoot + '**/*.html',
|
||||||
|
slidesRoot + '**/*.md',
|
||||||
|
`!${slidesRoot}**/node_modules/**`, // ignore node_modules
|
||||||
|
], gulp.series('reload'))
|
||||||
|
|
||||||
gulp.watch(['js/**'], gulp.series('js', 'reload', 'eslint'))
|
gulp.watch(['js/**'], gulp.series('js', 'reload', 'eslint'))
|
||||||
|
|
||||||
gulp.watch(['plugin/**/plugin.js', 'plugin/**/*.html'], gulp.series('plugins', 'reload'))
|
gulp.watch(['plugin/**/plugin.js', 'plugin/**/*.html'], gulp.series('plugins', 'reload'))
|
||||||
|
|
||||||
gulp.watch([
|
gulp.watch([
|
||||||
'css/theme/source/*.{sass,scss}',
|
'css/theme/source/**/*.{sass,scss}',
|
||||||
'css/theme/template/*.{sass,scss}',
|
'css/theme/template/*.{sass,scss}',
|
||||||
], gulp.series('css-themes', 'reload'))
|
], gulp.series('css-themes', 'reload'))
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export default class Location {
|
|||||||
// If the first bit is not fully numeric and there is a name we
|
// If the first bit is not fully numeric and there is a name we
|
||||||
// can assume that this is a named link
|
// can assume that this is a named link
|
||||||
if( !/^[0-9]*$/.test( bits[0] ) && name.length ) {
|
if( !/^[0-9]*$/.test( bits[0] ) && name.length ) {
|
||||||
let element;
|
let slide;
|
||||||
|
|
||||||
let f;
|
let f;
|
||||||
|
|
||||||
@@ -62,12 +62,14 @@ export default class Location {
|
|||||||
|
|
||||||
// Ensure the named link is a valid HTML ID attribute
|
// Ensure the named link is a valid HTML ID attribute
|
||||||
try {
|
try {
|
||||||
element = document.getElementById( decodeURIComponent( name ) );
|
slide = document
|
||||||
|
.getElementById( decodeURIComponent( name ) )
|
||||||
|
.closest('.slides>section, .slides>section>section');
|
||||||
}
|
}
|
||||||
catch ( error ) { }
|
catch ( error ) { }
|
||||||
|
|
||||||
if( element ) {
|
if( slide ) {
|
||||||
return { ...this.Reveal.getIndices( element ), f };
|
return { ...this.Reveal.getIndices( slide ), f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -2203,7 +2203,7 @@ export default function( revealElement, options ) {
|
|||||||
|
|
||||||
if( currentSlide && config.autoSlide !== false ) {
|
if( currentSlide && config.autoSlide !== false ) {
|
||||||
|
|
||||||
let fragment = currentSlide.querySelector( '.current-fragment' );
|
let fragment = currentSlide.querySelector( '.current-fragment[data-autoslide]' );
|
||||||
|
|
||||||
let fragmentAutoSlide = fragment ? fragment.getAttribute( 'data-autoslide' ) : null;
|
let fragmentAutoSlide = fragment ? fragment.getAttribute( 'data-autoslide' ) : null;
|
||||||
let parentAutoSlide = currentSlide.parentNode ? currentSlide.parentNode.getAttribute( 'data-autoslide' ) : null;
|
let parentAutoSlide = currentSlide.parentNode ? currentSlide.parentNode.getAttribute( 'data-autoslide' ) : null;
|
||||||
@@ -2705,6 +2705,10 @@ export default function( revealElement, options ) {
|
|||||||
loadSlide: slideContent.load.bind( slideContent ),
|
loadSlide: slideContent.load.bind( slideContent ),
|
||||||
unloadSlide: slideContent.unload.bind( slideContent ),
|
unloadSlide: slideContent.unload.bind( slideContent ),
|
||||||
|
|
||||||
|
// Media playback
|
||||||
|
startEmbeddedContent: () => slideContent.startEmbeddedContent( currentSlide ),
|
||||||
|
stopEmbeddedContent: () => slideContent.stopEmbeddedContent( currentSlide, { unloadIframes: false } ),
|
||||||
|
|
||||||
// Preview management
|
// Preview management
|
||||||
showPreview,
|
showPreview,
|
||||||
hidePreview: closeOverlay,
|
hidePreview: closeOverlay,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -7,7 +7,8 @@
|
|||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
|
|
||||||
const DEFAULT_SLIDE_SEPARATOR = '\r?\n---\r?\n',
|
const DEFAULT_SLIDE_SEPARATOR = '\r?\n---\r?\n',
|
||||||
DEFAULT_NOTES_SEPARATOR = 'notes?:',
|
DEFAULT_VERTICAL_SEPARATOR = null,
|
||||||
|
DEFAULT_NOTES_SEPARATOR = '^\s*notes?:',
|
||||||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
|
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
|
||||||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';
|
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';
|
||||||
|
|
||||||
@@ -37,15 +38,15 @@ const Plugin = () => {
|
|||||||
function getMarkdownFromSlide( section ) {
|
function getMarkdownFromSlide( section ) {
|
||||||
|
|
||||||
// look for a <script> or <textarea data-template> wrapper
|
// look for a <script> or <textarea data-template> wrapper
|
||||||
var template = section.querySelector( '[data-template]' ) || section.querySelector( 'script' );
|
const template = section.querySelector( '[data-template]' ) || section.querySelector( 'script' );
|
||||||
|
|
||||||
// strip leading whitespace so it isn't evaluated as code
|
// strip leading whitespace so it isn't evaluated as code
|
||||||
var text = ( template || section ).textContent;
|
let text = ( template || section ).textContent;
|
||||||
|
|
||||||
// restore script end tags
|
// restore script end tags
|
||||||
text = text.replace( new RegExp( SCRIPT_END_PLACEHOLDER, 'g' ), '</script>' );
|
text = text.replace( new RegExp( SCRIPT_END_PLACEHOLDER, 'g' ), '</script>' );
|
||||||
|
|
||||||
var leadingWs = text.match( /^\n?(\s*)/ )[1].length,
|
const leadingWs = text.match( /^\n?(\s*)/ )[1].length,
|
||||||
leadingTabs = text.match( /^\n?(\t*)/ )[1].length;
|
leadingTabs = text.match( /^\n?(\t*)/ )[1].length;
|
||||||
|
|
||||||
if( leadingTabs > 0 ) {
|
if( leadingTabs > 0 ) {
|
||||||
@@ -67,11 +68,11 @@ const Plugin = () => {
|
|||||||
*/
|
*/
|
||||||
function getForwardedAttributes( section ) {
|
function getForwardedAttributes( section ) {
|
||||||
|
|
||||||
var attributes = section.attributes;
|
const attributes = section.attributes;
|
||||||
var result = [];
|
const result = [];
|
||||||
|
|
||||||
for( var i = 0, len = attributes.length; i < len; i++ ) {
|
for( let i = 0, len = attributes.length; i < len; i++ ) {
|
||||||
var name = attributes[i].name,
|
const name = attributes[i].name,
|
||||||
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
|
||||||
@@ -94,10 +95,12 @@ const Plugin = () => {
|
|||||||
* values for what's not defined.
|
* values for what's not defined.
|
||||||
*/
|
*/
|
||||||
function getSlidifyOptions( options ) {
|
function getSlidifyOptions( options ) {
|
||||||
|
const markdownConfig = deck.getConfig().markdown;
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
|
options.separator = options.separator || markdownConfig?.separator || DEFAULT_SLIDE_SEPARATOR;
|
||||||
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
|
options.verticalSeparator = options.verticalSeparator || markdownConfig?.verticalSeparator || DEFAULT_VERTICAL_SEPARATOR;
|
||||||
|
options.notesSeparator = options.notesSeparator || markdownConfig?.notesSeparator || DEFAULT_NOTES_SEPARATOR;
|
||||||
options.attributes = options.attributes || '';
|
options.attributes = options.attributes || '';
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
@@ -111,7 +114,7 @@ const Plugin = () => {
|
|||||||
|
|
||||||
options = getSlidifyOptions( options );
|
options = getSlidifyOptions( options );
|
||||||
|
|
||||||
var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) );
|
const notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) );
|
||||||
|
|
||||||
if( notesMatch.length === 2 ) {
|
if( notesMatch.length === 2 ) {
|
||||||
content = notesMatch[0] + '<aside class="notes">' + marked(notesMatch[1].trim()) + '</aside>';
|
content = notesMatch[0] + '<aside class="notes">' + marked(notesMatch[1].trim()) + '</aside>';
|
||||||
@@ -133,10 +136,10 @@ const Plugin = () => {
|
|||||||
|
|
||||||
options = getSlidifyOptions( options );
|
options = getSlidifyOptions( options );
|
||||||
|
|
||||||
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
|
const separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
|
||||||
horizontalSeparatorRegex = new RegExp( options.separator );
|
horizontalSeparatorRegex = new RegExp( options.separator );
|
||||||
|
|
||||||
var matches,
|
let matches,
|
||||||
lastIndex = 0,
|
lastIndex = 0,
|
||||||
isHorizontal,
|
isHorizontal,
|
||||||
wasHorizontal = true,
|
wasHorizontal = true,
|
||||||
@@ -145,7 +148,7 @@ const Plugin = () => {
|
|||||||
|
|
||||||
// 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 ) ) {
|
||||||
var notes = null;
|
const notes = null;
|
||||||
|
|
||||||
// determine direction (horizontal by default)
|
// determine direction (horizontal by default)
|
||||||
isHorizontal = horizontalSeparatorRegex.test( matches[0] );
|
isHorizontal = horizontalSeparatorRegex.test( matches[0] );
|
||||||
@@ -174,10 +177,10 @@ const Plugin = () => {
|
|||||||
// add the remaining slide
|
// add the remaining slide
|
||||||
( wasHorizontal ? sectionStack : sectionStack[sectionStack.length-1] ).push( markdown.substring( lastIndex ) );
|
( wasHorizontal ? sectionStack : sectionStack[sectionStack.length-1] ).push( markdown.substring( lastIndex ) );
|
||||||
|
|
||||||
var markdownSections = '';
|
let markdownSections = '';
|
||||||
|
|
||||||
// flatten the hierarchical stack, and insert <section data-markdown> tags
|
// flatten the hierarchical stack, and insert <section data-markdown> tags
|
||||||
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
|
for( let i = 0, len = sectionStack.length; i < len; i++ ) {
|
||||||
// vertical
|
// vertical
|
||||||
if( sectionStack[i] instanceof Array ) {
|
if( sectionStack[i] instanceof Array ) {
|
||||||
markdownSections += '<section '+ options.attributes +'>';
|
markdownSections += '<section '+ options.attributes +'>';
|
||||||
@@ -206,7 +209,7 @@ const Plugin = () => {
|
|||||||
|
|
||||||
return new Promise( function( resolve ) {
|
return new Promise( function( resolve ) {
|
||||||
|
|
||||||
var externalPromises = [];
|
const externalPromises = [];
|
||||||
|
|
||||||
[].slice.call( scope.querySelectorAll( 'section[data-markdown]:not([data-markdown-parsed])') ).forEach( function( section, i ) {
|
[].slice.call( scope.querySelectorAll( 'section[data-markdown]:not([data-markdown-parsed])') ).forEach( function( section, i ) {
|
||||||
|
|
||||||
@@ -259,13 +262,13 @@ const Plugin = () => {
|
|||||||
|
|
||||||
return new Promise( function( resolve, reject ) {
|
return new Promise( function( resolve, reject ) {
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest(),
|
const xhr = new XMLHttpRequest(),
|
||||||
url = section.getAttribute( 'data-markdown' );
|
url = section.getAttribute( 'data-markdown' );
|
||||||
|
|
||||||
var datacharset = section.getAttribute( 'data-charset' );
|
const datacharset = section.getAttribute( 'data-charset' );
|
||||||
|
|
||||||
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
|
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
|
||||||
if( datacharset != null && datacharset != '' ) {
|
if( datacharset !== null && datacharset !== '' ) {
|
||||||
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
|
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,17 +313,17 @@ const Plugin = () => {
|
|||||||
*/
|
*/
|
||||||
function addAttributeInElement( node, elementTarget, separator ) {
|
function addAttributeInElement( node, elementTarget, separator ) {
|
||||||
|
|
||||||
var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
|
const markdownClassesInElementsRegex = new RegExp( separator, 'mg' );
|
||||||
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"]+?)\"|(data-[^\"= ]+?)(?=[\" ])", 'mg' );
|
const markdownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"]+?)\"|(data-[^\"= ]+?)(?=[\" ])", 'mg' );
|
||||||
var nodeValue = node.nodeValue;
|
let nodeValue = node.nodeValue;
|
||||||
var matches,
|
let matches,
|
||||||
matchesClass;
|
matchesClass;
|
||||||
if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
|
if( matches = markdownClassesInElementsRegex.exec( nodeValue ) ) {
|
||||||
|
|
||||||
var classes = matches[1];
|
const classes = matches[1];
|
||||||
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
|
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( markdownClassesInElementsRegex.lastIndex );
|
||||||
node.nodeValue = nodeValue;
|
node.nodeValue = nodeValue;
|
||||||
while( matchesClass = mardownClassRegex.exec( classes ) ) {
|
while( matchesClass = markdownClassRegex.exec( classes ) ) {
|
||||||
if( matchesClass[2] ) {
|
if( matchesClass[2] ) {
|
||||||
elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
|
elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
|
||||||
} else {
|
} else {
|
||||||
@@ -338,34 +341,34 @@ const Plugin = () => {
|
|||||||
*/
|
*/
|
||||||
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
|
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
|
||||||
|
|
||||||
if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
|
if ( element !== null && element.childNodes !== undefined && element.childNodes.length > 0 ) {
|
||||||
var previousParentElement = element;
|
let previousParentElement = element;
|
||||||
for( var i = 0; i < element.childNodes.length; i++ ) {
|
for( let i = 0; i < element.childNodes.length; i++ ) {
|
||||||
var childElement = element.childNodes[i];
|
const childElement = element.childNodes[i];
|
||||||
if ( i > 0 ) {
|
if ( i > 0 ) {
|
||||||
var j = i - 1;
|
let j = i - 1;
|
||||||
while ( j >= 0 ) {
|
while ( j >= 0 ) {
|
||||||
var aPreviousChildElement = element.childNodes[j];
|
const aPreviousChildElement = element.childNodes[j];
|
||||||
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) {
|
if ( typeof aPreviousChildElement.setAttribute === 'function' && aPreviousChildElement.tagName !== "BR" ) {
|
||||||
previousParentElement = aPreviousChildElement;
|
previousParentElement = aPreviousChildElement;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
j = j - 1;
|
j = j - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var parentSection = section;
|
let parentSection = section;
|
||||||
if( childElement.nodeName == "section" ) {
|
if( childElement.nodeName === "section" ) {
|
||||||
parentSection = childElement ;
|
parentSection = childElement ;
|
||||||
previousParentElement = childElement ;
|
previousParentElement = childElement ;
|
||||||
}
|
}
|
||||||
if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) {
|
if ( typeof childElement.setAttribute === 'function' || childElement.nodeType === Node.COMMENT_NODE ) {
|
||||||
addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
|
addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( element.nodeType == Node.COMMENT_NODE ) {
|
if ( element.nodeType === Node.COMMENT_NODE ) {
|
||||||
if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) {
|
if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) === false ) {
|
||||||
addAttributeInElement( element, section, separatorSectionAttributes );
|
addAttributeInElement( element, section, separatorSectionAttributes );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -377,14 +380,14 @@ const Plugin = () => {
|
|||||||
*/
|
*/
|
||||||
function convertSlides() {
|
function convertSlides() {
|
||||||
|
|
||||||
var sections = deck.getRevealElement().querySelectorAll( '[data-markdown]:not([data-markdown-parsed])');
|
const sections = deck.getRevealElement().querySelectorAll( '[data-markdown]:not([data-markdown-parsed])');
|
||||||
|
|
||||||
[].slice.call( sections ).forEach( function( section ) {
|
[].slice.call( sections ).forEach( function( section ) {
|
||||||
|
|
||||||
section.setAttribute( 'data-markdown-parsed', true )
|
section.setAttribute( 'data-markdown-parsed', true )
|
||||||
|
|
||||||
var notes = section.querySelector( 'aside.notes' );
|
const notes = section.querySelector( 'aside.notes' );
|
||||||
var markdown = getMarkdownFromSlide( section );
|
const markdown = getMarkdownFromSlide( section );
|
||||||
|
|
||||||
section.innerHTML = marked( markdown );
|
section.innerHTML = marked( markdown );
|
||||||
addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) ||
|
addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) ||
|
||||||
@@ -458,7 +461,7 @@ const Plugin = () => {
|
|||||||
code = escapeForHTML( code );
|
code = escapeForHTML( code );
|
||||||
|
|
||||||
// return `<pre><code ${lineNumbers} class="${language}">${code}</code></pre>`;
|
// return `<pre><code ${lineNumbers} class="${language}">${code}</code></pre>`;
|
||||||
|
|
||||||
return `<pre><code ${lineNumbers} ${lineNumberOffset} class="${language}">${code}</code></pre>`;
|
return `<pre><code ${lineNumbers} ${lineNumberOffset} class="${language}">${code}</code></pre>`;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user