Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize rendering #33

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8b20da9
Put markdeck revealjs adjustments in a markdeck theme
jceb Sep 27, 2019
ccc8aee
Hide box-shadow around emojis
jceb Sep 27, 2019
87bb47a
Remove duplicate plantuml.jar integration
jceb Sep 27, 2019
87db390
Remove duplicate img.emoji theming
jceb Sep 27, 2019
058d804
Support creation of custom revealjs themes through files in assets/cs…
jceb Sep 27, 2019
1e4fffd
Add header and footer elements that can be styled by themes
jceb Sep 27, 2019
b7f04d3
Show display controls in speaker notes always
jceb Sep 27, 2019
b0aa50d
Include favicon from user's theme folder
jceb Sep 27, 2019
5d96146
Convert bash script to Makefile
jceb Sep 28, 2019
5f8c0c8
Replace make variables with shell variables
jceb Sep 29, 2019
ab23ab1
Combine multiple rsync calls into one
jceb Sep 29, 2019
17c6cf4
Reduce wait time of liveserver to 50 milliseconds
jceb Sep 29, 2019
863abb0
Move temporary files into .meta/
jceb Sep 29, 2019
af3bf1d
Move rendered folder to assets/rendered
jceb Sep 29, 2019
c8115f3
Don't sync explain.html
jceb Sep 29, 2019
e30d122
Fix reference point for wait-for-changes and add inotify target
jceb Sep 29, 2019
cd5bc43
Simplify loop
jceb Sep 29, 2019
00933ae
Rename wait-for-changes target and make it PHONY
jceb Sep 30, 2019
eaa633f
Rename default target from all to build
jceb Sep 30, 2019
6944eea
Add missing sass dependency
jceb Sep 30, 2019
9540c1d
Merge branch 'master' into optimize_rendering
arnehilmann Oct 1, 2019
099da2f
Fix typo
jceb Oct 3, 2019
c2cb6c1
Create reference point for wait changes before the build run
jceb Oct 3, 2019
2bdc92e
Add option fragmentsInURL
jceb Nov 7, 2019
aa52136
Support columns configuration from pandoc documentation
jceb Nov 7, 2019
fa63940
Delete duplicate empty line
jceb Nov 7, 2019
b04f456
Set MARKDECK_USER for pdf and standalone to ensure write access
Nov 26, 2019
b976b80
Improve error detection if pdf rendering fails
Nov 26, 2019
6665eba
Unify error messages to start with an uppercase letter and end with a…
Nov 26, 2019
ac80512
Delete debug information
Nov 26, 2019
8191989
Add more information about the reason for skipping PDF rendering
Nov 26, 2019
88526c5
Deactivate markdeckFooter by default
Nov 26, 2019
7335b38
Increase heading font sizes in default theme to make it them readable
Nov 26, 2019
b61b44c
Hide list style if requested
Nov 26, 2019
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
2 changes: 2 additions & 0 deletions markdeck
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ services:

pdf:
image: "arne/markdeck-decktape:0.5"
user: "\$MARKDECK_USER"
volumes:
- type: bind
source: ${PWD}/${BUILD}
Expand All @@ -74,6 +75,7 @@ services:

standalone:
image: "arne/markdeck-standalone:0.2"
user: "\$MARKDECK_USER"
volumes:
- type: bind
source: ${PWD}/${BUILD}
Expand Down
2 changes: 1 addition & 1 deletion src/Dockerfile.liveserver
Original file line number Diff line number Diff line change
Expand Up @@ -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/ .
1 change: 1 addition & 0 deletions src/Dockerfile.pandoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
157 changes: 157 additions & 0 deletions src/markdeck/Makefile
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion src/markdeck/assets/markdeck/css/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
}
}


@font-face {
font-family: 'Inconsolata';
font-style: normal;
Expand Down
9 changes: 9 additions & 0 deletions src/markdeck/assets/markdeck/css/markdeck.revealjs.scss
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/markdeck/assets/markdeck/css/theme/source/markdeck.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/markdeck/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ margin: 0.1
minScale: 0.2
maxScale: 1.5

markdeckFooter: true
markdeckFooter: false

standalone:

Expand All @@ -41,6 +41,7 @@ loop: false
rtl: false
shuffle: false
fragments: true
fragmentsInURL: true
embedded: false
help: true
showNotes: false
Expand Down
8 changes: 4 additions & 4 deletions src/markdeck/lib/render-asciiart-filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Loading