From 359d49a8a7792c5b46bf894a2f2a06b94c6495d6 Mon Sep 17 00:00:00 2001 From: Kevin Lawrence Date: Mon, 8 Apr 2019 10:56:05 -0400 Subject: [PATCH] Added the ability to specify a custom CSS stylesheet --- bin/api2html.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/api2html.js b/bin/api2html.js index 8d86e84..8607413 100755 --- a/bin/api2html.js +++ b/bin/api2html.js @@ -36,6 +36,7 @@ program .option("-t, --theme ", "theme to use (see https://highlightjs.org/static/demo/ for a list)") .option("-c, --customLogo ", "use custom logo at the respective path") .option("-C, --customCss", "use custom css") + .option("-P, --customCssPath ", "use custom css file") .option("-i, --includes ", "comma-separated list of files to include") .option("-l, --languages ", "comma-separated list of languages to use for the language tabs (out of " + Object.getOwnPropertyNames(languageMap).join(", ") + ")") .option("-s, --search", "enable search") @@ -124,6 +125,20 @@ if (program.args.length === 0) { if (program.customCss) { shinOptions.customCss = true; } + + let customCss = ""; + if (program.customCssPath) { + shinOptions.customCss = true; + + try { + customCss = fs.readFileSync(path.resolve(program.customCssPath), "utf8"); + console.log(chalk.green(icons.ok) + " Read custom css file!"); + } + catch (error) { + console.log(chalk.red(icons.fail) + " Error loading custom css file:"); + console.log(err.message); + } + } let api = null; @@ -160,6 +175,10 @@ if (program.args.length === 0) { } console.log(chalk.green(icons.ok) + " Rendered HTML form markdown!"); + + if (customCss) { + html = html.replace (/\/\* place your custom CSS overrides here \*\//i, customCss); + } try {