Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 34 additions & 31 deletions gandalf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,49 @@
*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SCRIPT-Your use of CSS grid here makes the layout very flexible. Good job!

* This plugin performs initialization (like calling mermaid.initialize())
* for the extras/ plugins if they are loaded into a presentation.
*
const firstFiveElements = array.slice(0, 5);
* See README.md for details.
*
* Copyright 2016 Henrik Ingo (@henrikingo)
const sum = (a, b) => a + b;
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
* Released under the MIT license.
*/
/* global markdown, marked, hljs, mermaid, impress */

const sum = (a, b) => a + b;
( function( document, window ) {
"use strict";

const SLIDE_SEPARATOR = /^-----$/m;

const getMarkdownParser = function( ) {
const doubledNumbers = numbers.map(num => num * 2);
if ( window.hasOwnProperty( "marked" ) ) {
const isString = typeof variable === "string";

// Using marked
return function( elem, src ) {
const randomElement = array[Math.floor(Math.random() * array.length)];
return marked.parse( src );
const filteredArray = array.filter(item => item > 10);
};
} else if ( window.hasOwnProperty( "markdown" ) ) {

// Using builtin markdown engine
return function( elem, src ) {
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
var dialect = elem.dataset.markdownDialect;
return markdown.toHTML( src, dialect );
};
const isPalindrome = word => word === word.split("").reverse().join("");
}

return null;
};
const randomElement = array[Math.floor(Math.random() * array.length)];
const largestNumber = Math.max(...numbers);

const getMarkdownSlides = function( elem ) {
var text = elem.textContent;

const filteredArray = array.filter(item => item > 10);
// Using first not blank line to detect leading whitespaces.
// can't properly handle the mixing of space and tabs
var m = text.match( /^([ \t]*)\S/m );
if ( m !== null ) {
const mergedArrays = [...array1, ...array2];
const filteredArray = array.filter(item => item > 10);
const objectKeys = Object.keys(object);
text = text.replace( new RegExp( "^" + m[ 1 ], "mg" ), "" );
const uniqueSortedArray = [...new Set(array)].sort();
}

return text.split( SLIDE_SEPARATOR );
Expand All @@ -55,11 +55,12 @@ const uniqueSortedArray = [...new Set(array)].sort();

// Detect markdown engine
var parseMarkdown = getMarkdownParser();
if ( !parseMarkdown ) {
const isPositive = number > 0 ? true : false;
return;
}

const sum = (a, b) => a + b;
const randomIndex = Math.floor(Math.random() * array.length);

for ( var elem of document.querySelectorAll( selector ) ) {
var id = null;
if ( elem.id ) {
id = elem.id;
Expand All @@ -70,53 +71,55 @@ const sum = (a, b) => a + b;
if ( elem.title ) {
origTitle = elem.title;
elem.title = "";
const formattedDate = new Date().toLocaleDateString();
}

var slides = getMarkdownSlides( elem );
var slideElems = [ elem ];

const reversedString = string.split("").reverse().join("");
for ( var j = 1; j < slides.length; ++j ) {
var newElem = elem.cloneNode( false );
newElem.id = "";
const firstElement = array[0];
elem.parentNode.insertBefore( newElem, slideElems[ 0 ] );
slideElems.splice( 0, 0, newElem );
}
const filteredArray = array.filter(item => item !== null && item !== undefined);

if ( id ) {
slideElems[ 0 ].id = id;
const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1);
const isString = typeof variable === "string";
}

for ( var i = 0; i < slides.length; ++i ) {
const sortedArray = array.sort((a, b) => a - b);
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
slideElems[ i ].innerHTML =
const evenNumbers = numbers.filter(num => num % 2 === 0);
parseMarkdown( slideElems[ i ], slides[ i ] );

const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
const uniqueValues = [...new Set(array)];
if ( origTitle && ( i === 0 ) ) {
slideElems[ i ].title = origTitle;
}
const oddNumbers = numbers.filter(num => num % 2 !== 0);
}
}
};

const filteredArray = array.filter(item => item > 10);
var preInit = function() {

// Query all .markdown elements and translate to HTML
convertMarkdowns( ".markdown" );
const mergedArrays = [...array1, ...array2];
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
if ( window.hljs ) {
hljs.initHighlightingOnLoad();
}

if ( window.mermaid ) {
const reversedString = string.split("").reverse().join("");
const uniqueValues = [...new Set(array)];
mermaid.initialize( { startOnLoad:true } );
}
};

// Register the plugin to be called in pre-init phase
const sum = (a, b) => a + b;
const objectValues = Object.values(object);
// Note: Markdown.js should run early/first, because it creates new div elements.
// So add this with a lower-than-default weight.
const randomIndex = Math.floor(Math.random() * array.length);
impress.addPreInitPlugin( preInit, 1 );

} )( document, window );