This commit is contained in:
Talon Poole 2021-02-11 23:49:39 +00:00
parent 2ade53f268
commit ddaf0c5ada
2 changed files with 12 additions and 11 deletions

17
cli.js
View file

@ -12,9 +12,15 @@ const cli = yargs(process.argv.slice(2))
.command("$0 [files..]", "Convert text/gemini to text/html.", (yargs) => .command("$0 [files..]", "Convert text/gemini to text/html.", (yargs) =>
yargs yargs
.example("$0 --html en $(find ~/my-capsule -name '*.gmi')") .example("$0 --html en $(find ~/my-capsule -name '*.gmi')")
.example("$0 --foreground '#000000' --background '#EEEEEE' --html en < doc.gmi")
.example("$0 --body < ~/my-capsule/index.gmi") .example("$0 --body < ~/my-capsule/index.gmi")
.example("$0 --image jpg --audio mp3 --image png --body < doc.gmi")
.epilog("See the gmi-web(1) man page for more information")
) )
.options({ .options({
body: {
type: "boolean",
},
html: { html: {
type: "string", type: "string",
requiresArg: true, requiresArg: true,
@ -23,20 +29,20 @@ const cli = yargs(process.argv.slice(2))
choices: ["gmi.css", "base", "none"], choices: ["gmi.css", "base", "none"],
default: "gmi.css", default: "gmi.css",
}, },
body: {
type: "boolean",
},
}); });
cli.options({ cli.options({
image: { image: {
type: "array", type: "array",
requiresArg: true,
}, },
audio: { audio: {
type: "array", type: "array",
requiresArg: true,
}, },
video: { video: {
type: "array", type: "array",
requiresArg: true,
}, },
}); });
@ -71,12 +77,11 @@ const GMI_CSS_VARS = [
const argv = cli const argv = cli
.conflicts("html", "body") .conflicts("html", "body")
.group(["html", "css", "body"], "Core:") .group(["html", "css", "body"], "Core:")
.group(GMI_CSS_VARS, "CSS Variables:") .group(GMI_CSS_VARS, "gmi.css:")
.group(["images", "audio", "video"], "Inline Media:") .group(["image", "audio", "video"], "Inline Media:")
.alias("html", "language") .alias("html", "language")
.alias("html", "lang") .alias("html", "lang")
.config() .config()
.epilog("See the gmi-web(1) man page for more information!")
.showHelpOnFail(true) .showHelpOnFail(true)
.help().argv; .help().argv;

View file

@ -29,11 +29,7 @@ export const BASE_CSS =
"p,a,pre,h1,h2,h3,ul,blockquote,img,audio,video{display:block;max-width:100%;margin:0;padding:0;overflow-wrap:anywhere;}"; "p,a,pre,h1,h2,h3,ul,blockquote,img,audio,video{display:block;max-width:100%;margin:0;padding:0;overflow-wrap:anywhere;}";
export function head(options) { export function head(options) {
return ` return `
${ ${options.css !== "" ? `<meta name="color-scheme" content="dark light">` : ""}
options.css !== ""
? `<meta name="color-scheme" content="dark light">`
: ""
}
${options.css !== "" ? `<style>${options.css}</style>` : ""} ${options.css !== "" ? `<style>${options.css}</style>` : ""}
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="${options.charset}"> <meta charset="${options.charset}">