Skip to content

Commit

Permalink
Version for presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cjrace committed Nov 20, 2024
1 parent 5ce0796 commit 7a80c6b
Show file tree
Hide file tree
Showing 38 changed files with 606 additions and 566 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
.Ruserdata

/.quarto/

README.html
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Test that? No literally, testthat... (Slides)

This is a slide pack used for a coffee and coding demo showing off some of ways you can do pass / fail tests in R code, R Shiny apps and R packages.

## Run locally

Install [Quarto from their website](https://quarto.org/docs/get-started/).

Then load dependencies using renv:

```
renv::restore()
```

Then build the slides using (or the Render button if in R Studio):

```
quarto::quarto_preview()
```
Binary file added docs/img/qa-lity_street.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
560 changes: 193 additions & 367 deletions docs/index.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/index_files/libs/quarto-html/quarto-html.min.css

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/index_files/libs/revealjs/dist/reveal.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/index_files/libs/revealjs/dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index_files/libs/revealjs/dist/reveal.esm.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/index_files/libs/revealjs/dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index_files/libs/revealjs/dist/reveal.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions docs/index_files/libs/revealjs/dist/theme/quarto.css

This file was deleted.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/index_files/libs/revealjs/plugin/highlight/highlight.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index_files/libs/revealjs/plugin/highlight/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Plugin = {
hljs,

/**
* Highlights code blocks withing the given deck.
* Highlights code blocks within the given deck.
*
* Note that this can be called multiple times if
* there are multiple presentations on one page.
Expand Down Expand Up @@ -138,7 +138,7 @@ const Plugin = {

// Scroll highlights into view as we step through them
fragmentBlock.addEventListener( 'visible', Plugin.scrollHighlightedLineIntoView.bind( Plugin, fragmentBlock, scrollState ) );
fragmentBlock.addEventListener( 'hidden', Plugin.scrollHighlightedLineIntoView.bind( Plugin, fragmentBlock.previousSibling, scrollState ) );
fragmentBlock.addEventListener( 'hidden', Plugin.scrollHighlightedLineIntoView.bind( Plugin, fragmentBlock.previousElementSibling, scrollState ) );

} );

Expand Down

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion docs/index_files/libs/revealjs/plugin/markdown/markdown.js

Large diffs are not rendered by default.

112 changes: 64 additions & 48 deletions docs/index_files/libs/revealjs/plugin/markdown/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
import { marked } from 'marked';

const DEFAULT_SLIDE_SEPARATOR = '\r?\n---\r?\n',
DEFAULT_NOTES_SEPARATOR = 'notes?:',
DEFAULT_VERTICAL_SEPARATOR = null,
DEFAULT_NOTES_SEPARATOR = '^\s*notes?:',
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';

const SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__';

const CODE_LINE_NUMBER_REGEX = /\[([\s\d,|-]*)\]/;
// match an optional line number offset and highlight line numbers
// [<line numbers>] or [<offset>: <line numbers>]
const CODE_LINE_NUMBER_REGEX = /\[\s*((\d*):)?\s*([\s\d,|-]*)\]/;

const HTML_ESCAPE_MAP = {
'&': '&amp;',
Expand All @@ -35,22 +38,22 @@ const Plugin = () => {
function getMarkdownFromSlide( section ) {

// look for a <script> or <textarea data-template> wrapper
var template = section.querySelector( '[data-template]' ) || section.querySelector( 'script' );
const template = section.querySelector( '[data-template]' ) || section.querySelector( 'script' );

// strip leading whitespace so it isn't evaluated as code
var text = ( template || section ).textContent;
let text = ( template || section ).textContent;

// restore script end tags
text = text.replace( new RegExp( SCRIPT_END_PLACEHOLDER, 'g' ), '</script>' );

var leadingWs = text.match( /^\n?(\s*)/ )[1].length,
const leadingWs = text.match( /^\n?(\s*)/ )[1].length,
leadingTabs = text.match( /^\n?(\t*)/ )[1].length;

if( leadingTabs > 0 ) {
text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}','g'), '\n' );
text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}(.*)','g'), function(m, p1) { return '\n' + p1 ; } );
}
else if( leadingWs > 1 ) {
text = text.replace( new RegExp('\\n? {' + leadingWs + '}', 'g'), '\n' );
text = text.replace( new RegExp('\\n? {' + leadingWs + '}(.*)', 'g'), function(m, p1) { return '\n' + p1 ; } );
}

return text;
Expand All @@ -65,11 +68,11 @@ const Plugin = () => {
*/
function getForwardedAttributes( section ) {

var attributes = section.attributes;
var result = [];
const attributes = section.attributes;
const result = [];

for( var i = 0, len = attributes.length; i < len; i++ ) {
var name = attributes[i].name,
for( let i = 0, len = attributes.length; i < len; i++ ) {
const name = attributes[i].name,
value = attributes[i].value;

// disregard attributes that are used for markdown loading/parsing
Expand All @@ -92,10 +95,12 @@ const Plugin = () => {
* values for what's not defined.
*/
function getSlidifyOptions( options ) {
const markdownConfig = deck?.getConfig?.().markdown;

options = options || {};
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
options.separator = options.separator || markdownConfig?.separator || DEFAULT_SLIDE_SEPARATOR;
options.verticalSeparator = options.verticalSeparator || markdownConfig?.verticalSeparator || DEFAULT_VERTICAL_SEPARATOR;
options.notesSeparator = options.notesSeparator || markdownConfig?.notesSeparator || DEFAULT_NOTES_SEPARATOR;
options.attributes = options.attributes || '';

return options;
Expand All @@ -109,7 +114,7 @@ const Plugin = () => {

options = getSlidifyOptions( options );

var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) );
const notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) );

if( notesMatch.length === 2 ) {
content = notesMatch[0] + '<aside class="notes">' + marked(notesMatch[1].trim()) + '</aside>';
Expand All @@ -131,10 +136,10 @@ const Plugin = () => {

options = getSlidifyOptions( options );

var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
const separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
horizontalSeparatorRegex = new RegExp( options.separator );

var matches,
let matches,
lastIndex = 0,
isHorizontal,
wasHorizontal = true,
Expand All @@ -143,7 +148,7 @@ const Plugin = () => {

// iterate until all blocks between separators are stacked up
while( matches = separatorRegex.exec( markdown ) ) {
var notes = null;
const notes = null;

// determine direction (horizontal by default)
isHorizontal = horizontalSeparatorRegex.test( matches[0] );
Expand Down Expand Up @@ -172,10 +177,10 @@ const Plugin = () => {
// add the remaining slide
( wasHorizontal ? sectionStack : sectionStack[sectionStack.length-1] ).push( markdown.substring( lastIndex ) );

var markdownSections = '';
let markdownSections = '';

// flatten the hierarchical stack, and insert <section data-markdown> tags
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
for( let i = 0, len = sectionStack.length; i < len; i++ ) {
// vertical
if( sectionStack[i] instanceof Array ) {
markdownSections += '<section '+ options.attributes +'>';
Expand Down Expand Up @@ -204,7 +209,7 @@ const Plugin = () => {

return new Promise( function( resolve ) {

var externalPromises = [];
const externalPromises = [];

[].slice.call( scope.querySelectorAll( 'section[data-markdown]:not([data-markdown-parsed])') ).forEach( function( section, i ) {

Expand Down Expand Up @@ -257,13 +262,13 @@ const Plugin = () => {

return new Promise( function( resolve, reject ) {

var xhr = new XMLHttpRequest(),
const xhr = new XMLHttpRequest(),
url = section.getAttribute( 'data-markdown' );

var datacharset = section.getAttribute( 'data-charset' );
const datacharset = section.getAttribute( 'data-charset' );

// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
if( datacharset != null && datacharset != '' ) {
if( datacharset !== null && datacharset !== '' ) {
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
}

Expand Down Expand Up @@ -308,17 +313,17 @@ const Plugin = () => {
*/
function addAttributeInElement( node, elementTarget, separator ) {

var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"]+?)\"|(data-[^\"= ]+?)(?=[\" ])", 'mg' );
var nodeValue = node.nodeValue;
var matches,
const markdownClassesInElementsRegex = new RegExp( separator, 'mg' );
const markdownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"]+?)\"|(data-[^\"= ]+?)(?=[\" ])", 'mg' );
let nodeValue = node.nodeValue;
let matches,
matchesClass;
if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
if( matches = markdownClassesInElementsRegex.exec( nodeValue ) ) {

var classes = matches[1];
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
const classes = matches[1];
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( markdownClassesInElementsRegex.lastIndex );
node.nodeValue = nodeValue;
while( matchesClass = mardownClassRegex.exec( classes ) ) {
while( matchesClass = markdownClassRegex.exec( classes ) ) {
if( matchesClass[2] ) {
elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
} else {
Expand All @@ -336,34 +341,34 @@ const Plugin = () => {
*/
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {

if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
var previousParentElement = element;
for( var i = 0; i < element.childNodes.length; i++ ) {
var childElement = element.childNodes[i];
if ( element !== null && element.childNodes !== undefined && element.childNodes.length > 0 ) {
let previousParentElement = element;
for( let i = 0; i < element.childNodes.length; i++ ) {
const childElement = element.childNodes[i];
if ( i > 0 ) {
var j = i - 1;
let j = i - 1;
while ( j >= 0 ) {
var aPreviousChildElement = element.childNodes[j];
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) {
const aPreviousChildElement = element.childNodes[j];
if ( typeof aPreviousChildElement.setAttribute === 'function' && aPreviousChildElement.tagName !== "BR" ) {
previousParentElement = aPreviousChildElement;
break;
}
j = j - 1;
}
}
var parentSection = section;
if( childElement.nodeName == "section" ) {
let parentSection = section;
if( childElement.nodeName === "section" ) {
parentSection = childElement ;
previousParentElement = childElement ;
}
if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) {
if ( typeof childElement.setAttribute === 'function' || childElement.nodeType === Node.COMMENT_NODE ) {
addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
}
}
}

if ( element.nodeType == Node.COMMENT_NODE ) {
if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) {
if ( element.nodeType === Node.COMMENT_NODE ) {
if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) === false ) {
addAttributeInElement( element, section, separatorSectionAttributes );
}
}
Expand All @@ -375,14 +380,14 @@ const Plugin = () => {
*/
function convertSlides() {

var sections = deck.getRevealElement().querySelectorAll( '[data-markdown]:not([data-markdown-parsed])');
const sections = deck.getRevealElement().querySelectorAll( '[data-markdown]:not([data-markdown-parsed])');

[].slice.call( sections ).forEach( function( section ) {

section.setAttribute( 'data-markdown-parsed', true )

var notes = section.querySelector( 'aside.notes' );
var markdown = getMarkdownFromSlide( section );
const notes = section.querySelector( 'aside.notes' );
const markdown = getMarkdownFromSlide( section );

section.innerHTML = marked( markdown );
addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) ||
Expand Down Expand Up @@ -429,14 +434,23 @@ const Plugin = () => {
renderer.code = ( code, language ) => {

// Off by default
let lineNumberOffset = '';
let lineNumbers = '';

// Users can opt in to show line numbers and highlight
// specific lines.
// ```javascript [] show line numbers
// ```javascript [1,4-8] highlights lines 1 and 4-8
// optional line number offset:
// ```javascript [25: 1,4-8] start line numbering at 25,
// highlights lines 1 (numbered as 25) and 4-8 (numbered as 28-32)
if( CODE_LINE_NUMBER_REGEX.test( language ) ) {
lineNumbers = language.match( CODE_LINE_NUMBER_REGEX )[1].trim();
let lineNumberOffsetMatch = language.match( CODE_LINE_NUMBER_REGEX )[2];
if (lineNumberOffsetMatch){
lineNumberOffset = `data-ln-start-from="${lineNumberOffsetMatch.trim()}"`;
}

lineNumbers = language.match( CODE_LINE_NUMBER_REGEX )[3].trim();
lineNumbers = `data-line-numbers="${lineNumbers}"`;
language = language.replace( CODE_LINE_NUMBER_REGEX, '' ).trim();
}
Expand All @@ -446,7 +460,9 @@ const Plugin = () => {
// highlight.js is able to read it
code = escapeForHTML( code );

return `<pre><code ${lineNumbers} class="${language}">${code}</code></pre>`;
// return `<pre><code ${lineNumbers} class="${language}">${code}</code></pre>`;

return `<pre><code ${lineNumbers} ${lineNumberOffset} class="${language}">${code}</code></pre>`;
};
}

Expand Down
7 changes: 6 additions & 1 deletion docs/index_files/libs/revealjs/plugin/math/math.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index_files/libs/revealjs/plugin/math/math.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index_files/libs/revealjs/plugin/math/mathjax3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const MathJax3 = () => {
ready: () => {
MathJax.startup.defaultReady();
MathJax.startup.promise.then(() => {
Reveal.layout();
deck.layout();
});
}
}
Expand Down Expand Up @@ -66,7 +66,7 @@ export const MathJax3 = () => {

loadScript( url, function() {
// Reprocess equations in slides when they turn visible
Reveal.addEventListener( 'slidechanged', function( event ) {
deck.addEventListener( 'slidechanged', function( event ) {
MathJax.typeset();
} );
} );
Expand Down
2 changes: 1 addition & 1 deletion docs/index_files/libs/revealjs/plugin/notes/notes.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index_files/libs/revealjs/plugin/notes/notes.js

Large diffs are not rendered by default.

Loading

0 comments on commit 7a80c6b

Please sign in to comment.