From abe0f9098a08d5c59a5e34a61919186b5dad864a Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Mon, 28 Aug 2017 22:05:33 +0200 Subject: [PATCH] Work-around Remark rendering issue with screen media emulation --- plugins/remark.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/remark.js b/plugins/remark.js index 37202b4..9114400 100644 --- a/plugins/remark.js +++ b/plugins/remark.js @@ -16,6 +16,21 @@ class Remark { typeof remark === 'object' && typeof slideshow === 'object'); } + async configure() { + await this.page.emulateMedia(null); + await this.page.evaluate(_ => { + for (let j = 0; j < document.styleSheets.length; j++) { + const sheet = document.styleSheets[j]; + if (!sheet.rules) continue; + for (let i = sheet.rules.length - 1; i >= 0; i--) { + if (sheet.rules[i].cssText.indexOf('@media print') >= 0) { + sheet.deleteRule(i); + } + } + } + }); + } + slideCount() { return this.page.evaluate(_ => slideshow.getSlideCount()); }