diff --git a/bin/mdshow b/bin/mdshow index d9ba432142e10905a8650ba0a9a7965abe4be506..4ebe9f42b7a6a91ee921f513497f73c111dd26ec 100755 --- a/bin/mdshow +++ b/bin/mdshow @@ -16,6 +16,7 @@ PORT = 3000 VERSION := v0.1 # {{{1 help +.PHONY: help help: @echo "mdshow: the simple markdown to reveal.js converter" @echo "$(VERSION)" @@ -40,15 +41,18 @@ help: @echo " curl, pandoc, unzip, npm" # {{{1 version +.PHONY: version version: @echo "$(VERSION)" # {{{1 upgrade +.PHONY: upgrade upgrade: curl -L https://raw.githubusercontent.com/jceb/mdshow/master/mdshow -o $(realpath $(firstword $(MAKEFILE_LIST))) chmod a+x $(realpath $(firstword $(MAKEFILE_LIST))) # {{{1 setup +.PHONY: setup setup: programs \ sass \ $(MDSHOW_CONFIG)/defaults.css \ @@ -63,6 +67,7 @@ setup: programs \ $(MDSHOW_CONFIG)/reveal.js/mdshow-gulp.js \ $(MDSHOW_CONFIG)/scaffold.md +.PHONY: programs programs: @echo "Testing depedencies" @type curl || echo "curl is not installed, required in the setup process" @@ -85,9 +90,9 @@ $(MDSHOW_CONFIG)/defaults.yaml: curl -L https://raw.githubusercontent.com/jceb/mdshow/master/assets/defaults.yaml -o $@ $(MDSHOW_CONFIG)/reveal.js/dist/fontawesome: - curl -L https://use.fontawesome.com/releases/v5.15.1/fontawesome-free-5.15.1-web.zip -o $(dir $@)/fontawesome-free-web.zip + curl -L https://use.fontawesome.com/releases/v6.1.1/fontawesome-free-6.1.1-web.zip -o $(dir $@)/fontawesome-free-web.zip unzip $(dir $@)/fontawesome-free-web.zip -d $(dir $@) - mv $(dir $@)/fontawesome-free-5.15.1-web $@ + mv $(dir $@)/fontawesome-free-6.1.1-web $@ rm $(dir $@)/fontawesome-free-web.zip $(MDSHOW_CONFIG)/reveal.js: @@ -132,18 +137,22 @@ $(MDSHOW_CONFIG)/reveal.js/dist/plugin/highlight/styles/nord.css: rm -rf highlight.js-10.2.1 # {{{1 sass / theme builder +.PHONY: sass sass: $(MDSHOW_CONFIG)/reveal.js \ .sync-custom-themes \ .link-theme-assets \ .build-themes +.PHONY: .sync-custom-themes .sync-custom-themes: $(wildcard $(MDSHOW_CONFIG)/theme/*/source/*.scss) @[ -n "$^" ] && rsync -u $^ $(MDSHOW_CONFIG)/reveal.js/css/theme/source/ || true @[ -n "$^" ] && cd $(MDSHOW_CONFIG)/reveal.js && gulp css-themes || true +.PHONY: .build-themes .SECONDEXPANSION: .build-themes: $$(addprefix $(MDSHOW_CONFIG)/reveal.js/dist/theme/,$$(addsuffix .css,$$(basename $$(notdir $$(wildcard $(MDSHOW_CONFIG)/reveal.js/css/theme/source/*.scss))))) +.PHONY: .link-theme-assets .SECONDEXPANSION: .link-theme-assets: $$(addprefix $(MDSHOW_CONFIG)/reveal.js/dist/theme/,$$(basename $$(notdir $$(wildcard $(MDSHOW_CONFIG)/reveal.js/css/theme/source/*.scss)))) @@ -157,6 +166,7 @@ $(MDSHOW_CONFIG)/reveal.js/dist/theme/%: $(MDSHOW_CONFIG)/theme/%/assets @cp $@.css $< # {{{1 themes +.PHONY: themes themes: $(MDSHOW_CONFIG)/reveal.js/dist $(wildcard $(MDSHOW_CONFIG)/reveal.js/dist/theme/*.css) @ls -1 $(MDSHOW_CONFIG)/reveal.js/dist/theme/*.css | sed -ne 's/^.*\/\([^\/]*\).css$$/\1/p' @echo "Change theme by adding the option 'theme: <name>' between the two --- .. --- delimiters at the top of $(SLIDES)." @@ -167,6 +177,7 @@ $(MDSHOW_CONFIG)/scaffold.md: [ ! -e $@ ] && \ curl -L https://raw.githubusercontent.com/jceb/mdshow/master/examples/$(SLIDES) -o $@ +.PHONY: scaffold scaffold: $(MDSHOW_CONFIG)/scaffold.md @([ -e $(SLIDES) ] && [ -e assets ] && \ echo "'$(SLIDES)' and or 'assets' already exists, nothing to do here.") || \ @@ -181,6 +192,7 @@ scaffold: $(MDSHOW_CONFIG)/scaffold.md echo "- Run 'mdshow pdf' to store the slideshow in a PDF document") || true\ # {{{1 html +.PHONY: html html: $(basename $(SLIDES)).html $(basename $(SLIDES)).html: serving build @@ -189,9 +201,11 @@ $(basename $(SLIDES)).html: serving build monolith -o $@ http://localhost:$(PORT) # {{{1 build +.PHONY: build build: $(BUILD_DIR)/config.json sass $(MDSHOW_CONFIG)/reveal.js/dist/fontawesome $(BUILD_DIR)/index.html # {{{1 pdf +.PHONY: pdf pdf: $(basename $(SLIDES)).pdf $(basename $(SLIDES)).pdf: serving build @@ -206,9 +220,11 @@ $(MDSHOW_CONFIG)/reveal.js/mdshow-gulp.js: [ ! -e $@ ] && \ curl -L https://raw.githubusercontent.com/jceb/mdshow/master/assets/mdshow-gulp.js -o $@ +.PHONY: serve serve: build $(MDSHOW_CONFIG)/reveal.js/mdshow-gulp.js cd $(MDSHOW_CONFIG)/reveal.js && gulp -f mdshow-gulp.js --port=$(PORT) --slides="$(SLIDES)" --root="${PWD}/$(BUILD_DIR)" +.PHONY: serving serving: @curl -s -I -o /dev/null http://localhost:$(PORT) @@ -233,29 +249,31 @@ $(BUILD_DIR)/config.json: $(SLIDES) $(MDSHOW_CONFIG)/defaults.yaml $(MDSHOW_CON $(BUILD_DIR)/index.html: $(SLIDES) $(BUILD_DIR)/config.json $(BUILD_DIR)/reveal.js $(BUILD_DIR)/assets $(BUILD_DIR)/.mdshow $(BUILD_DIR)/reveal.js/defaults.css PANDOC_ARGS=; \ - theme="$$($(MDSHOW_CONFIG)/reveal.js/node_modules/node-jq/bin/jq -r '.theme' < $(BUILD_DIR)/config.json)"; \ - [ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/in-header.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-in-header=$(MDSHOW_CONFIG)/theme/$${theme}/include/in-header.html"; \ - [ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/before-body.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-before-body=$(MDSHOW_CONFIG)/theme/$${theme}/include/before-body.html"; \ - [ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/after-body.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-after-body=$(MDSHOW_CONFIG)/theme/$${theme}/include/after-body.html"; \ - pandoc \ - $(MDSHOW_CONFIG)/defaults.yaml \ - $(SLIDES) \ - --data-dir=$(MDSHOW_CONFIG)/pandoc \ - -f markdown+yaml_metadata_block \ - -t revealjs \ - --lua-filter fontawesome.lua \ - --wrap=preserve \ - --standalone \ - --no-highlight \ - --slide-level=2 \ - -V revealjs-url=reveal.js \ - -o $@ \ - $${PANDOC_ARGS} + theme="$$($(MDSHOW_CONFIG)/reveal.js/node_modules/node-jq/bin/jq -r '.theme' < $(BUILD_DIR)/config.json)"; \ + [ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/in-header.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-in-header=$(MDSHOW_CONFIG)/theme/$${theme}/include/in-header.html"; \ + [ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/before-body.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-before-body=$(MDSHOW_CONFIG)/theme/$${theme}/include/before-body.html"; \ + [ -e "$(MDSHOW_CONFIG)/theme/$${theme}/include/after-body.html" ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-after-body=$(MDSHOW_CONFIG)/theme/$${theme}/include/after-body.html"; \ + pandoc \ + $(MDSHOW_CONFIG)/defaults.yaml \ + $(SLIDES) \ + --data-dir=$(MDSHOW_CONFIG)/pandoc \ + -f markdown+yaml_metadata_block \ + -t revealjs \ + --lua-filter fontawesome.lua \ + --wrap=preserve \ + --standalone \ + --no-highlight \ + --slide-level=2 \ + -V revealjs-url=reveal.js \ + -o $@ \ + $${PANDOC_ARGS} # {{{1 cleanup +.PHONY: clean clean: rm -rf $(BUILD_DIR) +.PHONY: distclean distclean: [ -e $(MDSHOW_CONFIG)/defaults.yaml ] && mv $(MDSHOW_CONFIG)/defaults.yaml $(MDSHOW_CONFIG)/defaults.yaml.bak || true [ -e $(MDSHOW_CONFIG)/scaffold.md ] && mv $(MDSHOW_CONFIG)/scaffold.md $(MDSHOW_CONFIG)/scaffold.md.bak || true diff --git a/default.revealjs b/default.revealjs index ec3a6b711d82befd3d5d41809ae552a233f2677b..380ddf35b5c0ec72307cc771c8110835782ea15b 100644 --- a/default.revealjs +++ b/default.revealjs @@ -92,78 +92,76 @@ $body$ // https://github.com/hakimel/reveal.js#configuration Reveal.initialize({ // Display controls in the bottom right corner - controls: ('$controls$' === '' ? false : true), + controls: Boolean(JSON.parse('$controls$')), // Help the user learn the controls by providing hints, for example by // bouncing the down arrow when they first encounter a vertical slide - controlsTutorial: ('$controlsTutorial$' === '' ? false : true), + controlsTutorial: Boolean(JSON.parse('$controlsTutorial$')), // Display a presentation progress bar - progress: ('$progress$' === '' ? false : true), + progress: Boolean(JSON.parse('$progress$')), // Display the page number of the current slide - slideNumber: ('$slideNumber$' === '' ? false : '$slideNumber$' === 'true' ? true : '$slideNumber$'), + slideNumber: Boolean(JSON.parse('$slideNumber$')), // Use 1 based indexing for # links to match slide number (default is zero // based) - hashOneBasedIndex: ('$hashOneBasedIndex$' === '' ? false : true), + hashOneBasedIndex: Boolean(JSON.parse('$hashOneBasedIndex$')), // Add the current slide number to the URL hash so that reloading the // page/copying the URL will return you to the same slide - hash: ('$hash$' === '' ? false : true), + hash: Boolean(JSON.parse('$hash$')), // Flags if we should monitor the hash and change slides accordingly - respondToHashChanges: ('$respondToHashChanges$' === '' ? false : true), + respondToHashChanges: Boolean(JSON.parse('$respondToHashChanges$')), // Push each slide change to the browser history - history: ('$history$' === '' ? false : true), + history: Boolean(JSON.parse('$history$')), // Enable keyboard shortcuts for navigation - keyboard: ('$keyboard$' === '' ? false : true), + keyboard: Boolean(JSON.parse('$keyboard$')), // Disables the default reveal.js slide layout (scaling and centering) // so that you can use custom CSS layout - disableLayout: ('$disableLayout$' === '' ? false : true), + disableLayout: Boolean(JSON.parse('$disableLayout$')), // Enable the slide overview mode - overview: ('$overview$' === '' ? false : true), + overview: Boolean(JSON.parse('$overview$')), // Vertical centering of slides - center: ('$center$' === '' ? false : true), + center: Boolean(JSON.parse('$center$')), // Enables touch navigation on devices with touch input - touch: ('$touch$' === '' ? false : true), + touch: Boolean(JSON.parse('$touch$')), // Loop the presentation - loop: ('$loop$' === '' ? false : true), + loop: Boolean(JSON.parse('$loop$')), // Change the presentation direction to be RTL - rtl: ('$rtl$' === '' ? false : true), + rtl: Boolean(JSON.parse('$rtl$')), $if(navigationMode)$ // see https://github.com/hakimel/reveal.js/#navigation-mode navigationMode: '$navigationMode$', $endif$ // Randomizes the order of slides each time the presentation loads - shuffle: ('$shuffle$' === '' ? false : true), + shuffle: Boolean(JSON.parse('$shuffle$')), // Turns fragments on and off globally - fragments: ('$fragments$' === '' ? false : true), + fragments: Boolean(JSON.parse('$fragments$')), // Flags whether to include the current fragment in the URL // so that reloading brings you to the same fragment position - fragmentInURL: ('$fragmentInURL$' === '' ? false : true), + fragmentInURL: Boolean(JSON.parse('$fragmentInURL$')), // Flags if the presentation is running in an embedded mode, // i.e. contained within a limited portion of the screen - embedded: ('$embedded$' === '' ? false : true), + embedded: Boolean(JSON.parse('$embedded$')), // Flags if we should show a help overlay when the questionmark // key is pressed - help: ('$help$' === '' ? false : true), + help: Boolean(JSON.parse('$help$')), // Flags if it should be possible to pause the presentation (blackout) - pause: ('$pause$' === '' ? false : true), + pause: Boolean(JSON.parse('$pause$')), // Flags if speaker notes should be visible to all viewers - showNotes: ('$showNotes$' === '' ? false : true), + showNotes: Boolean(JSON.parse('$showNotes$')), // Global override for autolaying embedded media (video/audio/iframe) // - null: Media will only autoplay if data-autoplay is present // - True: All media will autoplay, regardless of individual setting // - False: No media will autoplay, regardless of individual setting - autoPlayMedia: ('$autoPlayMedia$' === 'null' ? null : '$autoPlayMedia$' === '' ? false : true), + autoPlayMedia: '$autoPlayMedia$'.length > 0 ? Boolean(JSON.parse('$autoPlayMedia$')) : null, // Global override for preloading lazy-loaded iframes // - null: Iframes with data-src AND data-preload will be loaded when within // the viewDistance, iframes with only data-src will be loaded when visible // - True: All iframes with data-src will be loaded when within the viewDistance // - False: All iframes with data-src will be loaded only when visible - preloadIframes: ('$preloadIframes$' === 'null' ? null : '$preloadIframes$' === '' ? false : true), + preloadIframes: '$preloadIframes$'.length > 0 ? Boolean(JSON.parse('$preloadIframes$')) : null, // Can be used to globally disable auto-animation - autoAnimate: ('$autoAnimate$' === '' ? false : true), -$if(autoAnimateMatcher)$ + autoAnimate: Boolean(JSON.parse('$autoAnimate$')), // Optionally provide a custom element matcher that will be // used to dictate which elements we can animate between. - autoAnimateMatcher: ('$autoAnimateMatcher$' === 'null' ? null : '$autoAnimateMatcher$'), // none/fade/slide/convex/concave/zoom -$endif$ + autoAnimateMatcher: ('$autoAnimateMatcher$'.length > 0 ? '$autoAnimateMatcher$' : null), // none/fade/slide/convex/concave/zoom $if(autoAnimateEasing)$ // Default settings for our auto-animate transitions, can be // overridden per-slide or per-element via data arguments @@ -172,17 +170,15 @@ $endif$ $if(autoAnimateDuration)$ autoAnimateDuration: $autoAnimateDuration$, $endif$ - autoAnimateUnmatched: ('$autoAnimateUnmatched$' === '' ? false : true), + autoAnimateUnmatched: Boolean(JSON.parse('$autoAnimateUnmatched$')), // Number of milliseconds between automatically proceeding to the // next slide, disabled when set to 0, this value can be overwritten // by using a data-autoslide attribute on your slides autoSlide: ('$autoSlide$' === '' ? false : parseInt('$autoSlide$')), // Stop auto-sliding after user input - autoSlideStoppable: ('$autoSlideStoppable$' === '' ? false : true), -$if(autoSlideMethod)$ + autoSlideStoppable: Boolean(JSON.parse('$autoSlideStoppable$')), // Use this method for navigation when auto-sliding (defaults to navigateNext) - autoSlideMethod: ('$autoSlideMethod$' === 'null' ? null : '$autoSlideMethod$'), // none/fade/slide/convex/concave/zoom -$endif$ + autoSlideMethod: ('$autoSlideMethod$'.length > 0 ? '$autoSlideMethod$' : null), // none/fade/slide/convex/concave/zoom $if(defaultTiming)$ // Specify the average time in seconds that you think you will spend // presenting each slide. This is used to show a pacing timer in the @@ -190,24 +186,19 @@ $if(defaultTiming)$ defaultTiming: $defaultTiming$, $endif$ // Enable slide navigation via mouse wheel - mouseWheel: ('$mouseWheel$' === '' ? false : true), + mouseWheel: Boolean(JSON.parse('$mouseWheel$')), // Opens links in an iframe preview overlay // Add `data-preview-link` and `data-preview-link="False"` to customise each link // individually - previewLinks: ('$previewLinks$' === '' ? false : true), + previewLinks: Boolean(JSON.parse('$previewLinks$')), // Exposes the reveal.js API through window.postMessage - postMessage: ('$postMessage$' === '' ? false : true), + postMessage: Boolean(JSON.parse('$postMessage$')), // Dispatches all reveal.js events to the parent window through postMessage - postMessageEvents: ('$postMessageEvents$' === '' ? false : true), + postMessageEvents: Boolean(JSON.parse('$postMessageEvents$')), // Focuses body when page changes visibility to ensure keyboard shortcuts work - focusBodyOnPageVisibilityChange: ('$focusBodyOnPageVisibilityChange$' === '' ? false : true), - // Apply a 3D roll to links on hover - // TODO check if still in use - rollingLinks: ('$rollingLinks$' === '' ? false : true), + focusBodyOnPageVisibilityChange: Boolean(JSON.parse('$focusBodyOnPageVisibilityChange$')), // Hides the address bar on mobile devices - hideAddressBar: ('$controls$' === '' ? false : true), - // Opens links in an iframe preview overlay - previewLinks: ('$controls$' === '' ? false : true)$previewLinks$, + hideAddressBar: Boolean(JSON.parse('$controls$')), $if(transition)$ // Transition style transition: '$transition$', // none/fade/slide/convex/concave/zoom