Skip to content

Commit

Permalink
Merge pull request #1 from kjlaw89/custom-css
Browse files Browse the repository at this point in the history
Added the ability to specify a custom CSS stylesheet
  • Loading branch information
kjlaw89 authored Apr 8, 2019
2 parents ebee624 + 359d49a commit e9b77fc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bin/api2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ program
.option("-t, --theme <themeName>", "theme to use (see https://highlightjs.org/static/demo/ for a list)")
.option("-c, --customLogo <logoPath>", "use custom logo at the respective path")
.option("-C, --customCss", "use custom css")
.option("-P, --customCssPath <cssPath>", "use custom css file")
.option("-i, --includes <includesList>", "comma-separated list of files to include")
.option("-l, --languages <languageList>", "comma-separated list of languages to use for the language tabs (out of " + Object.getOwnPropertyNames(languageMap).join(", ") + ")")
.option("-s, --search", "enable search")
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 {

Expand Down

0 comments on commit e9b77fc

Please sign in to comment.