diff --git a/cli.js b/cli.js index 1d95cf7..76d65cd 100755 --- a/cli.js +++ b/cli.js @@ -31,6 +31,7 @@ const cli = yargs(process.argv.slice(2)) }, dir: { type: "string", + hidden: true, choices: ["rtl", "ltr"], default: "ltr", requiresArg: true, @@ -40,8 +41,9 @@ const cli = yargs(process.argv.slice(2)) requiresArg: true, }, descriptions: { - type: "number", - default: 0, + coerce: (arg) => { + return typeof arg === "number" ? arg : arg ? Infinity : 0; + }, }, css: { default: "full", @@ -49,6 +51,7 @@ const cli = yargs(process.argv.slice(2)) }, inline: { type: "boolean", + hidden: true, group: "CSS:", }, image: { @@ -69,15 +72,9 @@ const cli = yargs(process.argv.slice(2)) default: "utf-8", requiresArg: true, }, - schemes: { - type: "boolean", - hidden: true, - default: false, - group: "CSS:", - }, }) .group(["html", "body"], "Core:") - .group(["author", "descriptions", "css", "schemes", "dir"], "HTML:") + .group(["author", "descriptions", "css", "dir"], "HTML:") .group(["image", "audio", "video"], "Inline Media:"); const CSS_VARS = CSS.rootVariables(CSS.FULL); diff --git a/css.js b/css.js index 9c6aab5..4a6cd82 100644 --- a/css.js +++ b/css.js @@ -53,7 +53,10 @@ export function style({ inline, css }) { if (css === "core") return ``; if (css === "full") - return ``; + return `\n`; return ``; } diff --git a/html.js b/html.js index f454e5f..02d5b01 100644 --- a/html.js +++ b/html.js @@ -4,6 +4,8 @@ import escape from "escape-html"; import * as CSS from "./css.js"; export const GMI_REGEX = /^((=>\s?(?[^\s]+)(\s(?.+))?)|(?<pre>```\s?(?<alt>.+)?)|(###\s?(?<h3>.+))|(##\s?(?<h2>.+))|(#\s?(?<h1>.+))|(\*\s?(?<li>.+))|(>\s?(?<quote>.+))|(?<text>(.+)?))$/; +export const tokenize = (gemtext) => + gemtext.split("\n").map((line) => GMI_REGEX.exec(line).groups); export function block( { text, href, title, pre, alt, h1, h2, h3, li, quote }, @@ -94,7 +96,7 @@ export function body(tokens, options) { } export function toHTML(gemtext, options) { - const tokens = gemtext.split("\n").map((line) => GMI_REGEX.exec(line).groups); + const tokens = tokenize(gemtext); if (options.body) return body(tokens, options); @@ -118,12 +120,9 @@ ${body(tokens, options)} export function head(options) { return ` <meta charset="${options.charset}"> -<meta name="viewport" content="width=device-width,initial-scale=1"> -${ - options.schemes || options.css === "full" - ? `<meta name="color-scheme" content="dark light">\n` - : "" -}${CSS.style(options)} +<meta name="viewport" content="width=device-width,initial-scale=1">${CSS.style( + options + )} <title>${options.title}${ !options.author ? "" : `\n` }${ diff --git a/package-lock.json b/package-lock.json index 42eee59..47b8d31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gmi-web-cli", - "version": "1.0.11-rc.2", + "version": "1.0.0-rc.3", "lockfileVersion": 1, "requires": true, "dependencies": {