Work-around Remark rendering issue with screen media emulation

This commit is contained in:
Antonin Stefanutti 2017-08-28 22:05:33 +02:00
parent f6e5797c15
commit abe0f9098a

View File

@ -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());
}