Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lesson Template
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
prace-lessons
Lesson Template
Commits
f68203db
Commit
f68203db
authored
10 years ago
by
Raniere Silva
Browse files
Options
Downloads
Plain Diff
Merge branch 'core' into gh-pages
parents
f7cfe5ba
e0771954
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+23
-16
23 additions, 16 deletions
Makefile
tools/chunk-options.R
+26
-0
26 additions, 0 deletions
tools/chunk-options.R
tools/filters/blockquote2div.py
+0
-13
0 additions, 13 deletions
tools/filters/blockquote2div.py
with
49 additions
and
29 deletions
Makefile
+
23
−
16
View file @
f68203db
# 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
=
\
...
...
@@ -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
...
...
@@ -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
\
...
...
@@ -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
:
...
...
@@ -59,4 +66,4 @@ clean :
# very-clean : Remove generated HTML.
very-clean
:
@
rm
-f
$(
DST_
PAGES
)
@
rm
-f
$(
DST_
MD
)
This diff is collapsed.
Click to expand it.
tools/chunk-options.R
0 → 100644
+
26
−
0
View file @
f68203db
# 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
This diff is collapsed.
Click to expand it.
tools/filters/blockquote2div.py
+
0
−
13
View file @
f68203db
...
...
@@ -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
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment