Loading Makefile +23 −16 Original line number Diff line number Diff line # Files. MARKDOWN = $(wildcard *.md) EXCLUDES = README.md LAYOUT.md FAQ.md DESIGN.md SRC_PAGES = $(filter-out $(EXCLUDES), $(MARKDOWN)) DST_PAGES = $(patsubst %.md,%.html,$(SRC_PAGES)) # R Markdown files. SRC_RMD = $(wildcard ??-*.Rmd) DST_RMD = $(patsubst %.Rmd,%.md,$(SRC_RMD)) # Pandoc filters FILTERS = $(wildcard tools/filters/*.py) # All Markdown files (hand-written and generated). SRC_MD = $(wildcard *.md) $(DST_RMD) DST_HTML = $(patsubst %.md,%.html,$(SRC_MD)) # All outputs. DST_ALL = $(DST_HTML) # Inclusions. INCLUDES = \ Loading @@ -14,11 +16,14 @@ INCLUDES = \ -Vfooter="$$(cat _includes/footer.html)" \ -Vjavascript="$$(cat _includes/javascript.html)" # Chunk options for knitr (used in R conversion). R_CHUNK_OPTS = tools/chunk-options.R # Default action is to show what commands are available. all : commands ## preview : Build website locally for checking. preview : $(DST_PAGES) preview : $(DST_ALL) # Pattern for slides (different parameters and template). motivation.html : motivation.md _layouts/slides.html Loading @@ -27,7 +32,7 @@ motivation.html : motivation.md _layouts/slides.html -o $@ $< # Pattern to build a generic page. %.html : %.md _layouts/page.html $(FILTERS) %.html : %.md _layouts/page.html pandoc -s -t html \ --template=_layouts/page \ --filter=tools/filters/blockquote2div.py \ Loading @@ -35,23 +40,25 @@ motivation.html : motivation.md _layouts/slides.html $(INCLUDES) \ -o $@ $< # Pattern to convert R Markdown to Markdown. %.md: %.Rmd $(R_CHUNK_OPTS) Rscript -e "knitr::knit('$$(basename $<)', output = '$$(basename $@)')" ## unittest : Run unit test (for Python 2 and 3) unittest: tools/check.py tools/validation_helpers.py tools/test_check.py cd tools/ && python2 test_check.py cd tools/ && python3 test_check.py # Pattern to convert R Markdown to Markdown. %.md: %.Rmd $(R_CHUNK_OPTS) Rscript -e "knitr::knit('$$(basename $<)', output = '$$(basename $@)')" ## commands : Display available commands. commands : Makefile @sed -n 's/^##//p' $< ## settings : Show variables and settings. settings : @echo 'SRC_PAGES:' $(SRC_PAGES) @echo 'DST_PAGES:' $(DST_PAGES) @echo 'SRC_RMD:' $(SRC_RMD) @echo 'DST_RMD:' $(DST_RMD) @echo 'SRC_MD:' $(SRC_MD) @echo 'DST_HTML:' $(DST_HTML) ## clean : Clean up temporary and intermediate files. clean : Loading @@ -59,4 +66,4 @@ clean : # very-clean : Remove generated HTML. very-clean : @rm -f $(DST_PAGES) @rm -f $(DST_MD) tools/chunk-options.R 0 → 100644 +26 −0 Original line number Diff line number Diff line # These settings control the behavior of all chunks in the novice R materials. # For example, to generate the lessons with all the output hidden, simply change # `results` from "markup" to "hide". # For more information on available chunk options, see # http://yihui.name/knitr/options#chunk_options library("knitr") opts_chunk$set(tidy = FALSE, results = "markup", comment = NA, fig.align = "center") # The hooks below add html tags to the code chunks and their output so that they # are properly formatted when the site is built with jekyll. hook_in <- function(x, options) { stringr::str_c("\n\n~~~{.r}\n", paste0(x, collapse="\n"), "\n~~~\n\n") } hook_out <- function(x, options) { stringr::str_c("\n\n~~~{.output}\n", paste0(x, collapse="\n"), "\n~~~\n\n") } knit_hooks$set(source = hook_in, output = hook_out, warning = hook_out, error = hook_out, message = hook_out) No newline at end of file tools/filters/blockquote2div.py +0 −13 Original line number Diff line number Diff line Loading @@ -51,15 +51,6 @@ import pandocfilters as pf # trigger the blockquote to be converted to a div. SPECIAL_CLASSES = ['callout', 'challenge', 'prereq', 'objectives'] # These are titles of blockquotes that will cause the blockquote to # be converted into a div. They are 'title': 'class' pairs, where the # 'title' will create a blockquote with the corresponding 'class'. SPECIAL_TITLES = {'prerequisites': 'prereq', 'learning objectives': 'objectives', 'objectives': 'objectives', 'challenge': 'challenge', 'callout': 'callout'} def find_header(blockquote): """Find attributes in a blockquote if they are defined on a Loading Loading @@ -104,10 +95,6 @@ def blockquote2div(key, value, format, meta): id, classes, kvs = attr lowercase_title = pf.stringify(inlines).lower() if lowercase_title in SPECIAL_TITLES: classes.append(SPECIAL_TITLES[lowercase_title]) if len(classes) == 1 and classes[0] in SPECIAL_CLASSES: remove_attributes(blockquote) # a blockquote is just a list of blocks, so it can be Loading Loading
Makefile +23 −16 Original line number Diff line number Diff line # Files. MARKDOWN = $(wildcard *.md) EXCLUDES = README.md LAYOUT.md FAQ.md DESIGN.md SRC_PAGES = $(filter-out $(EXCLUDES), $(MARKDOWN)) DST_PAGES = $(patsubst %.md,%.html,$(SRC_PAGES)) # R Markdown files. SRC_RMD = $(wildcard ??-*.Rmd) DST_RMD = $(patsubst %.Rmd,%.md,$(SRC_RMD)) # Pandoc filters FILTERS = $(wildcard tools/filters/*.py) # All Markdown files (hand-written and generated). SRC_MD = $(wildcard *.md) $(DST_RMD) DST_HTML = $(patsubst %.md,%.html,$(SRC_MD)) # All outputs. DST_ALL = $(DST_HTML) # Inclusions. INCLUDES = \ Loading @@ -14,11 +16,14 @@ INCLUDES = \ -Vfooter="$$(cat _includes/footer.html)" \ -Vjavascript="$$(cat _includes/javascript.html)" # Chunk options for knitr (used in R conversion). R_CHUNK_OPTS = tools/chunk-options.R # Default action is to show what commands are available. all : commands ## preview : Build website locally for checking. preview : $(DST_PAGES) preview : $(DST_ALL) # Pattern for slides (different parameters and template). motivation.html : motivation.md _layouts/slides.html Loading @@ -27,7 +32,7 @@ motivation.html : motivation.md _layouts/slides.html -o $@ $< # Pattern to build a generic page. %.html : %.md _layouts/page.html $(FILTERS) %.html : %.md _layouts/page.html pandoc -s -t html \ --template=_layouts/page \ --filter=tools/filters/blockquote2div.py \ Loading @@ -35,23 +40,25 @@ motivation.html : motivation.md _layouts/slides.html $(INCLUDES) \ -o $@ $< # Pattern to convert R Markdown to Markdown. %.md: %.Rmd $(R_CHUNK_OPTS) Rscript -e "knitr::knit('$$(basename $<)', output = '$$(basename $@)')" ## unittest : Run unit test (for Python 2 and 3) unittest: tools/check.py tools/validation_helpers.py tools/test_check.py cd tools/ && python2 test_check.py cd tools/ && python3 test_check.py # Pattern to convert R Markdown to Markdown. %.md: %.Rmd $(R_CHUNK_OPTS) Rscript -e "knitr::knit('$$(basename $<)', output = '$$(basename $@)')" ## commands : Display available commands. commands : Makefile @sed -n 's/^##//p' $< ## settings : Show variables and settings. settings : @echo 'SRC_PAGES:' $(SRC_PAGES) @echo 'DST_PAGES:' $(DST_PAGES) @echo 'SRC_RMD:' $(SRC_RMD) @echo 'DST_RMD:' $(DST_RMD) @echo 'SRC_MD:' $(SRC_MD) @echo 'DST_HTML:' $(DST_HTML) ## clean : Clean up temporary and intermediate files. clean : Loading @@ -59,4 +66,4 @@ clean : # very-clean : Remove generated HTML. very-clean : @rm -f $(DST_PAGES) @rm -f $(DST_MD)
tools/chunk-options.R 0 → 100644 +26 −0 Original line number Diff line number Diff line # These settings control the behavior of all chunks in the novice R materials. # For example, to generate the lessons with all the output hidden, simply change # `results` from "markup" to "hide". # For more information on available chunk options, see # http://yihui.name/knitr/options#chunk_options library("knitr") opts_chunk$set(tidy = FALSE, results = "markup", comment = NA, fig.align = "center") # The hooks below add html tags to the code chunks and their output so that they # are properly formatted when the site is built with jekyll. hook_in <- function(x, options) { stringr::str_c("\n\n~~~{.r}\n", paste0(x, collapse="\n"), "\n~~~\n\n") } hook_out <- function(x, options) { stringr::str_c("\n\n~~~{.output}\n", paste0(x, collapse="\n"), "\n~~~\n\n") } knit_hooks$set(source = hook_in, output = hook_out, warning = hook_out, error = hook_out, message = hook_out) No newline at end of file
tools/filters/blockquote2div.py +0 −13 Original line number Diff line number Diff line Loading @@ -51,15 +51,6 @@ import pandocfilters as pf # trigger the blockquote to be converted to a div. SPECIAL_CLASSES = ['callout', 'challenge', 'prereq', 'objectives'] # These are titles of blockquotes that will cause the blockquote to # be converted into a div. They are 'title': 'class' pairs, where the # 'title' will create a blockquote with the corresponding 'class'. SPECIAL_TITLES = {'prerequisites': 'prereq', 'learning objectives': 'objectives', 'objectives': 'objectives', 'challenge': 'challenge', 'callout': 'callout'} def find_header(blockquote): """Find attributes in a blockquote if they are defined on a Loading Loading @@ -104,10 +95,6 @@ def blockquote2div(key, value, format, meta): id, classes, kvs = attr lowercase_title = pf.stringify(inlines).lower() if lowercase_title in SPECIAL_TITLES: classes.append(SPECIAL_TITLES[lowercase_title]) if len(classes) == 1 and classes[0] in SPECIAL_CLASSES: remove_attributes(blockquote) # a blockquote is just a list of blocks, so it can be Loading