[scripts/markdown2htmldoc] bundle the required stylesheets together with the generated document

This commit is contained in:
Dmytro Meleshko 2020-07-06 18:51:13 +03:00
parent ccae18c898
commit 8e1d1dd9cb
3 changed files with 18 additions and 2 deletions

View file

@ -41,6 +41,12 @@ md.use(markdownItHeaderAnchors);
let markdownDocument = fs.readFileSync(args.get('inputFile', 0), 'utf-8');
let renderedMarkdown = md.render(markdownDocument);
let githubMarkdownCSS = fs.readFileSync(
require.resolve('github-markdown-css/github-markdown.css'),
);
let syntaxHighlightingThemeCSS = fs.readFileSync(
require.resolve('prismjs/themes/prism.css'),
);
let renderedHtmlDocument = `
<!DOCTYPE html>
@ -49,8 +55,12 @@ let renderedHtmlDocument = `
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css" integrity="sha256-HbgiGHMLxHZ3kkAiixyvnaaZFNjNWLYKD/QG6PWaQPc=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism.min.css" integrity="sha256-77qGXu2p8NpfcBpTjw4jsMeQnz0vyh74f5do0cWjQ/Q=" crossorigin="anonymous" />
<style>
${githubMarkdownCSS}
</style>
<style>
${syntaxHighlightingThemeCSS}
</style>
<style>
html, body {
padding: 0;

View file

@ -2,6 +2,7 @@
"private": true,
"dependencies": {
"argparse": "^1.0.10",
"github-markdown-css": "^4.0.0",
"github-slugger": "^1.2.1",
"markdown-it": "*",
"markdown-it-emoji": "*",

View file

@ -555,6 +555,11 @@ get-stdin@^6.0.0:
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==
github-markdown-css@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/github-markdown-css/-/github-markdown-css-4.0.0.tgz#be9f4caf7a389228d4c368336260ffc909061f35"
integrity sha512-mH0bcIKv4XAN0mQVokfTdKo2OD5K8WJE9+lbMdM32/q0Ie5tXgVN/2o+zvToRMxSTUuiTRcLg5hzkFfOyBYreg==
github-slugger@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/github-slugger/-/github-slugger-1.3.0.tgz#9bd0a95c5efdfc46005e82a906ef8e2a059124c9"