fix defaults
This commit is contained in:
parent
ae1ae05246
commit
2a75fc8223
2
cli.js
2
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:",
|
||||
},
|
||||
|
|
8
html.js
8
html.js
|
@ -106,7 +106,7 @@ export function toHTML(gemtext, options) {
|
|||
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="${options.html}" dir="${
|
||||
options.dir
|
||||
options.dir || "ltr"
|
||||
}" style='${options.inlineCSS("html")}'>
|
||||
<head>${head(
|
||||
Object.assign(options, {
|
||||
|
@ -123,7 +123,7 @@ ${body(tokens, options)}
|
|||
|
||||
export function head(options) {
|
||||
return `
|
||||
<meta charset="${options.charset}">
|
||||
<meta charset="${options.charset || "utf-8"}">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">${
|
||||
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$/;
|
||||
|
|
|
@ -80,13 +80,13 @@ test("--html en", () => {
|
|||
toHTML(gemtext, {
|
||||
html: "en",
|
||||
author: "anon",
|
||||
descriptions: true,
|
||||
description: true,
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
"<!DOCTYPE html>
|
||||
<html lang=\\"en\\" dir=\\"undefined\\" style=''>
|
||||
<html lang=\\"en\\" dir=\\"ltr\\" style=''>
|
||||
<head>
|
||||
<meta charset=\\"undefined\\">
|
||||
<meta charset=\\"utf-8\\">
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width,initial-scale=1\\">
|
||||
<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>
|
Loading…
Reference in a new issue