From 2a0aac35dca42e5f4d6a9920b5c1a9aaab1dd2da Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Wed, 7 Apr 2021 20:41:25 +0200 Subject: [PATCH] Add markdown example screenshot script --- .github/markdown_example.mjs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/markdown_example.mjs diff --git a/.github/markdown_example.mjs b/.github/markdown_example.mjs new file mode 100644 index 00000000..2041d129 --- /dev/null +++ b/.github/markdown_example.mjs @@ -0,0 +1,21 @@ +//Imports + import puppeteer from "puppeteer" + +//Setup browser + const browser = await puppeteer.launch({ + headless:true, + executablePath:process.env.PUPPETEER_BROWSER_PATH, + args:["--no-sandbox", "--disable-extensions", "--disable-setuid-sandbox", "--disable-dev-shm-usage"], + ignoreDefaultArgs:["--disable-extensions"], + }) + const page = await browser.newPage() + +//Select markdown example and take screenshoot + await page.setViewport({width:600, height:600}) + await page.goto("https://github.com/lowlighter/lowlighter/blob/master/metrics.markdown.md") + const clip = await page.evaluate(() => { + const {x, y, width, height} = document.querySelector("#readme").getBoundingClientRect() + return {x, y, width, height} + }) + await page.screenshot({type:"png", path:"metrics.markdown.png", clip, omitBackground:true}) + await browser.close()