intial commit (forked from private repo)
This commit is contained in:
13
slides/_extensions/grantmcdermott/clean/_extension.yml
Normal file
13
slides/_extensions/grantmcdermott/clean/_extension.yml
Normal file
@ -0,0 +1,13 @@
|
||||
title: clean
|
||||
author: Grant McDermott
|
||||
version: 1.3.0
|
||||
quarto-required: ">=1.3.0"
|
||||
contributes:
|
||||
formats:
|
||||
revealjs:
|
||||
theme: [default, clean.scss]
|
||||
menu:
|
||||
side: left
|
||||
slide-number: true
|
||||
date-format: long
|
||||
|
||||
351
slides/_extensions/grantmcdermott/clean/clean.scss
Normal file
351
slides/_extensions/grantmcdermott/clean/clean.scss
Normal file
@ -0,0 +1,351 @@
|
||||
/*-- scss:defaults --*/
|
||||
|
||||
// Custom colours and variables
|
||||
|
||||
$jet: #131516;
|
||||
$accent: #107895;
|
||||
$accent2: #9a2515;
|
||||
// $accent2: #e64173;
|
||||
$right-arrow: "\2192"; // Unicode character for right arrow
|
||||
|
||||
// fonts
|
||||
|
||||
/*
|
||||
Note: This theme uses the Roboto font family, which it imports from Google
|
||||
Fonts to ensure consistent weighting in addition to availability. While
|
||||
you can use a local installation of Roboto, this is generally not
|
||||
recommended since the weighting will likely be wrong (probably too
|
||||
light). OTOH, importing from Google Fonts can cause some issues in
|
||||
certain secure environments due the external CDN (see:
|
||||
https://github.com/grantmcdermott/quarto-revealjs-clean/issues/7). If
|
||||
that's the case for you, simply comment out the `@import url(...)` line
|
||||
below and it will default for the default Sans Serif font on your system
|
||||
(e.g., Helvetica on a Mac). Circling back to the earlier point about
|
||||
preserving consistent font weights, you may also wish to remove "Roboto"
|
||||
from the choice set if the family is installed locally.
|
||||
*/
|
||||
@import url('https://fonts.googleapis.com/css?family=Roboto:200,200i,300,300i,350,350i,400,400i&display=swap');
|
||||
|
||||
$font-family-sans-serif: "Roboto", sans-serif !default;
|
||||
$presentation-heading-font: "Roboto", sans-serif !default;
|
||||
|
||||
$presentation-heading-color: $jet !default;
|
||||
$presentation-heading-font-weight: lighter;
|
||||
//$presentation-heading-line-height: 2;
|
||||
//$presentation-block-margin: 28px;
|
||||
$presentation-font-size-root: 32px;
|
||||
|
||||
// colors
|
||||
//$body-bg: #f0f1eb !default;
|
||||
$body-color: $jet !default;
|
||||
$link-color: $accent !default;
|
||||
$selection-bg: #26351c !default;
|
||||
|
||||
|
||||
/*-- scss:rules --*/
|
||||
|
||||
.reveal a {
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
.reveal p {
|
||||
// font-weight: 300;
|
||||
font-weight: lighter;
|
||||
margin-top: 1.25em;
|
||||
}
|
||||
|
||||
// title and headings
|
||||
|
||||
#title-slide {
|
||||
text-align: left;
|
||||
|
||||
.title {
|
||||
color: $body-color;
|
||||
font-size: 1.4em;
|
||||
// font-weight: 350;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: $accent;
|
||||
font-style: italic;
|
||||
margin-top: 0em;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
.institute,
|
||||
.quarto-title-affiliation,
|
||||
.quarto-title-author-email {
|
||||
font-style: italic;
|
||||
// font-size: 80%;
|
||||
// color: #7F7F7F;
|
||||
}
|
||||
|
||||
.author,
|
||||
.quarto-title-author-name {
|
||||
color: $body-color;
|
||||
}
|
||||
|
||||
.quarto-title-authors {
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
|
||||
.quarto-title-author {
|
||||
padding-left: 0em;
|
||||
padding-right: 0em;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
.reveal h2 {
|
||||
// font-weight: 350;
|
||||
font-weight: lighter;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
.reveal h3 {
|
||||
color: $accent;
|
||||
font-style: italic;
|
||||
// font-weight: 350;
|
||||
font-weight: lighter;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
.reveal h4 {
|
||||
color: $accent2;
|
||||
// font-weight: 350;
|
||||
font-weight: normal;
|
||||
margin-top: 1.25em;
|
||||
}
|
||||
|
||||
// alerts etc.
|
||||
|
||||
.alert {
|
||||
color: $accent2;
|
||||
}
|
||||
|
||||
.fg {
|
||||
color: var(--col, $jet);
|
||||
}
|
||||
|
||||
.bg {
|
||||
background-color: var(--col, #fff);
|
||||
padding: 0.1em;
|
||||
border-radius: 5px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
// lists
|
||||
|
||||
// Unordered lists
|
||||
|
||||
.reveal ul {
|
||||
// font-weight: 300;
|
||||
font-weight: lighter;
|
||||
padding-left: 16px;
|
||||
|
||||
li::marker {
|
||||
color: mix($accent, white, 70%);
|
||||
}
|
||||
}
|
||||
|
||||
.reveal ul ul {
|
||||
list-style: none;
|
||||
|
||||
li:before {
|
||||
content: $right-arrow;
|
||||
color: mix($accent, white, 60%);
|
||||
display: inline-block;
|
||||
width: 1em;
|
||||
margin-left: -1em;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
// Ordered lists
|
||||
|
||||
.reveal ol {
|
||||
// font-weight: 300;
|
||||
font-weight: lighter;
|
||||
padding-left: 16px;
|
||||
|
||||
li::marker {
|
||||
color: $accent;
|
||||
}
|
||||
}
|
||||
|
||||
// Move "hamburger" menu button to top right
|
||||
|
||||
.reveal .slide-menu-button {
|
||||
position: fixed;
|
||||
top: 6px;
|
||||
right: 0;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.reveal .slide-menu-button > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
// Same for chalkboard buttons (with an offset)
|
||||
|
||||
.reveal .slide-chalkboard-buttons {
|
||||
position: fixed;
|
||||
top: 12px;
|
||||
right: 24px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.reveal .slide-chalkboard-buttons > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
// Logo to the bottom-left
|
||||
.slide-logo {
|
||||
display: block !important;
|
||||
position: fixed !important;
|
||||
bottom: 0 !important;
|
||||
left: 10px !important;
|
||||
max-width: 150px; // Adjust if necessary
|
||||
max-height: 50px;
|
||||
width: auto !important;
|
||||
color: $body-color !important;
|
||||
}
|
||||
|
||||
// Also need to enforce slide numbers at bottom-right (if logo is present)
|
||||
.slide-number, .reveal.has-logo .slide-number {
|
||||
bottom: 6px !important;
|
||||
right: 10px !important;
|
||||
top: unset !important;
|
||||
color: #777777 !important;
|
||||
}
|
||||
|
||||
// Beamer-style button link environment
|
||||
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 6px 12px;
|
||||
margin-bottom: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 1.42857143;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
background-color: $accent;
|
||||
border: 1px solid $accent;
|
||||
color: #fff !important;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: #0056b3;
|
||||
border-color: #0056b3;
|
||||
}
|
||||
|
||||
.button::before {
|
||||
content: "▶";
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
// tables
|
||||
|
||||
.reveal table {
|
||||
// height: auto; /* Adjust table width to fit content up to the available slide space */
|
||||
margin: auto;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.reveal table th,
|
||||
.reveal table td {
|
||||
border: none; /* Remove internal row lines */
|
||||
padding: .23em; /* Adjust padding as needed */
|
||||
text-align: left; /* Adjust text alignment as needed */
|
||||
font-weight: lighter; /* Lighter font weight for main table text */
|
||||
}
|
||||
|
||||
/* Adds a bottom border to the table header row for distinction */
|
||||
.reveal table thead th,
|
||||
.reveal .slides table tr:last-child td,
|
||||
.reveal .slides table {
|
||||
border-bottom: 2px solid #D3D3D3; /* Dark grey color for the bottom border */
|
||||
}
|
||||
|
||||
/* Make column headers bold */
|
||||
.reveal table thead th {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Styling table captions */
|
||||
.reveal table caption {
|
||||
color: #666666; /* Dark grey color for the caption */
|
||||
font-variant: small-caps; /* Use small caps for the caption text */
|
||||
}
|
||||
|
||||
// Special catch for etable environment to ensure these table images
|
||||
// don't overflow the slide.
|
||||
// See: https://lrberge.github.io/fixest/articles/etable_new_features.html
|
||||
|
||||
.etable {
|
||||
width: 100%;
|
||||
height: calc(100% - 3em); /* Adjust 3em based on the height of your header, if necessary */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.etable img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
// Change the relative widths of `output-location: column`.
|
||||
// See: https://github.com/grantmcdermott/quarto-revealjs-clean/pull/16
|
||||
// Example usage:
|
||||
// ```{python}
|
||||
// #| echo: true
|
||||
// #| output-location: column
|
||||
// #| classes: columns3070
|
||||
// <code>
|
||||
// ```
|
||||
.reveal .columns3070 > div.column:first-child {
|
||||
width: 30%;
|
||||
}
|
||||
.reveal .columns3070 div.column:not(:first-child) {
|
||||
width: 70%;
|
||||
}
|
||||
.reveal .columns7030 > div.column:first-child {
|
||||
width: 70%;
|
||||
}
|
||||
.reveal .columns7030 div.column:not(:first-child) {
|
||||
width: 30%;
|
||||
}
|
||||
.reveal .columns4060 > div.column:first-child {
|
||||
width: 40%;
|
||||
}
|
||||
.reveal .columns4060 div.column:not(:first-child) {
|
||||
width: 60%;
|
||||
}
|
||||
.reveal .columns6040 > div.column:first-child {
|
||||
width: 60%;
|
||||
}
|
||||
.reveal .columns6040 div.column:not(:first-child) {
|
||||
width: 40%;
|
||||
}
|
||||
7
slides/_extensions/metropolis-theme/_extension.yml
Normal file
7
slides/_extensions/metropolis-theme/_extension.yml
Normal file
@ -0,0 +1,7 @@
|
||||
title: Quarto Metropolis Theme
|
||||
author: Patrick Schratz
|
||||
version: 1.0.0
|
||||
contributes:
|
||||
formats:
|
||||
revealjs:
|
||||
theme: metropolis.scss
|
||||
218
slides/_extensions/metropolis-theme/metropolis.scss
Normal file
218
slides/_extensions/metropolis-theme/metropolis.scss
Normal file
@ -0,0 +1,218 @@
|
||||
/*-- scss:defaults --*/
|
||||
|
||||
// fonts
|
||||
@import url(https://fonts.googleapis.com/css?family=Fira+Sans:300,300i,400,400i,500,500i,700,700i);
|
||||
@import url(https://cdn.rawgit.com/tonsky/FiraCode/1.204/distr/fira_code.css);
|
||||
@import url("https://fonts.googleapis.com/css?family=Roboto+Mono|JetBrains+Mono&display=swap");
|
||||
@import url("https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap");
|
||||
|
||||
$font-family-sans-serif: "Roboto", "Fira Sans", "Droid Serif", serif !default;
|
||||
$font-family-monospace: "JetBrains Mono", "Fira Code", monospace;
|
||||
$presentation-font-size-root: 32px;
|
||||
$presentation-line-height: 1.5em;
|
||||
$presentation-heading-font-weight: 400;
|
||||
|
||||
// colors
|
||||
$body-bg: #fafafa !default;
|
||||
$body-color: #000 !default;
|
||||
// $link-color: #EB811B !default;
|
||||
$selection-bg: #26351c;
|
||||
|
||||
// headings
|
||||
// $presentation-heading-font: "Palatino Linotype", "Book Antiqua", Palatino,
|
||||
// FreeSerif, serif !default;
|
||||
// $presentation-heading-color: #383d3d !default;
|
||||
|
||||
/*-- scss:rules --*/
|
||||
|
||||
.reveal a {
|
||||
line-height: 1.5em;
|
||||
color: #eb811b;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.reveal .footer a {
|
||||
color: #eb811b !important;
|
||||
}
|
||||
|
||||
.reveal p {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.reveal .slide ul li,
|
||||
.reveal .slide ol li {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
// maximum height of code blocks before scrolling is used
|
||||
.reveal pre.sourceCode code {
|
||||
max-height: 700px; // default 500
|
||||
}
|
||||
|
||||
// title slide
|
||||
.title-slide {
|
||||
background-color: #fafafa;
|
||||
border-top: 80px solid #fafafa;
|
||||
}
|
||||
|
||||
h1.title {
|
||||
color: #1a292c;
|
||||
font-size: 45px;
|
||||
text-shadow: none;
|
||||
font-weight: 400;
|
||||
text-align: left;
|
||||
margin-left: 15px;
|
||||
padding-top: 80px;
|
||||
}
|
||||
p.subtitle {
|
||||
// margin-top: -10px;
|
||||
// padding-bottom: -20px;
|
||||
color: #1a292c;
|
||||
text-shadow: none;
|
||||
font-weight: 300;
|
||||
font-size: 40px;
|
||||
text-align: left;
|
||||
margin-left: 15px;
|
||||
}
|
||||
p.author {
|
||||
color: #1a292c;
|
||||
text-shadow: none;
|
||||
font-weight: 300;
|
||||
font-size: 30px;
|
||||
text-align: left;
|
||||
margin-left: 15px;
|
||||
margin-bottom: -10px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
p.date {
|
||||
color: #1a292c;
|
||||
text-shadow: none;
|
||||
font-weight: 300;
|
||||
font-size: 30px;
|
||||
text-align: left;
|
||||
margin-left: 15px;
|
||||
// margin-bottom: -30px;
|
||||
}
|
||||
|
||||
p.subtitle:after {
|
||||
content: "";
|
||||
display: block;
|
||||
border: none;
|
||||
background-color: #eb811b;
|
||||
color: #eb811b;
|
||||
height: 1px;
|
||||
margin: 25px 0 25px;
|
||||
}
|
||||
|
||||
// Section break slide
|
||||
hr,
|
||||
h1::after {
|
||||
content: "";
|
||||
display: block;
|
||||
border: none;
|
||||
background-color: #eb811b;
|
||||
color: #eb811b;
|
||||
height: 1px;
|
||||
margin: 1em 10px 0 10px;
|
||||
}
|
||||
|
||||
// Override h1 style for title slide (remove section break slide style)
|
||||
hr,
|
||||
h1.title::after {
|
||||
content: "";
|
||||
display: block;
|
||||
border: none;
|
||||
background-color: transparent !important;
|
||||
color: transparent !important;
|
||||
height: 0px;
|
||||
margin: 0px !important;
|
||||
}
|
||||
|
||||
h2::after.title {
|
||||
margin: 10px 15px 35px 0;
|
||||
}
|
||||
|
||||
.reveal .slide-number a {
|
||||
font-size: 120%;
|
||||
background-color: #fafafa;
|
||||
border-radius: 12px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
// inline
|
||||
.reveal code {
|
||||
font-size: 70%;
|
||||
background-color: #afb8c133;
|
||||
color: #000;
|
||||
padding: 4px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
// code blocks
|
||||
.reveal div.sourceCode pre code {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
// code output
|
||||
.reveal pre code {
|
||||
font-size: 100%;
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
.colored-column {
|
||||
border: 2px solid red;
|
||||
border-radius: 6px !important;
|
||||
padding: 10px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.column {
|
||||
// #column;
|
||||
// border: 2px solid red;
|
||||
border-radius: 10px !important;
|
||||
padding: 10px;
|
||||
margin: 5px;
|
||||
// background-color: #ededed;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.reveal h2 {
|
||||
background-color: #23373b;
|
||||
padding: 5px 0px 5px 10px;
|
||||
color: #fafafa;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.small-font {
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
iframe {
|
||||
display: block;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
//
|
||||
.reveal .slide-menu-button .fa-bars::before {
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="rgb(35, 55, 59)" class="bi bi-list" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"/></svg>');
|
||||
}
|
||||
|
||||
.reveal .slide-chalkboard-buttons .fa-easel2::before {
|
||||
padding-bottom: 6px;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="rgb(35, 55, 59)" class="bi bi-easel2" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0a.5.5 0 0 1 .447.276L8.81 1h4.69A1.5 1.5 0 0 1 15 2.5V11h.5a.5.5 0 0 1 0 1h-2.86l.845 3.379a.5.5 0 0 1-.97.242L12.11 14H3.89l-.405 1.621a.5.5 0 0 1-.97-.242L3.36 12H.5a.5.5 0 0 1 0-1H1V2.5A1.5 1.5 0 0 1 2.5 1h4.691l.362-.724A.5.5 0 0 1 8 0ZM2 11h12V2.5a.5.5 0 0 0-.5-.5h-11a.5.5 0 0 0-.5.5V11Zm9.61 1H4.39l-.25 1h7.72l-.25-1Z"/></svg>');
|
||||
}
|
||||
|
||||
.reveal .slide-chalkboard-buttons .fa-brush::before {
|
||||
padding-bottom: 6px;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="rgb(35, 55, 59)" class="bi bi-brush" viewBox="0 0 16 16"><path d="M15.825.12a.5.5 0 0 1 .132.584c-1.53 3.43-4.743 8.17-7.095 10.64a6.067 6.067 0 0 1-2.373 1.534c-.018.227-.06.538-.16.868-.201.659-.667 1.479-1.708 1.74a8.118 8.118 0 0 1-3.078.132 3.659 3.659 0 0 1-.562-.135 1.382 1.382 0 0 1-.466-.247.714.714 0 0 1-.204-.288.622.622 0 0 1 .004-.443c.095-.245.316-.38.461-.452.394-.197.625-.453.867-.826.095-.144.184-.297.287-.472l.117-.198c.151-.255.326-.54.546-.848.528-.739 1.201-.925 1.746-.896.126.007.243.025.348.048.062-.172.142-.38.238-.608.261-.619.658-1.419 1.187-2.069 2.176-2.67 6.18-6.206 9.117-8.104a.5.5 0 0 1 .596.04zM4.705 11.912a1.23 1.23 0 0 0-.419-.1c-.246-.013-.573.05-.879.479-.197.275-.355.532-.5.777l-.105.177c-.106.181-.213.362-.32.528a3.39 3.39 0 0 1-.76.861c.69.112 1.736.111 2.657-.12.559-.139.843-.569.993-1.06a3.122 3.122 0 0 0 .126-.75l-.793-.792zm1.44.026c.12-.04.277-.1.458-.183a5.068 5.068 0 0 0 1.535-1.1c1.9-1.996 4.412-5.57 6.052-8.631-2.59 1.927-5.566 4.66-7.302 6.792-.442.543-.795 1.243-1.042 1.826-.121.288-.214.54-.275.72v.001l.575.575zm-4.973 3.04.007-.005a.031.031 0 0 1-.007.004zm3.582-3.043.002.001h-.002z"/></svg>');
|
||||
}
|
||||
|
||||
.reveal .progress {
|
||||
color: #23373b;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
title: Include Code Files
|
||||
author: Bruno Beaufils
|
||||
version: 1.0.0
|
||||
quarto-required: ">=1.2"
|
||||
contributes:
|
||||
filters:
|
||||
- include-code-files.lua
|
||||
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
--- include-code-files.lua – filter to include code from source files
|
||||
---
|
||||
--- Copyright: © 2020 Bruno BEAUFILS
|
||||
--- License: MIT – see LICENSE file for details
|
||||
|
||||
--- Dedent a line
|
||||
local function dedent(line, n)
|
||||
return line:sub(1, n):gsub(" ", "") .. line:sub(n + 1)
|
||||
end
|
||||
|
||||
--- Find snippet start and end.
|
||||
--
|
||||
-- Use this to populate startline and endline.
|
||||
-- This should work like pandocs snippet functionality: https://github.com/owickstrom/pandoc-include-code/tree/master
|
||||
local function snippet(cb, fh)
|
||||
if not cb.attributes.snippet then
|
||||
return
|
||||
end
|
||||
|
||||
-- Cannot capture enum: http://lua-users.org/wiki/PatternsTutorial
|
||||
local comment
|
||||
local comment_stop = ""
|
||||
if
|
||||
string.match(cb.attributes.include, ".py$")
|
||||
or string.match(cb.attributes.include, ".jl$")
|
||||
or string.match(cb.attributes.include, ".r$")
|
||||
then
|
||||
comment = "#"
|
||||
elseif string.match(cb.attributes.include, ".o?js$") or string.match(cb.attributes.include, ".css$") then
|
||||
comment = "//"
|
||||
elseif string.match(cb.attributes.include, ".lua$") then
|
||||
comment = "--"
|
||||
elseif string.match(cb.attributes.include, ".html$") then
|
||||
comment = "<!%-%-"
|
||||
comment_stop = " *%-%->"
|
||||
else
|
||||
-- If not known assume that it is something one or two long and not alphanumeric.
|
||||
comment = "%W%W?"
|
||||
end
|
||||
|
||||
local p_start = string.format("^ *%s start snippet %s%s", comment, cb.attributes.snippet, comment_stop)
|
||||
local p_stop = string.format("^ *%s end snippet %s%s", comment, cb.attributes.snippet, comment_stop)
|
||||
local start, stop = nil, nil
|
||||
|
||||
-- Cannot use pairs.
|
||||
local line_no = 1
|
||||
for line in fh:lines() do
|
||||
if start == nil then
|
||||
if string.match(line, p_start) then
|
||||
start = line_no + 1
|
||||
end
|
||||
elseif stop == nil then
|
||||
if string.match(line, p_stop) then
|
||||
stop = line_no - 1
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
line_no = line_no + 1
|
||||
end
|
||||
|
||||
-- Reset so nothing is broken later on.
|
||||
fh:seek("set")
|
||||
|
||||
-- If start and stop not found, just continue
|
||||
if start == nil or stop == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
cb.attributes.startLine = tostring(start)
|
||||
cb.attributes.endLine = tostring(stop)
|
||||
end
|
||||
|
||||
--- Filter function for code blocks
|
||||
local function transclude(cb)
|
||||
if cb.attributes.include then
|
||||
local content = ""
|
||||
local fh = io.open(cb.attributes.include)
|
||||
if not fh then
|
||||
io.stderr:write("Cannot open file " .. cb.attributes.include .. " | Skipping includes\n")
|
||||
else
|
||||
local number = 1
|
||||
local start = 1
|
||||
|
||||
-- change hyphenated attributes to PascalCase
|
||||
for i, pascal in pairs({ "startLine", "endLine" }) do
|
||||
local hyphen = pascal:gsub("%u", "-%0"):lower()
|
||||
if cb.attributes[hyphen] then
|
||||
cb.attributes[pascal] = cb.attributes[hyphen]
|
||||
cb.attributes[hyphen] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Overwrite startLine and stopLine with the snippet if any.
|
||||
snippet(cb, fh)
|
||||
|
||||
if cb.attributes.startLine then
|
||||
cb.attributes.startFrom = cb.attributes.startLine
|
||||
start = tonumber(cb.attributes.startLine)
|
||||
end
|
||||
|
||||
for line in fh:lines("L") do
|
||||
if cb.attributes.dedent then
|
||||
line = dedent(line, cb.attributes.dedent)
|
||||
end
|
||||
if number >= start then
|
||||
if not cb.attributes.endLine or number <= tonumber(cb.attributes.endLine) then
|
||||
content = content .. line
|
||||
end
|
||||
end
|
||||
number = number + 1
|
||||
end
|
||||
|
||||
fh:close()
|
||||
end
|
||||
|
||||
-- remove key-value pair for used keys
|
||||
cb.attributes.include = nil
|
||||
cb.attributes.startLine = nil
|
||||
cb.attributes.endLine = nil
|
||||
cb.attributes.dedent = nil
|
||||
|
||||
-- return final code block
|
||||
return pandoc.CodeBlock(content, cb.attr)
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{ CodeBlock = transclude },
|
||||
}
|
||||
Reference in New Issue
Block a user