Skip to content

Commit

Permalink
add modern node addons ACCU version
Browse files Browse the repository at this point in the history
  • Loading branch information
dvirtz committed Apr 21, 2024
1 parent 2c8d56b commit 3a83f3e
Show file tree
Hide file tree
Showing 19 changed files with 1,152 additions and 257 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
.DS_Store
build/
dist/
.site/
744 changes: 672 additions & 72 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "index.js",
"scripts": {
"present": "reveal-md slides/index.md -w",
"generate": "reveal-md slides --static .site",
"generate": "rimraf .site && reveal-md slides --static .site",
"test": "mocha",
"spellcheck": "cspell slides/**/*.md",
"prepare": "husky"
Expand All @@ -30,10 +30,11 @@
"husky": "^9.0.11",
"jquery": "^3.7.1",
"mocha": "^10.4.0",
"reveal-test": "^3.2.1"
"reveal-test": "^3.3.0",
"rimraf": "^5.0.5"
},
"dependencies": {
"reveal-compiler-explorer": "^3.2.1",
"reveal-compiler-explorer": "^3.3.0",
"reveal-md": "^5.5.2",
"reveal-pdf": "^1.0.1",
"reveal-timeline": "^1.2.1",
Expand Down
130 changes: 0 additions & 130 deletions plugins/embed-code/embed-code.js

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/load-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ if (typeof RevealTimeline !== 'undefined') {
if (typeof RevealPdf !== 'undefined') {
options.plugins.push(RevealPdf)
}
if (typeof EmbedCode !== 'undefined') {
options.plugins.splice(options.plugins.indexOf(RevealHighlight), 0, EmbedCode);
}
29 changes: 14 additions & 15 deletions scripts/preprocess.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { readFileSync } = require('fs');
const { readFile } = require('fs').promises;
const path = require('path');
const { getInitialDir } = require('reveal-md/lib/config');
const os = require('os')

const LINE_SEPARATOR = '\n';
const LINE_SEPARATOR = os.EOL;
const FILE_REF_REGEX = /^FILE: (.+)$/;
const SVG_START = /<svg.*>/;
const SVG_END = /<\/svg>/;
Expand All @@ -11,17 +11,17 @@ const SVG_URL = /url\(#([^)]+)\)/;
const SLIDES = /^# Slides/;
const SLIDE_REF = /\.md\)/mg;

const loadFileContent = (filePath, options, svgState) => {
const contents = readFileSync(path.join(options.initialDir, filePath), 'utf-8');
const loadFileContent = async (filePath, options, svgState) => {
const contents = await readFile(path.join(options.initialDir, filePath), 'utf-8');
if (path.extname(filePath) === '.md') {
return preprocessMarkdown(contents, options, svgState);
return await preprocessMarkdown(contents, options, svgState);
}
return contents;
};

const processLine = (line, options, svgState) => {
const processLine = async (line, options, svgState) => {
for (const m of (line.match(FILE_REF_REGEX) || []).slice(1)) {
return loadFileContent(m, options, svgState);
return await loadFileContent(m, options, svgState);
}

if (svgState.insideSvg) {
Expand All @@ -38,11 +38,10 @@ const processLine = (line, options, svgState) => {
return line;
}

const preprocessMarkdown = (markdown, options, svgState) => {
return markdown
.split(LINE_SEPARATOR)
.map(line => processLine(line, options, svgState))
.join(LINE_SEPARATOR);
const preprocessMarkdown = async (markdown, options, svgState) => {
const lines = markdown.split(LINE_SEPARATOR);
const processedLines = await Promise.all(lines.map(line => processLine(line, options, svgState)));
return processedLines.join(LINE_SEPARATOR);
}

const preprocess = async (markdown, options) => {
Expand All @@ -55,8 +54,8 @@ const preprocess = async (markdown, options) => {
return markdown.replace(SLIDE_REF, '.html)');
}

options.initialDir = await getInitialDir();
let res = preprocessMarkdown(markdown, options, svgState);
options.initialDir = path.join(path.dirname(__dirname), 'slides');
let res = await preprocessMarkdown(markdown, options, svgState);
return res;
}

Expand Down
4 changes: 3 additions & 1 deletion slides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

<div class="fragment fade-out" data-fragment-index="0">

- [Modern C++ addons for node.js](modern-js-addons/js_addons.md)
- Modern C++ addons for node.js
- [March 2024, Core C++](modern-js-addons/js_addons.md)
- [April 2004, ACCU](modern-js-addons/accu.md)
- C++23 ranges: conceptual changes and useful practicalities,
- [April 2023, ACCU](ranges_23/ranges.md)
- [June 2023, Core C++](ranges_23/corecpp.md)
Expand Down
Loading

0 comments on commit 3a83f3e

Please sign in to comment.