fix defaults

This commit is contained in:
Talon Poole 2021-02-24 20:23:28 +00:00
parent ae1ae05246
commit 2a75fc8223
3 changed files with 8 additions and 8 deletions

2
cli.js
View file

@ -48,7 +48,7 @@ const cli = yargs(process.argv.slice(2))
requiresArg: true, requiresArg: true,
group: "HTML:", group: "HTML:",
}, },
descriptions: { description: {
coerce: (arg) => (typeof arg === "number" ? arg : arg ? Infinity : 0), coerce: (arg) => (typeof arg === "number" ? arg : arg ? Infinity : 0),
group: "HTML:", group: "HTML:",
}, },

View file

@ -106,7 +106,7 @@ export function toHTML(gemtext, options) {
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html lang="${options.html}" dir="${ <html lang="${options.html}" dir="${
options.dir options.dir || "ltr"
}" style='${options.inlineCSS("html")}'> }" style='${options.inlineCSS("html")}'>
<head>${head( <head>${head(
Object.assign(options, { Object.assign(options, {
@ -123,7 +123,7 @@ ${body(tokens, options)}
export function head(options) { export function head(options) {
return ` return `
<meta charset="${options.charset}"> <meta charset="${options.charset || "utf-8"}">
<meta name="viewport" content="width=device-width,initial-scale=1">${ <meta name="viewport" content="width=device-width,initial-scale=1">${
options.styleTag options.styleTag
} }
@ -146,13 +146,13 @@ function description(tokens, options) {
text.length > limit ? `${text.substring(0, limit)}...` : text; text.length > limit ? `${text.substring(0, limit)}...` : text;
let description = let description =
options.descriptions > 0 options.description > 0
? tokens.find((token) => { ? tokens.find((token) => {
return token.text && token.text !== ""; return token.text && token.text !== "";
}) })
: false; : false;
return description && truncate(description.text, options.descriptions); return description && truncate(description.text, options.description);
} }
export const GMI_EXT = /\.gmi$/; export const GMI_EXT = /\.gmi$/;

View file

@ -80,13 +80,13 @@ test("--html en", () => {
toHTML(gemtext, { toHTML(gemtext, {
html: "en", html: "en",
author: "anon", author: "anon",
descriptions: true, description: true,
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
"<!DOCTYPE html> "<!DOCTYPE html>
<html lang=\\"en\\" dir=\\"undefined\\" style=''> <html lang=\\"en\\" dir=\\"ltr\\" style=''>
<head> <head>
<meta charset=\\"undefined\\"> <meta charset=\\"utf-8\\">
<meta name=\\"viewport\\" content=\\"width=device-width,initial-scale=1\\"> <meta name=\\"viewport\\" content=\\"width=device-width,initial-scale=1\\">
<meta name=\\"color-scheme\\" content=\\"dark light\\"> <meta name=\\"color-scheme\\" content=\\"dark light\\">
<style>p,pre,ul,blockquote,h1,h2,h3{margin-top:0;margin-bottom:0;overflow-wrap:break-word;}p:empty{padding-bottom:20px;}a{display:block;}pre{overflow-y:auto;}img,audio,video{display:block;max-width:100%;}body{margin:0 auto;padding:0.5rem;max-width:48rem;hyphens:manual;}p{font-family:georgia, times, serif;font-size:1.25rem;line-height:1.5;text-indent:0rem;}a{font-size:1.25rem;font-style:normal;font-family:georgia, times, serif;line-height:1.5;text-decoration:underline;}pre{padding:1rem;font-family:consolas, monaco, monospace;font-size:1rem;line-height:1;}h1{font-family:avenir, helvetica, arial, sans-serif;font-size:3rem;line-height:1.25;}h2{font-family:avenir, helvetica, arial, sans-serif;font-size:2.25rem;line-height:1.25;}h3{font-family:avenir, helvetica, arial, sans-serif;font-size:1.5rem;line-height:1.25;}ul{padding-left:1rem;list-style-type:circle;font-size:1.25rem;font-family:georgia, times, serif;line-height:1.25;}blockquote{margin-left:0;margin-right:0;padding-left:0.5rem;border-left-width:0.5rem;border-left-style:solid;font-family:georgia, times, serif;font-size:1.25rem;font-style:italic;line-height:1.25;}html,body,h1,h2,h3,p,a,ul,blockquote,pre::selection{color:black;background-color:white;}blockquote{border-color:black;}pre,::selection,a:hover{color:white;background-color:black;}@media (prefers-color-scheme: dark){html,body,h1,h2,h3,p,a,ul,blockquote,pre::selection{color:white;background-color:black;}blockquote{border-color:white;}pre,::selection,a:hover{color:black;background-color:white;}}</style> <style>p,pre,ul,blockquote,h1,h2,h3{margin-top:0;margin-bottom:0;overflow-wrap:break-word;}p:empty{padding-bottom:20px;}a{display:block;}pre{overflow-y:auto;}img,audio,video{display:block;max-width:100%;}body{margin:0 auto;padding:0.5rem;max-width:48rem;hyphens:manual;}p{font-family:georgia, times, serif;font-size:1.25rem;line-height:1.5;text-indent:0rem;}a{font-size:1.25rem;font-style:normal;font-family:georgia, times, serif;line-height:1.5;text-decoration:underline;}pre{padding:1rem;font-family:consolas, monaco, monospace;font-size:1rem;line-height:1;}h1{font-family:avenir, helvetica, arial, sans-serif;font-size:3rem;line-height:1.25;}h2{font-family:avenir, helvetica, arial, sans-serif;font-size:2.25rem;line-height:1.25;}h3{font-family:avenir, helvetica, arial, sans-serif;font-size:1.5rem;line-height:1.25;}ul{padding-left:1rem;list-style-type:circle;font-size:1.25rem;font-family:georgia, times, serif;line-height:1.25;}blockquote{margin-left:0;margin-right:0;padding-left:0.5rem;border-left-width:0.5rem;border-left-style:solid;font-family:georgia, times, serif;font-size:1.25rem;font-style:italic;line-height:1.25;}html,body,h1,h2,h3,p,a,ul,blockquote,pre::selection{color:black;background-color:white;}blockquote{border-color:black;}pre,::selection,a:hover{color:white;background-color:black;}@media (prefers-color-scheme: dark){html,body,h1,h2,h3,p,a,ul,blockquote,pre::selection{color:white;background-color:black;}blockquote{border-color:white;}pre,::selection,a:hover{color:black;background-color:white;}}</style>