diff options
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | README.md | 18 | ||||
-rw-r--r-- | js/reveal.js | 3 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | plugin/highlight/highlight.js | 49 |
5 files changed, 70 insertions, 6 deletions
@@ -1,4 +1,4 @@ -Copyright (C) 2016 Hakim El Hattab, http://hakim.se +Copyright (C) 2016 Hakim El Hattab, http://hakim.se, and reveal.js contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -236,13 +236,13 @@ Reveal.initialize({ previewLinks: false, // Transition style - transition: 'default', // none/fade/slide/convex/concave/zoom + transition: 'slide', // none/fade/slide/convex/concave/zoom // Transition speed transitionSpeed: 'default', // default/fast/slow // Transition style for full page slide backgrounds - backgroundTransition: 'default', // none/fade/slide/convex/concave/zoom + backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom // Number of slides away from the current that are visible viewDistance: 3, @@ -301,6 +301,20 @@ Reveal.initialize({ }); ``` +If you wish to disable this behavior and do your own scaling (e.g. using media queries), try these settings: + +```javascript +Reveal.initialize({ + + ... + + width: "100%", + height: "100%", + margin: 0, + minScale: 1, + maxScale: 1 +}); +``` ### Dependencies diff --git a/js/reveal.js b/js/reveal.js index 861059c..28aa400 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -714,6 +714,9 @@ fragment.classList.add( 'visible' ); } ); + // Notify subscribers that the PDF layout is good to go + dispatchEvent( 'pdf-ready' ); + } /** diff --git a/package.json b/package.json index c96e4fd..f0dcedf 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "url": "git://github.com/hakimel/reveal.js.git" }, "engines": { - "node": "~4.1.1" + "node": "~6.9.1" }, "dependencies": { "express": "~4.14.0", @@ -39,7 +39,7 @@ "grunt-sass": "~1.2.0", "grunt-retire": "~0.3.10", "grunt-zip": "~0.17.1", - "node-sass": "~3.7.0" + "node-sass": "~3.13.0" }, "license": "MIT" } diff --git a/plugin/highlight/highlight.js b/plugin/highlight/highlight.js index 8be8c98..6aae081 100644 --- a/plugin/highlight/highlight.js +++ b/plugin/highlight/highlight.js @@ -1,5 +1,52 @@ // START CUSTOM REVEAL.JS INTEGRATION (function() { + // Function to perform a better "data-trim" on code snippets + // Will slice an indentation amount on each line of the snippet (amount based on the line having the lowest indentation length) + function betterTrim(snippetEl) { + // Helper functions + function trimLeft(val) { + // Adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill + return val.replace(/^[\s\uFEFF\xA0]+/g, ''); + } + function trimLineBreaks(input) { + var lines = input.split('\n'); + + // Trim line-breaks from the beginning + for (var i = 0; i < lines.length; i++) { + if (lines[i].trim() === '') { + lines.splice(i--, 1); + } else break; + } + + // Trim line-breaks from the end + for (var i = lines.length-1; i >= 0; i--) { + if (lines[i].trim() === '') { + lines.splice(i, 1); + } else break; + } + + return lines.join('\n'); + } + + // Main function for betterTrim() + return (function(snippetEl) { + var content = trimLineBreaks(snippetEl.innerHTML); + var lines = content.split('\n'); + // Calculate the minimum amount to remove on each line start of the snippet (can be 0) + var pad = lines.reduce(function(acc, line) { + if (line.length > 0 && trimLeft(line).length > 0 && acc > line.length - trimLeft(line).length) { + return line.length - trimLeft(line).length; + } + return acc; + }, Number.POSITIVE_INFINITY); + // Slice each line with this amount + return lines.map(function(line, index) { + return line.slice(pad); + }) + .join('\n'); + })(snippetEl); + } + if( typeof window.addEventListener === 'function' ) { var hljs_nodes = document.querySelectorAll( 'pre code' ); @@ -8,7 +55,7 @@ // trim whitespace if data-trim attribute is present if( element.hasAttribute( 'data-trim' ) && typeof element.innerHTML.trim === 'function' ) { - element.innerHTML = element.innerHTML.trim(); + element.innerHTML = betterTrim(element); } // Now escape html unless prevented by author |