diff --git a/markdeck b/markdeck index 77b1076..a0ec8e5 100755 --- a/markdeck +++ b/markdeck @@ -65,6 +65,7 @@ services: pdf: image: "arne/markdeck-decktape:0.5" + user: "\$MARKDECK_USER" volumes: - type: bind source: ${PWD}/${BUILD} @@ -74,6 +75,7 @@ services: standalone: image: "arne/markdeck-standalone:0.2" + user: "\$MARKDECK_USER" volumes: - type: bind source: ${PWD}/${BUILD} diff --git a/src/Dockerfile.liveserver b/src/Dockerfile.liveserver index 71c9d68..9a9bb74 100644 --- a/src/Dockerfile.liveserver +++ b/src/Dockerfile.liveserver @@ -9,4 +9,4 @@ EXPOSE 8080 VOLUME /target WORKDIR /target -ENTRYPOINT node /usr/local/bin/live-server --no-browser --wait=100 --watch=/target/index.html,assets/css/ . +ENTRYPOINT node /usr/local/bin/live-server --no-browser --wait=50 --watch=/target/index.html,assets/css/ . diff --git a/src/Dockerfile.pandoc b/src/Dockerfile.pandoc index c396714..7ef8e5d 100644 --- a/src/Dockerfile.pandoc +++ b/src/Dockerfile.pandoc @@ -6,6 +6,7 @@ ARG pandoc_version ARG version ARG motto +# TODO try watchman to get inotify working. Currently watchman in alpine edge .. RUN apk add \ make bash curl \ graphviz inotify-tools rsync \ diff --git a/src/markdeck/Makefile b/src/markdeck/Makefile new file mode 100644 index 0000000..ff01463 --- /dev/null +++ b/src/markdeck/Makefile @@ -0,0 +1,157 @@ +#!/usr/bin/env make -f + +SHELL := /bin/bash + +build: .info-build render sync sass config pandoc + @echo "-------- /rerendering ---------" + @echo + +.info-build: + @echo "-------- rerendering ---------" + + +.info-render: + @echo "-------- rerendering prep ---------" + +render: .info-render /target/assets/css/rerendering.css /target/assets/rendered + @echo "-------- /rerendering prep ---------" + @echo + +/target/assets/css/rerendering.css: /markdeck/assets/markdeck/css/when-rerendering.css /target/assets/css + cp $< $@ + +/target/assets/css: + mkdir -p $@ + +/target/assets/rendered: + mkdir -p $@ + + +.info-sync: + @echo "-------- rsync output --------" + +sync: .info-sync .rsync .fc-list + @echo "-------- /rsync ---------" + @echo + +.rsync: /target .rsync-sync /target/assets/css/slides.scss /target/assets/css/render-pdf.css + +.rsync-sync: /markdeck/assets $(wildcard /source/assets) + # FIXME the dynamically generated scss and css files are deleted by rsync. + # If there was a way to separate the files coming from rsync and the + # dynamically generated files this would be ideal + # -rsync -auv --delete $^ /target/ + -rsync -auv $^ /target/ + +.fc-list: + @echo + @echo "Known fonts:" + @fc-list + +/target/assets/css/slides.scss /target/assets/css/slides.impress.css /target/assets/css/render-pdf.css: + touch $@ + + +.info-sass: + @echo "-------- sass output --------" + +sass: .info-sass \ + /target/assets/css/slides.css \ + /target/assets/css/slides.impress.css \ + /target/assets/markdeck/css/markdeck.impressjs.css \ + /target/assets/markdeck/css/markdeck.revealjs.css \ + .sync-custom-themes \ + $(addprefix /target/assets/3rdparty/reveal.js/css/theme/,$(addsuffix .css,$(basename $(notdir $(wildcard /target/assets/3rdparty/reveal.js/css/theme/source/*.scss))))) + + @echo "-------- /sass ---------" + @echo + +.sync-custom-themes: $(wildcard /source/assets/css/theme/source/*.scss) + rsync -au $^ /target/assets/3rdparty/reveal.js/css/theme/source/ + + +.info-config: + @echo "-------- config --------" + +config: .info-config .metadata + jq '. | .' < /target/.meta/config.json + @echo "ASCIIART_CONFIG=${ASCIIART_CONFIG}" + @echo "-------- /config --------" + @echo + +.metadata: /target/.meta /target/.meta/config.json + +/target/.meta/config.json: $(wildcard /source/slide*.md) /markdeck/note.md /markdeck/defaults.yaml + pandoc --template=/markdeck/metadata.template $^ > $@ + +/target/.meta: + mkdir -p $@ + + +.info-pandoc: + @echo "-------- pandoc output --------" + +pandoc: .info-pandoc /target/index.html + @echo "-------- /pandoc output --------" + @echo + +/target/.meta/slides.combined.md.txt: $(wildcard /source/slide*.md) + -rm -f $@ + touch $@ + if [ -n "$^" ]; then \ + for F in $^; do \ + markdown-pp --exclude latexrender $$F >> $@ ; \ + echo >> $@; \ + done; \ + else \ + cp /markdeck/note.md $@; \ + fi + +/target/.meta/index.html: /target/.meta/slides.combined.md.txt /target/.meta/config.json /markdeck/defaults.yaml + PANDOC_ARGS=; \ + [ -e /source/include-before-body ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-before-body /source/include-before-body"; \ + [ -e /source/include-after-body ] && PANDOC_ARGS="$${PANDOC_ARGS} --include-after-body /source/include-after-body"; \ + variant="$$(jq -r '.variant' < /target/.meta/config.json)"; \ + pandoc \ + -f markdown+yaml_metadata_block \ + -t revealjs \ + --no-highlight \ + --wrap=preserve \ + --standalone \ + --template=/markdeck/template-$${variant}.html \ + --slide-level=2 \ + --section-divs \ + --lua-filter /markdeck/lib/skip-slide-filter.lua \ + --filter mathjax-pandoc-filter \ + --lua-filter /markdeck/lib/render-asciiart-filter.lua \ + --lua-filter /markdeck/lib/render-emojis-filter.lua \ + --lua-filter /markdeck/lib/bg-shortcut-filter.lua \ + --lua-filter /markdeck/lib/$${variant}-shortcut-filter.lua \ + --lua-filter /markdeck/lib/inline-svg.lua \ + --lua-filter /markdeck/lib/font-awesome.lua \ + $${PANDOC_ARGS} \ + -o $@ \ + $< /markdeck/defaults.yaml 2>&1 | tee /target/.meta/pandoc.output + +/target/index.html: /target/.meta /target/.meta/index.html + # clear rerendering styling + echo "" > /target/assets/css/rerendering.css + cp /target/.meta/index.html $@ + +.SECONDEXPANSION: +/target/assets/3rdparty/reveal.js/css/theme/%.css: $$(addsuffix /%.scss,/target/assets/3rdparty/reveal.js/css/theme/source) + sassc $< $@ + +/target/assets/markdeck/css/%.css /target/assets/css/%.css: $$(subst .css,.scss,$$@) + sassc $< $@ + +wait-for-changes: $(wildcard /source/slide*.md) /source/assets $(wildcard /source/include-before-body) $(wildcard /source/include-after-body) + # TODO currently inotify doesn't work on mounted volumes :-/ + # inotifywait -e modify,create,delete,move,attrib -r $^ + /markdeck/wait-for-changes "$(WAIT_REFERENCE)" + + +clean: + rm -rf /target/.??* /target/* + +.PHONY: build .info-build render .info-render sync .info-sync .rsync .rsync-sync .fc-list sass .info-sass .sync-custom-themes clean config .info-config pandoc .info-pandoc wait-for-changes diff --git a/src/markdeck/assets/markdeck/css/_common.scss b/src/markdeck/assets/markdeck/css/_common.scss index 8f56212..447e5ee 100644 --- a/src/markdeck/assets/markdeck/css/_common.scss +++ b/src/markdeck/assets/markdeck/css/_common.scss @@ -14,7 +14,6 @@ } } - @font-face { font-family: 'Inconsolata'; font-style: normal; diff --git a/src/markdeck/assets/markdeck/css/markdeck.revealjs.scss b/src/markdeck/assets/markdeck/css/markdeck.revealjs.scss index 7262050..fe4abea 100644 --- a/src/markdeck/assets/markdeck/css/markdeck.revealjs.scss +++ b/src/markdeck/assets/markdeck/css/markdeck.revealjs.scss @@ -1,5 +1,14 @@ @import "commoncommon"; +.columns { + display: flex; +} + +.no-list-style ul { + list-style-type: none; + padding-left: 0; +} + .reveal .license { font-size: 12pt; } diff --git a/src/markdeck/assets/markdeck/css/theme/source/markdeck.scss b/src/markdeck/assets/markdeck/css/theme/source/markdeck.scss index 5c241d6..2aa2199 100644 --- a/src/markdeck/assets/markdeck/css/theme/source/markdeck.scss +++ b/src/markdeck/assets/markdeck/css/theme/source/markdeck.scss @@ -52,10 +52,10 @@ $linkColor: #00008B; $linkColorHover: lighten( $linkColor, 20% ); $selectionBackgroundColor: rgba(0, 0, 0, 0.99); -$heading1Size: 1.4em; -$heading2Size: 0.8em; -$heading3Size: 0.8em; -$heading4Size: 0.8em; +$heading1Size: 2.5em; +$heading2Size: 1.5em; +$heading3Size: 1.3em; +$heading4Size: 1.1em; section.has-dark-background { &, h1, h2, h3, h4, h5, h6 { diff --git a/src/markdeck/defaults.yaml b/src/markdeck/defaults.yaml index fe47d94..4a5021e 100644 --- a/src/markdeck/defaults.yaml +++ b/src/markdeck/defaults.yaml @@ -16,7 +16,7 @@ margin: 0.1 minScale: 0.2 maxScale: 1.5 -markdeckFooter: true +markdeckFooter: false standalone: @@ -41,6 +41,7 @@ loop: false rtl: false shuffle: false fragments: true +fragmentsInURL: true embedded: false help: true showNotes: false diff --git a/src/markdeck/lib/render-asciiart-filter.lua b/src/markdeck/lib/render-asciiart-filter.lua index aefd3f4..338e9b8 100644 --- a/src/markdeck/lib/render-asciiart-filter.lua +++ b/src/markdeck/lib/render-asciiart-filter.lua @@ -41,11 +41,11 @@ else io.stderr:write(err) end -local outputdir=io.open("rendered","r") +local outputdir=io.open("assets/rendered","r") if outputdir~=nil then io.close(outputdir) else - os.execute("mkdir rendered") + os.execute("mkdir assets/rendered") end LIBDIR=os.getenv("ASCIIART_LIBDIR") or "lib" @@ -128,7 +128,7 @@ images = {} function Cleanup(doc) - local pfile = io.popen('ls -a rendered/*.png rendered/*.svg 2> /dev/null') + local pfile = io.popen('ls -a assets/rendered/*.png assets/rendered/*.svg 2> /dev/null') for fname in pfile:lines() do if not images[fname] then io.stderr:write("removing obsolete '" .. fname .. "'\n") @@ -146,7 +146,7 @@ function Render(elem, attr) if elem.classes[1] == format then local cmd, filetype = render_cmd(elem.text, elem.attributes or {}) local mimetype = "image/" .. filetype - local fname = "rendered/" .. format .. "-" .. pandoc.sha1(cmd[1] .. table.concat(cmd[2], " ") .. cmd[3]) .. "." .. filetype + local fname = "assets/rendered/" .. format .. "-" .. pandoc.sha1(cmd[1] .. table.concat(cmd[2], " ") .. cmd[3]) .. "." .. filetype local data = nil local f=io.open(fname,"rb") diff --git a/src/markdeck/loop b/src/markdeck/loop index e043562..aae672c 100755 --- a/src/markdeck/loop +++ b/src/markdeck/loop @@ -10,7 +10,7 @@ case $PARAM in shell) bash -i; exit;; --once) ONCE=true;; loop) ;; - *) echo "unknown parameter '$PARAM' given, aborting here..." && exit 1;; + *) echo "Unknown parameter '$PARAM' given, aborting here." && exit 1;; esac shopt -s nullglob @@ -20,20 +20,19 @@ function print_usage() { echo -e "\n\n\n${esc}[1mmarkdeck $VERSION - $MOTTO${esc}[0m\n" echo -e " ${esc}[1mfor the slides: open http://localhost:$PORT${esc}[0m" echo - echo -e "for side-by-side view: open http://localhost:$PORT/explain.html" + echo -e "For side-by-side view: open http://localhost:$PORT/explain.html" echo -e " to stop markdeck: hit Ctrl-C" echo echo } function show_errors() { - rm -f /target/index.html echo '
' > /target/index.html - cat /tmp/pandoc.output >> /target/index.html + cat /target/.meta/pandoc.output >> /target/index.html echo '' >> /target/index.html echo -e "${esc}[37m${esc}[43m" echo -e "\npandoc crashed\n" - cat /tmp/pandoc.output + cat /target/.meta/pandoc.output echo -e "${esc}[0m" sleep 4 } @@ -49,134 +48,30 @@ fi export ASCIIART_CONFIG export ASCIIART_LIBDIR=/markdeck/lib +export WAIT_REFERENCE="$(mktemp)" + while true; do cd /target - echo "-------- rerendering ---------" - mkdir -p /target/assets/css/ - cp -v /markdeck/assets/markdeck/css/when-rerendering.css /target/assets/css/rerendering.css - - [[ -d /target/rendered ]] || mkdir -p /target/rendered - - echo "-------- rsync output --------" - rsync -a /markdeck/assets /target/ || : - touch /target/assets/css/slides.css /target/assets/css/render-pdf.css - [[ -d /source/assets ]] && rsync -av /source/assets /target/ || : - rsync -a /markdeck/explain.html /target/ || : - fc-list - echo "-------- /rsync output --------" - echo - - echo "-------- sass output --------" - if [[ -e /source/assets/css/slides.scss ]]; then - sassc \ - /source/assets/css/slides.scss \ - /target/assets/css/slides.css || : - fi - if [[ -e /source/assets/css/theme/source/ ]]; then - find /source/assets/css/theme/source/ -name \*.scss | while read filename; do - cp "$filename" /target/assets/3rdparty/reveal.js/css/theme/source/ - sassc \ - /target/assets/3rdparty/reveal.js/css/theme/source/$(basename "$filename") \ - /target/assets/3rdparty/reveal.js/css/theme/$(basename "$filename" | sed -e 's/\.scss$/.css/') || : - done - fi - if [[ -e /source/assets/css/slides.impress.scss ]]; then - sassc \ - /source/assets/css/slides.impress.scss \ - /target/assets/css/slides.impress.css || : - fi - sassc \ - /markdeck/assets/markdeck/css/markdeck.revealjs.scss \ - /target/assets/markdeck/css/markdeck.revealjs.css || : - sassc \ - /markdeck/assets/3rdparty/reveal.js/css/theme/source/markdeck.scss \ - /target/assets/3rdparty/reveal.js/css/theme/markdeck.css || : - sassc \ - /markdeck/assets/markdeck/css/markdeck.impressjs.scss \ - /target/assets/markdeck/css/markdeck.impressjs.css || : - echo "-------- /sass output --------" - echo - - echo "-------- config --------" - shopt -s nullglob - SOURCE_MD=$(echo /source/slide*.md) - shopt -u nullglob - METADATA="$(pandoc --template=/markdeck/metadata.template ${SOURCE_MD:-/markdeck/note.md} /markdeck/defaults.yaml)" - mkdir -p /target/.meta/ - rm -f /target/.meta/config.json - echo "$METADATA" > /target/.meta/config.json - jq '. | .' <<<$METADATA - variant=$(jq -r '.variant' <<< "$METADATA") - echo "ASCIIART_CONFIG=$ASCIIART_CONFIG" - echo "-------- /config --------" - echo + touch "${WAIT_REFERENCE}" - echo "-------- pandoc output --------" - PANDOC_ARGS= - [[ -e /source/include-before-body ]] && PANDOC_ARGS="$PANDOC_ARGS --include-before-body /source/include-before-body" - [[ -e /source/include-after-body ]] && PANDOC_ARGS="$PANDOC_ARGS --include-after-body /source/include-after-body" - rm -f /target/slides.combined.md.txt - # cat ${SOURCE_MD:-/markdeck/note.md} > /target/slides.combined.md.txt - if [[ -n ${SOURCE_MD:-} ]]; then - for F in $SOURCE_MD; do - markdown-pp --exclude latexrender $F >> /target/slides.combined.md.txt - echo >> /target/slides.combined.md.txt - done - else - cp /markdeck/note.md /target/slides.combined.md.txt - fi - - - template=/markdeck/template-${variant}.html - if pandoc \ - -f markdown+yaml_metadata_block \ - -t revealjs \ - --no-highlight \ - --wrap=preserve \ - --standalone \ - --template=$template \ - --slide-level=2 \ - --section-divs \ - --lua-filter /markdeck/lib/skip-slide-filter.lua \ - --filter mathjax-pandoc-filter \ - --lua-filter /markdeck/lib/render-asciiart-filter.lua \ - --lua-filter /markdeck/lib/render-emojis-filter.lua \ - --lua-filter /markdeck/lib/bg-shortcut-filter.lua \ - --lua-filter /markdeck/lib/${variant}-shortcut-filter.lua \ - --lua-filter /markdeck/lib/inline-svg.lua \ - --lua-filter /markdeck/lib/font-awesome.lua \ - $PANDOC_ARGS \ - -o /target/index.html.tmp \ - /target/slides.combined.md.txt /markdeck/defaults.yaml 2>&1 | tee /tmp/pandoc.output; - then - if [[ -e /target/index.html.tmp ]]; then - echo "" > /target/assets/css/rerendering.css - mv /target/index.html.tmp /target/index.html - else - show_errors - fi - else - show_errors - fi - echo "-------- /pandoc output --------" - echo - echo "-------- /rerendering ----------" - echo + make -f /markdeck/Makefile build || show_errors $ONCE && break if [[ /source -nt /target/index.html ]]; then - echo -e "\n\n\nchange detected: sources newer than rendered deck, rerendering started...\n\n\n" + echo -e "\n\n\nChange detected, restart rerendering.\n\n\n" continue fi sleep .5 print_usage - /markdeck/wait-for-changes + make -f /markdeck/Makefile wait-for-changes echo -e "\n\n\n\n\n\n\n\n\n\n" done -echo "done." +rm -f "${WAIT_REFERENCE}" + +echo "Markdeck done." diff --git a/src/markdeck/loop.decktape b/src/markdeck/loop.decktape index d293383..0d49d81 100755 --- a/src/markdeck/loop.decktape +++ b/src/markdeck/loop.decktape @@ -9,8 +9,8 @@ while true; do pdf=$(echo "$CONFIG" | jq -r '.pdf') if [ -n "$pdf" ]; then + echo "Start PDF rendering." touch /slides/.meta/pdf_rendered - echo "starting pdf rendering" # stat -c "%y %n" /target/index.html # stat -c "%y %n" /target/.meta/pdf_rendered pdf_size=$(echo "$CONFIG" | jq -r '.pdf_size') @@ -40,9 +40,14 @@ while true; do convert -density 300x300 $(ls -1r -tc /tmp/slides/*.png) /slides/$pdf.screenshots.pdf fi - echo "pdf rendering finished" + echo "PDF rendering finished." + else + echo "No PDF output file specified, skip rendering." fi sleep 1 - [ /slides/index.html -nt /slides/.meta/pdf_rendered ] && continue + + [ -e /slides/index.html ] && [ -e /slides/.meta/pdf_rendered ] && [ /slides/index.html -nt /slides/.meta/pdf_rendered ] && continue inotifywait -qq /slides/index.html done + +# vi: ft=sh:tw=80:sw=4:ts=4:sts=4:et diff --git a/src/markdeck/template-reveal.html b/src/markdeck/template-reveal.html index 9c15f4d..e33874e 100644 --- a/src/markdeck/template-reveal.html +++ b/src/markdeck/template-reveal.html @@ -90,6 +90,7 @@ rtl: '$rtl$', shuffle: '$shuffle$', fragments: '$fragments$', + fragmentsInURL: '$fragmentsInURL$', embedded: '$embedded$', help: '$help$', showNotes: '$showNotes$', diff --git a/src/markdeck/wait-for-changes b/src/markdeck/wait-for-changes index d6791a0..f7bf413 100755 --- a/src/markdeck/wait-for-changes +++ b/src/markdeck/wait-for-changes @@ -2,7 +2,11 @@ set -e -E -u SOURCES="/source/slide*.md $(find /source/assets -type d) /source/include-before-body /source/include-after-body" -TARGET=/target/index.html +TARGET="${1}" + +if [ ! -e "${TARGET}" ]; then + exit 1 +fi last_sources=$(echo $SOURCES) no_change=true @@ -19,6 +23,7 @@ while $no_change; do no_change=false fi done - $no_change && sleep 2 + $no_change && sleep 1 done + exit 0