Commit f505b8f0 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Permet d'utiliser un répertoire local pour reveal.js.

parent 95709e58
......@@ -28,7 +28,7 @@ export const assets = () =>
export const prez = () =>
src(PREZ_GLOB, { since: lastRun(prez) })
.pipe(index())
.pipe(pandoc({ variables: { "revealjs-url": REVEALJS_URL } }))
.pipe(pandoc({ revealJSURL: REVEALJS_URL }))
.pipe(dest(DEST_DIR));
export const graphs = () =>
......
import gulpPandoc from "gulp-pandoc";
import { callbackify } from "util";
import exec from "./exec";
import logger from "gulplog";
import { merge } from "merge-anything";
import { obj } from "through2";
import path from "path";
const PLUGIN_NAME = "pandoc";
const DEFAULTS = {
slideLevel: 2,
tocDepth: 2,
revealJSURL: "reveal.js",
variables: {
"revealjs-url": "reveal.js",
width: 1024,
height: 768,
navigationMode: "linear",
......@@ -16,21 +22,63 @@ const DEFAULTS = {
},
};
/**
* @param {string} url
* @return {function}
*/
export function getRevealJSResolver(url) {
if (url.match(/^(https?:)?\/\//i)) {
return () => url;
}
return (output) => path.relative(path.dirname(output.relative), url);
}
export default function pandoc(options = {}) {
const { slideLevel, tocDepth, variables } = merge({}, DEFAULTS, options);
return gulpPandoc({
from:
"markdown+backtick_code_blocks+pandoc_title_block+yaml_metadata_block",
to: "revealjs",
ext: ".html",
args: [
"--standalone",
`--slide-level=${slideLevel}`,
"--toc",
`--toc-depth=${tocDepth}`,
...Object.getOwnPropertyNames(variables).map(
(name) => `--variable=${name}:${variables[name]}`
),
],
});
const { slideLevel, tocDepth, revealJSURL, variables } = merge(
{},
DEFAULTS,
options
);
const revealJSURLResolver = getRevealJSResolver(revealJSURL);
return obj(
callbackify(
/**
* @param {File} input
*/
async function (input) {
const output = input.clone({ contents: false });
output.extname = ".html";
output.contents = null;
const args = [
"--from=markdown+backtick_code_blocks+pandoc_title_block+yaml_metadata_block",
"--to=revealjs",
"--standalone",
`--slide-level=${slideLevel}`,
"--toc",
`--toc-depth=${tocDepth}`,
`--variable=revealjs-url:${revealJSURLResolver(output)}`,
...Object.getOwnPropertyNames(variables).map(
(name) => `--variable=${name}:${variables[name]}`
),
input.path,
];
const { stdout } = await exec(PLUGIN_NAME, "pandoc", args, {
encoding: "buffer",
});
output.contents = stdout;
logger.info(
"%s: %s -> %s",
PLUGIN_NAME,
input.relative,
output.relative
);
this.push(output);
}
)
);
}
......@@ -1886,15 +1886,6 @@
"assert-plus": "^1.0.0"
}
},
"dateformat": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz",
"integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=",
"requires": {
"get-stdin": "^4.0.1",
"meow": "^3.3.0"
}
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
......@@ -4610,61 +4601,6 @@
}
}
},
"gulp-pandoc": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/gulp-pandoc/-/gulp-pandoc-0.2.2.tgz",
"integrity": "sha1-WM8CwpTWaPGc4NGFAIT+w4Yh09U=",
"requires": {
"gulp-util": "~2.2.14",
"pdc": "~0.2.2",
"through2": "~0.4.1"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"object-keys": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz",
"integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY="
},
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"through2": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.4.2.tgz",
"integrity": "sha1-2/WGYDEVHsg1K7bE22SiKSqEC5s=",
"requires": {
"readable-stream": "~1.0.17",
"xtend": "~2.1.1"
}
},
"xtend": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz",
"integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=",
"requires": {
"object-keys": "~0.4.0"
}
}
}
},
"gulp-rename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-2.0.0.tgz",
......@@ -5216,119 +5152,6 @@
"vinyl-sourcemaps-apply": "^0.2.1"
}
},
"gulp-util": {
"version": "2.2.20",
"resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz",
"integrity": "sha1-1xRuVyiRC9jwR6awseVJvCLb1kw=",
"requires": {
"chalk": "^0.5.0",
"dateformat": "^1.0.7-1.2.3",
"lodash._reinterpolate": "^2.4.1",
"lodash.template": "^2.4.1",
"minimist": "^0.2.0",
"multipipe": "^0.1.0",
"through2": "^0.5.0",
"vinyl": "^0.2.1"
},
"dependencies": {
"ansi-regex": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz",
"integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk="
},
"ansi-styles": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz",
"integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94="
},
"chalk": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz",
"integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=",
"requires": {
"ansi-styles": "^1.1.0",
"escape-string-regexp": "^1.0.0",
"has-ansi": "^0.1.0",
"strip-ansi": "^0.3.0",
"supports-color": "^0.2.0"
}
},
"clone-stats": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz",
"integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE="
},
"has-ansi": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz",
"integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=",
"requires": {
"ansi-regex": "^0.2.0"
}
},
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"minimist": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.1.tgz",
"integrity": "sha512-GY8fANSrTMfBVfInqJAY41QkOM+upUTytK1jZ0c8+3HdHrJxBJ3rF5i9moClXTE8uUSnUo8cAsCoxDXvSY4DHg=="
},
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"strip-ansi": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz",
"integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=",
"requires": {
"ansi-regex": "^0.2.1"
}
},
"supports-color": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz",
"integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo="
},
"through2": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz",
"integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=",
"requires": {
"readable-stream": "~1.0.17",
"xtend": "~3.0.0"
}
},
"vinyl": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.2.3.tgz",
"integrity": "sha1-vKk4IJWC7FpJrVOKAPofEl5RMlI=",
"requires": {
"clone-stats": "~0.0.1"
}
},
"xtend": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz",
"integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo="
}
}
},
"gulp-zip": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/gulp-zip/-/gulp-zip-5.0.1.tgz",
......@@ -6716,44 +6539,16 @@
"resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz",
"integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc="
},
"lodash._escapehtmlchar": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash._escapehtmlchar/-/lodash._escapehtmlchar-2.4.1.tgz",
"integrity": "sha1-32fDu2t+jh6DGrSL+geVuSr+iZ0=",
"requires": {
"lodash._htmlescapes": "~2.4.1"
}
},
"lodash._escapestringchar": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash._escapestringchar/-/lodash._escapestringchar-2.4.1.tgz",
"integrity": "sha1-7P4iYYoq3lC/7qQ5N+Ud9m8O23I="
},
"lodash._getnative": {
"version": "3.9.1",
"resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz",
"integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U="
},
"lodash._htmlescapes": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash._htmlescapes/-/lodash._htmlescapes-2.4.1.tgz",
"integrity": "sha1-MtFL8IRLbeb4tioFG09nwii2JMs="
},
"lodash._isiterateecall": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz",
"integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw="
},
"lodash._isnative": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash._isnative/-/lodash._isnative-2.4.1.tgz",
"integrity": "sha1-PqZAS3hKe+g2x7V1gOHN95sUgyw="
},
"lodash._objecttypes": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash._objecttypes/-/lodash._objecttypes-2.4.1.tgz",
"integrity": "sha1-fAt/admKH3ZSn4kLDNsbTf7BHBE="
},
"lodash._reescape": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz",
......@@ -6764,52 +6559,11 @@
"resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz",
"integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0="
},
"lodash._reinterpolate": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-2.4.1.tgz",
"integrity": "sha1-TxInqlqHEfxjL1sHofRgequLMiI="
},
"lodash._reunescapedhtml": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash._reunescapedhtml/-/lodash._reunescapedhtml-2.4.1.tgz",
"integrity": "sha1-dHxPxAED6zu4oJduVx96JlnpO6c=",
"requires": {
"lodash._htmlescapes": "~2.4.1",
"lodash.keys": "~2.4.1"
}
},
"lodash._root": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz",
"integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI="
},
"lodash._shimkeys": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash._shimkeys/-/lodash._shimkeys-2.4.1.tgz",
"integrity": "sha1-bpzJZm/wgfC1psl4uD4kLmlJ0gM=",
"requires": {
"lodash._objecttypes": "~2.4.1"
}
},
"lodash.defaults": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-2.4.1.tgz",
"integrity": "sha1-p+iIXwXmiFEUS24SqPNngCa8TFQ=",
"requires": {
"lodash._objecttypes": "~2.4.1",
"lodash.keys": "~2.4.1"
}
},
"lodash.escape": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-2.4.1.tgz",
"integrity": "sha1-LOEsXghNsKV92l5dHu659dF1o7Q=",
"requires": {
"lodash._escapehtmlchar": "~2.4.1",
"lodash._reunescapedhtml": "~2.4.1",
"lodash.keys": "~2.4.1"
}
},
"lodash.isarguments": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
......@@ -6820,60 +6574,11 @@
"resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz",
"integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U="
},
"lodash.isobject": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-2.4.1.tgz",
"integrity": "sha1-Wi5H/mmVPx7mMafrof5k0tBlWPU=",
"requires": {
"lodash._objecttypes": "~2.4.1"
}
},
"lodash.keys": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz",
"integrity": "sha1-SN6kbfj/djKxDXBrissmWR4rNyc=",
"requires": {
"lodash._isnative": "~2.4.1",
"lodash._shimkeys": "~2.4.1",
"lodash.isobject": "~2.4.1"
}
},
"lodash.restparam": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz",
"integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU="
},
"lodash.template": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-2.4.1.tgz",
"integrity": "sha1-nmEQB+32KRKal0qzxIuBez4c8g0=",
"requires": {
"lodash._escapestringchar": "~2.4.1",
"lodash._reinterpolate": "~2.4.1",
"lodash.defaults": "~2.4.1",
"lodash.escape": "~2.4.1",
"lodash.keys": "~2.4.1",
"lodash.templatesettings": "~2.4.1",
"lodash.values": "~2.4.1"
}
},
"lodash.templatesettings": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz",
"integrity": "sha1-6nbHXRHrhtTb6JqDiTu4YZKaxpk=",
"requires": {
"lodash._reinterpolate": "~2.4.1",
"lodash.escape": "~2.4.1"
}
},
"lodash.values": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz",
"integrity": "sha1-q/UUQ2s8twUAFieXjLzzCxKA7qQ=",
"requires": {
"lodash.keys": "~2.4.1"
}
},
"log-symbols": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz",
......@@ -8109,11 +7814,6 @@
"pinkie-promise": "^2.0.0"
}
},
"pdc": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/pdc/-/pdc-0.2.3.tgz",
"integrity": "sha1-PU0laVCMvfgEJRGn58HfKKGGaHU="
},
"pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment