Commit bd9298c4 authored by Fred Chasen's avatar Fred Chasen

Update exposeFunction

parent 883d6ca1
node_modules
\ No newline at end of file
...@@ -38,6 +38,8 @@ let relativePath = path.resolve(dir, input); ...@@ -38,6 +38,8 @@ let relativePath = path.resolve(dir, input);
let output; let output;
let tmpFile, tmpPath; let tmpFile, tmpPath;
let headless = typeof program.debug === "undefined";
// var hyphenator; // var hyphenator;
// var hyphenateOptions; // var hyphenateOptions;
...@@ -66,8 +68,6 @@ if (typeof(program.output) === "string") { ...@@ -66,8 +68,6 @@ if (typeof(program.output) === "string") {
output = "output.pdf"; output = "output.pdf";
} }
console.log("output", output, program.output);
/* /*
if (program.hyphenate) { if (program.hyphenate) {
hyphenateOptions = { hyphenateOptions = {
...@@ -96,7 +96,7 @@ if (program.hyphenate) { ...@@ -96,7 +96,7 @@ if (program.hyphenate) {
(async () => { (async () => {
const browser = await puppeteer.launch({ const browser = await puppeteer.launch({
// headless: false, headless: headless
// args: ['--no-sandbox', '--allow-file-access-from-files', '--enable-local-file-accesses'] // args: ['--no-sandbox', '--allow-file-access-from-files', '--enable-local-file-accesses']
}); });
...@@ -113,36 +113,47 @@ if (program.hyphenate) { ...@@ -113,36 +113,47 @@ if (program.hyphenate) {
let server = app.listen(PORT); let server = app.listen(PORT);
await page.goto(`http://localhost:${PORT}/print/${basename}`); await page.goto(`http://localhost:${PORT}/print/${basename}?preview=true`);
await page.addScriptTag({ await page.exposeFunction('PuppeteerLogger', (msg, counter) => {
url: `http://localhost:${PORT}/polyfill/paged.polyfill.js` console.log(msg, counter);
}); });
await page.exposeFunction('onPagesRendered', async (msg, width, height, orientation) => { await page.exposeFunction('onPagesRendered', async (msg, width, height, orientation) => {
console.log(msg); console.log(msg, width, height, orientation);
console.log("Saved to", output);
let pdf = await page.pdf({ if (headless) {
path: output, let pages = await page.waitForSelector(".pages");
printBackground: true, let pdf = await page.pdf({
displayHeaderFooter: false, path: output,
width: width, printBackground: true,
height: height, displayHeaderFooter: false,
orientation: orientation, width: width,
margin: { height: height,
top: 0, orientation: orientation,
right: 0, margin: {
bottom: 0, top: 0,
left: 0, right: 0,
}, bottom: 0,
// format: 'A4' left: 0,
}).catch((e) => { },
console.error(e); // format: 'A4'
}) }).catch((e) => {
console.error(e);
server.close(); });
await browser.close(); console.log("Saved to", output);
server.close();
await browser.close();
}
});
await page.addScriptTag({
url: `http://localhost:${PORT}/polyfill/paged.polyfill.js`
}); });
})(); })();
...@@ -158,6 +158,20 @@ section[data-type="epigraph"], ...@@ -158,6 +158,20 @@ section[data-type="epigraph"],
font-variant-numeric: oldstyle-nums; font-variant-numeric: oldstyle-nums;
} }
.shorter:nth(1) {
position: running(shorter1);
}
.shorter:nth(2) {
position: running(shorter2);
}
.page:nth(1) {
content: --var-1;
}
--var-1 = dataurl:svg
/* flexbox */ /* flexbox */
section[data-type="copyright"] #flexbox { section[data-type="copyright"] #flexbox {
......
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