From 2a75fc8223f84728d86071118c501bdeb5820176 Mon Sep 17 00:00:00 2001 From: Talon Poole Date: Wed, 24 Feb 2021 20:23:28 +0000 Subject: [PATCH] fix defaults --- cli.js | 2 +- html.js | 8 ++++---- spec.js => html.spec.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename spec.js => html.spec.js (98%) diff --git a/cli.js b/cli.js index e53dcd1..cc27ae8 100755 --- a/cli.js +++ b/cli.js @@ -48,7 +48,7 @@ const cli = yargs(process.argv.slice(2)) requiresArg: true, group: "HTML:", }, - descriptions: { + description: { coerce: (arg) => (typeof arg === "number" ? arg : arg ? Infinity : 0), group: "HTML:", }, diff --git a/html.js b/html.js index 3e6a4bf..1ce9945 100644 --- a/html.js +++ b/html.js @@ -106,7 +106,7 @@ export function toHTML(gemtext, options) { return ` ${head( Object.assign(options, { @@ -123,7 +123,7 @@ ${body(tokens, options)} export function head(options) { return ` - + ${ options.styleTag } @@ -146,13 +146,13 @@ function description(tokens, options) { text.length > limit ? `${text.substring(0, limit)}...` : text; let description = - options.descriptions > 0 + options.description > 0 ? tokens.find((token) => { return token.text && token.text !== ""; }) : false; - return description && truncate(description.text, options.descriptions); + return description && truncate(description.text, options.description); } export const GMI_EXT = /\.gmi$/; diff --git a/spec.js b/html.spec.js similarity index 98% rename from spec.js rename to html.spec.js index 49778b7..3312d95 100644 --- a/spec.js +++ b/html.spec.js @@ -80,13 +80,13 @@ test("--html en", () => { toHTML(gemtext, { html: "en", author: "anon", - descriptions: true, + description: true, }) ).toMatchInlineSnapshot(` " - + - +