From be81ee22ecc1af1db6d24a44109594d30461d8c9 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 14 Aug 2016 15:02:05 +0800 Subject: [PATCH] Update slide mode, now respect all meta settings and update default styles --- lib/response.js | 2 +- public/css/slide.css | 13 ++++++++++++- public/js/slide.js | 24 +++++++++++++++++++++++- public/views/slide.ejs | 2 +- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/response.js b/lib/response.js index 9df2ee9f..5c5798c8 100644 --- a/lib/response.js +++ b/lib/response.js @@ -555,7 +555,7 @@ function showPublishSlide(req, res, next) { title: title, description: meta.description, slides: slides, - slideOptions: JSON.stringify(meta.slideOptions || {}), + meta: JSON.stringify(obj.meta || {}), GA: meta.GA, useCDN: config.usecdn }; diff --git a/public/css/slide.css b/public/css/slide.css index 195981b3..40bb6ea1 100644 --- a/public/css/slide.css +++ b/public/css/slide.css @@ -252,4 +252,15 @@ pre.mermaid > svg { .reveal .slides > section, .reveal .slides > section > section { transform-style: flat; -} \ No newline at end of file +} + +.reveal.rtl .slides, +.reveal.rtl .slides h1, +.reveal.rtl .slides h2, +.reveal.rtl .slides h3, +.reveal.rtl .slides h4, +.reveal.rtl .slides h5, +.reveal.rtl .slides h6 { + direction: rtl; + font-family: inherit; +} diff --git a/public/js/slide.js b/public/js/slide.js index 996610fb..fe3cb1e8 100644 --- a/public/js/slide.js +++ b/public/js/slide.js @@ -45,7 +45,29 @@ var defaultOptions = { }; // options from yaml meta -var options = JSON.parse($("#options").text()); +var meta = JSON.parse($("#meta").text()); +var options = meta.slideOptions || {}; + +var view = $('.reveal'); + +//text language +if (meta.lang && typeof meta.lang == "string") { + view.attr('lang', meta.lang); +} else { + view.removeAttr('lang'); +} +//text direction +if (meta.dir && typeof meta.dir == "string" && meta.dir == "rtl") { + options.rtl = true; +} else { + options.rtl = false; +} +//breaks +if (typeof meta.breaks === 'boolean' && !meta.breaks) { + md.options.breaks = false; +} else { + md.options.breaks = true; +} // options from URL query string var queryOptions = Reveal.getQueryHash() || {}; diff --git a/public/views/slide.ejs b/public/views/slide.ejs index 5817a200..8a8fbae0 100644 --- a/public/views/slide.ejs +++ b/public/views/slide.ejs @@ -50,7 +50,7 @@
<%- slides %>
- +