add --dir and update man page

This commit is contained in:
Talon Poole 2021-02-15 17:17:16 +00:00
parent b113fda0ec
commit 74e84b1ab4
6 changed files with 84 additions and 65 deletions

9
cli.js
View file

@ -30,6 +30,12 @@ const cli = yargs(process.argv.slice(2))
type: "string", type: "string",
requiresArg: true, requiresArg: true,
}, },
dir: {
type: "string",
choices: ["rtl", "ltr"],
default: "ltr",
requiresArg: true,
},
author: { author: {
type: "string", type: "string",
requiresArg: true, requiresArg: true,
@ -40,6 +46,7 @@ const cli = yargs(process.argv.slice(2))
css: { css: {
choices: ["gmi.css", "base", "none"], choices: ["gmi.css", "base", "none"],
default: "gmi.css", default: "gmi.css",
requiresArg: true,
}, },
charset: { charset: {
type: "string", type: "string",
@ -97,7 +104,7 @@ const argv = cli
.conflicts("description", "body") .conflicts("description", "body")
.conflicts("html", "body") .conflicts("html", "body")
.group(["html", "body"], "Core:") .group(["html", "body"], "Core:")
.group(["author", "description", "css"], "HTML:") .group(["author", "description", "css", "dir"], "HTML:")
.group(["image", "audio", "video"], "Inline Media:") .group(["image", "audio", "video"], "Inline Media:")
.group(GMI_CSS_VARS, "gmi.css:") .group(GMI_CSS_VARS, "gmi.css:")
.alias("html", "language") .alias("html", "language")

View file

@ -5,7 +5,7 @@
.nh .nh
.ad l .ad l
.\" Begin generated content: .\" Begin generated content:
.TH "gmi-web" "1" "2021-02-12" "1.0.0-rc.2" .TH "gmi-web" "1" "2021-02-15" "1.0.0-rc.2"
.P .P
.SH NAME .SH NAME
.P .P
@ -13,41 +13,39 @@ gmi-web - a bridge between Gemini and HTML
.P .P
.SH SYNOPSIS .SH SYNOPSIS
.P .P
\fBgmi-web\fR [--html|--body] <\fIOPTIONS\fR> < [\fIFILE\fR] \fBgmi-web\fR [--html \fILANG\fR|--body] <\fIOPTIONS\fR> < [\fIFILE\fR]
.P .P
\fBgmi-web\fR [--html|--body] <\fIOPTIONS\fR> [\fIFILES\fR] \fBgmi-web\fR [--html \fILANG\fR|--body] <\fIOPTIONS\fR> [\fIFILES\fR]
.P .P
.SH DESCRIPTION .SH DESCRIPTION
.P .P
Convert Gemtext to semantic HTML styled in a readable, predictable Convert Gemtext to semantic HTML styled in a readable, predictable and
and mobile-friendly fashion! mobile-friendly fashion!
.P .P
.SH OPTIONS .SH OPTIONS
.P .P
\fB--html\fR \fILANG\fR
.RS 4
Generate a full HTML5 document with the provided \fILANG\fR.
.P
\fBgmi-web\fR --html en < doc.gmi
.P
.RE
\fB--descriptions\fR
.RS 4
If this flag is set the first non-empty text line of each Gemini file will
be used for the description <meta> tag. This will be truncated to 200
characters using an ellipsis.
.P
.RE
\fB--author\fR
.RS 4
If provided this will be used for the author <meta> tag on every file.
.P
.RE
\fB--body\fR \fB--body\fR
.RS 4 .RS 4
Generate only the HTML for the lines of the Gemini document. Generate only the HTML for the lines of the Gemini document.
.P .P
\fBgmi-web\fR --body < doc.gmi .RE
.nf
.RS 4
gmi-web --body < doc\&.gmi
.fi
.RE
.P
\fB--html\fR \fILANG\fR
.RS 4
Generate a full HTML5 document with the provided \fILANG\fR. \fB--dir\fR can be used
to adjust the document text direction from "ltr" to "rtl".
.P
Use \fB--descriptions\fR \fILIMIT\fR to apply the first non-empty text line of each
file as the description <meta> tag. \fILIMIT\fR will be used to truncate the text
with an ellipsis at that number of characters, otherwise the whole line will
be used.
.P
Use \fB--author\fR \fINAME\fR to set the author <meta> tag on every file.
.P .P
.RE .RE
\fB--css\fR \fIMODE\fR \fB--css\fR \fIMODE\fR
@ -61,26 +59,35 @@ include any style information and inline elements will be wrapped in <p>.
.RS 4 .RS 4
See --help or gmi.css(5) for the complete list of customizable styles. See --help or gmi.css(5) for the complete list of customizable styles.
.P .P
\fBgmi-web\fR --html en --foreground "#555555" --background "#9EEBCF" < doc.gmi
.P
.RE .RE
.nf
.RS 4
gmi-web --html en \\
--foreground "#555555" \\
--background "#9EEBCF" < doc\&.gmi
.fi
.RE
.P
\fB[--image|--audio|--video]\fR \fIEXENSIONS\fR \fB[--image|--audio|--video]\fR \fIEXENSIONS\fR
.RS 4 .RS 4
Include the provided \fIEXTENSIONS\fR as inline media according to the flag used. Include media extensions inline. You can provide multiple extensions per flag
You can provide multiple extensions per flag or multiple flags per extension. or multiple flags per extension.
.P
\fBgmi-web\fR --image jpg png --audio mp3 --html en < doc.gmi
.P
\fBgmi-web\fR --image jpg --image png --audio mp3 --html en < doc.gmi
.P .P
.RE .RE
.nf
.RS 4
gmi-web --html en \\
--image jpg \\
--image png \\
--audio mp3 ogg < doc\&.gmi
.fi
.RE
.P
\fB--config\fR [\fIJSON\fR] \fB--config\fR [\fIJSON\fR]
.RS 4 .RS 4
All the options documented here and by \fB--help\fR may be captured in a .json All the options documented here and by \fB--help\fR may be captured in a .json
file and passed to \fB--config\fR instead of as flags on the command-line. file and passed to \fB--config\fR instead of as flags on the command-line.
.P .P
\fBgmi-web\fR --config web.json < doc.gmi
.P
.RE .RE
.SH SEE ALSO .SH SEE ALSO
.P .P

View file

@ -6,34 +6,34 @@ gmi-web - a bridge between Gemini and HTML
# SYNOPSIS # SYNOPSIS
*gmi-web* [--html|--body] <_OPTIONS_> < [_FILE_] *gmi-web* [--html _LANG_|--body] <_OPTIONS_> < [_FILE_]
*gmi-web* [--html|--body] <_OPTIONS_> [_FILES_] *gmi-web* [--html _LANG_|--body] <_OPTIONS_> [_FILES_]
# DESCRIPTION # DESCRIPTION
Convert Gemtext to semantic HTML styled in a readable, predictable Convert Gemtext to semantic HTML styled in a readable, predictable and
and mobile-friendly fashion! mobile-friendly fashion!
# OPTIONS # OPTIONS
*--html* _LANG_
Generate a full HTML5 document with the provided _LANG_.
*gmi-web* --html en < doc.gmi
*--descriptions*
If this flag is set the first non-empty text line of each Gemini file will
be used for the description <meta> tag. This will be truncated to 200
characters using an ellipsis.
*--author*
If provided this will be used for the author <meta> tag on every file.
*--body* *--body*
Generate only the HTML for the lines of the Gemini document. Generate only the HTML for the lines of the Gemini document.
*gmi-web* --body < doc.gmi ```
gmi-web --body < doc.gmi
```
*--html* _LANG_
Generate a full HTML5 document with the provided _LANG_. *--dir* can be used
to adjust the document text direction from "ltr" to "rtl".
Use *--descriptions* _LIMIT_ to apply the first non-empty text line of each
file as the description <meta> tag. _LIMIT_ will be used to truncate the text
with an ellipsis at that number of characters, otherwise the whole line will
be used.
Use *--author* _NAME_ to set the author <meta> tag on every file.
*--css* _MODE_ *--css* _MODE_
By default this will be set to *gmi.css*. Choosing *base* will use just what By default this will be set to *gmi.css*. Choosing *base* will use just what
@ -43,22 +43,27 @@ and mobile-friendly fashion!
*gmi.css* *gmi.css*
See --help or gmi.css(5) for the complete list of customizable styles. See --help or gmi.css(5) for the complete list of customizable styles.
*gmi-web* --html en --foreground "#555555" --background "#9EEBCF" < doc.gmi ```
gmi-web --html en \\
--foreground "#555555" \\
--background "#9EEBCF" < doc.gmi
```
*[--image|--audio|--video]* _EXENSIONS_ *[--image|--audio|--video]* _EXENSIONS_
Include the provided _EXTENSIONS_ as inline media according to the flag used. Include media extensions inline. You can provide multiple extensions per flag
You can provide multiple extensions per flag or multiple flags per extension. or multiple flags per extension.
*gmi-web* --image jpg png --audio mp3 --html en < doc.gmi ```
gmi-web --html en \\
*gmi-web* --image jpg --image png --audio mp3 --html en < doc.gmi --image jpg \\
--image png \\
--audio mp3 ogg < doc.gmi
```
*--config* [_JSON_] *--config* [_JSON_]
All the options documented here and by *--help* may be captured in a .json All the options documented here and by *--help* may be captured in a .json
file and passed to *--config* instead of as flags on the command-line. file and passed to *--config* instead of as flags on the command-line.
*gmi-web* --config web.json < doc.gmi
# SEE ALSO # SEE ALSO
*gmi.css*(5) *gmi.css*(5)

View file

@ -19,7 +19,7 @@ export function html(file, options) {
if (options.body) return body(tokens, options); if (options.body) return body(tokens, options);
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html lang="${options.language}" style="${options.styles}"> <html lang="${options.language}" dir="${options.dir}" style="${options.styles}">
<head>${head( <head>${head(
Object.assign(options, { Object.assign(options, {
title: tokens[0].h1, title: tokens[0].h1,

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "gmi-web-cli", "name": "gmi-web-cli",
"version": "1.0.0-rc.2", "version": "1.0.1-rc.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View file

@ -1,6 +1,6 @@
{ {
"name": "gmi-web-cli", "name": "gmi-web-cli",
"version": "1.0.0-rc.2", "version": "1.0.1-rc.2",
"description": "A bridge between HTML and Gemini", "description": "A bridge between HTML and Gemini",
"main": "html.js", "main": "html.js",
"type": "module", "type": "module",