Skip to content

Commit 37f09eb

Browse files
committed
Add 'htmldark' option for dark theme support in HTML output
1 parent 48782ff commit 37f09eb

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

data/completion.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ complete:
317317
desc: Boolean that if false won't try to open the output contents in a browser -defaults to true-
318318
- name: htmlwait=
319319
desc: Amount of ms, when htmlopen=true, to wait for the system browser to open an render the html output
320+
- name: htmldark=
321+
desc: If supported and true the output html will use a dark theme.
320322
- name: out=ini
321323
desc: A INI/Properties format -arrays are not supported-
322324
- name: out=json

data/usage.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,11 @@
13271327
"Option": "htmlwait",
13281328
"Type": "Number",
13291329
"Description": "Amount of ms, when htmlopen=true, to wait for the system browser to open an render the html output"
1330+
},
1331+
{
1332+
"Option": "htmldark",
1333+
"Type": "Boolean",
1334+
"Description": "If supported and true the output html will use a dark theme."
13301335
}
13311336
],
13321337
[

src/build.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ help:
66
desc : Option to perform (e.g. dev; clean; pack; build; test)
77
example : "build"
88
mandatory: false
9+
options :
10+
- dev
11+
- clean
12+
- pack
13+
- build
14+
- test
915

1016
todo:
1117
- (ask ):

src/docs/USAGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ List of options to use when _out=html_:
758758
| htmlpart | Boolean | Boolean flag that if true and the input data is a string or markdown the generated html will be partial and not the complete file |
759759
| htmlopen | Boolean | Boolean that if false won't try to open the output contents in a browser (defaults to true). To use outfile= you need to set htmlopen=false. |
760760
| htmlwait | Number | Amount of ms, when htmlopen=true, to wait for the system browser to open an render the html output |
761+
| htmldark | Boolean | If supported and true the output html will use a dark theme. |
761762

762763
---
763764

src/include/outputFns.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ var _outputFns = new Map([
1818
if (params.htmlopen) tmpf = io.createTempFile("oafp_", ".html")
1919

2020
ow.loadTemplate()
21+
params.htmldark = toBoolean(_$(params.htmldark, "htmldark").isString().default("false"))
2122
if (isString(r)) {
22-
html = ow.template.html.genStaticVersion(ow.template.parseMD2HTML(r, !toBoolean(params.htmlpart), !toBoolean(params.htmlcompact)))
23+
html = ow.template.html.genStaticVersion(ow.template.parseMD2HTML(r, !toBoolean(params.htmlpart), !toBoolean(params.htmlcompact),__,params.htmldark))
2324
html = html.replace("<html>", "<html><meta charset=\"utf-8\">")
2425
} else {
2526
let _res = ow.template.html.parseMap(r, true)
26-
html = "<html><meta charset=\"utf-8\"><style>" + _res.css + "</style><body>" + _res.out + "</body></html>"
27+
html = "<html><meta charset=\"utf-8\"><style>" + _res.css + "</style><body" + (params.htmldark ? " class=\"njsmap_dark\"" : "") + ">" + _res.out + "</body></html>"
2728
}
2829
if (params.htmlopen) {
2930
io.writeFileString(tmpf, html)

0 commit comments

Comments
 (0)