RC
This commit is contained in:
parent
6ec48f2605
commit
b383f03f94
3
cli.js
3
cli.js
|
@ -30,8 +30,9 @@ const GMI_CSS_VARS = [
|
||||||
|
|
||||||
require("yargs")
|
require("yargs")
|
||||||
.scriptName("gmi-web")
|
.scriptName("gmi-web")
|
||||||
|
.config()
|
||||||
.command(
|
.command(
|
||||||
"$0 [--lang] [files..]",
|
"$0 [files..]",
|
||||||
"Convert .gmi to .html. See gmi-web(1) for more details.",
|
"Convert .gmi to .html. See gmi-web(1) for more details.",
|
||||||
(yargs) =>
|
(yargs) =>
|
||||||
yargs
|
yargs
|
||||||
|
|
30
gmi-web.1
30
gmi-web.1
|
@ -35,6 +35,12 @@ name.
|
||||||
\fBgmi-web\fR --lang "en" --foreground "#FFFFF" --background "#00000" $(find . -name *.gmi)
|
\fBgmi-web\fR --lang "en" --foreground "#FFFFF" --background "#00000" $(find . -name *.gmi)
|
||||||
.P
|
.P
|
||||||
.RE
|
.RE
|
||||||
|
\fB--config\fR [\fIJSON\fR]
|
||||||
|
.RS 4
|
||||||
|
All the options documented here and by \fB--help\fR may be captured in a .json
|
||||||
|
file and passed to \fB--config\fR.
|
||||||
|
.P
|
||||||
|
.RE
|
||||||
\fB--images\fR \fB--audio\fR \fB--video\fR
|
\fB--images\fR \fB--audio\fR \fB--video\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Include the respective media inline.
|
Include the respective media inline.
|
||||||
|
@ -42,7 +48,7 @@ Include the respective media inline.
|
||||||
.RE
|
.RE
|
||||||
\fB--no-css\fR
|
\fB--no-css\fR
|
||||||
.RS 4
|
.RS 4
|
||||||
Use only the bare-minimum <style>
|
Use only the bare minimum <style>
|
||||||
.P
|
.P
|
||||||
.RE
|
.RE
|
||||||
.SH EXAMPLES
|
.SH EXAMPLES
|
||||||
|
@ -55,6 +61,28 @@ gmi-web --lang en $(find \&. -name *\&.gmi)
|
||||||
.fi
|
.fi
|
||||||
.RE
|
.RE
|
||||||
.P
|
.P
|
||||||
|
To use \fB--config\fR you will need a .json file with the flags you want to be
|
||||||
|
included.
|
||||||
|
.P
|
||||||
|
.nf
|
||||||
|
.RS 4
|
||||||
|
{
|
||||||
|
"language": "en",
|
||||||
|
"foreground": "#137752",
|
||||||
|
"background": "#F4F4F4"
|
||||||
|
}
|
||||||
|
.fi
|
||||||
|
.RE
|
||||||
|
.P
|
||||||
|
Then give the path to \fBgmi-web\fR --config.
|
||||||
|
.P
|
||||||
|
.nf
|
||||||
|
.RS 4
|
||||||
|
gmi-web --config /path/to/my\&.json $(find \&. -name *\&.gmi)
|
||||||
|
.fi
|
||||||
|
.RE
|
||||||
|
.P
|
||||||
|
.P
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.P
|
.P
|
||||||
\fBgmi.css\fR(5)
|
\fBgmi.css\fR(5)
|
||||||
|
|
|
@ -24,11 +24,15 @@ and mobile-friendly fashion!
|
||||||
|
|
||||||
*gmi-web* --lang "en" --foreground "#FFFFF" --background "#00000" $(find . -name \*.gmi)
|
*gmi-web* --lang "en" --foreground "#FFFFF" --background "#00000" $(find . -name \*.gmi)
|
||||||
|
|
||||||
|
*--config* [_JSON_]
|
||||||
|
All the options documented here and by *--help* may be captured in a .json
|
||||||
|
file and passed to *--config*.
|
||||||
|
|
||||||
*--images* *--audio* *--video*
|
*--images* *--audio* *--video*
|
||||||
Include the respective media inline.
|
Include the respective media inline.
|
||||||
|
|
||||||
*--no-css*
|
*--no-css*
|
||||||
Use only the bare-minimum <style>
|
Use only the bare minimum <style>
|
||||||
|
|
||||||
# EXAMPLES
|
# EXAMPLES
|
||||||
|
|
||||||
|
@ -38,6 +42,24 @@ Render .html for all the .gmi files in the current directory
|
||||||
gmi-web --lang en $(find . -name \*.gmi)
|
gmi-web --lang en $(find . -name \*.gmi)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To use *--config* you will need a .json file with the flags you want to be
|
||||||
|
included.
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"language": "en",
|
||||||
|
"foreground": "#137752",
|
||||||
|
"background": "#F4F4F4"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then give the path to *gmi-web* --config.
|
||||||
|
|
||||||
|
```
|
||||||
|
gmi-web --config /path/to/my.json $(find . -name \*.gmi)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
||||||
*gmi.css*(5)
|
*gmi.css*(5)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "gmi-web",
|
"name": "gmi-web",
|
||||||
"version": "0.1.0",
|
"version": "1.0.0",
|
||||||
"description": "A bridge between the HTML and Gemini",
|
"description": "A bridge between the HTML and Gemini",
|
||||||
"main": "cli.js",
|
"main": "cli.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
22
tokenize.js
22
tokenize.js
|
@ -1,19 +1,17 @@
|
||||||
const GMI_EXT = /\.gmi$/;
|
const GMI_EXT = /\.gmi$/;
|
||||||
const GMI_REGEX = require("./gmi.regex");
|
const GMI_REGEX = require("./gmi.regex");
|
||||||
|
const tokenize = (exports.tokenize = (file) =>
|
||||||
|
JSON.stringify(
|
||||||
|
file.contents
|
||||||
|
.toString("utf8")
|
||||||
|
.split("\n")
|
||||||
|
.map((line) => GMI_REGEX.exec(line).groups),
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
));
|
||||||
module.exports = (file, cb) => {
|
module.exports = (file, cb) => {
|
||||||
if (!GMI_EXT.test(file.path)) return cb(null, file);
|
if (!GMI_EXT.test(file.path)) return cb(null, file);
|
||||||
|
file.contents = Buffer.from(tokenize(file));
|
||||||
file.path = file.path.replace(GMI_EXT, ".tokens.json");
|
file.path = file.path.replace(GMI_EXT, ".tokens.json");
|
||||||
file.contents = Buffer.from(
|
|
||||||
JSON.stringify(
|
|
||||||
file.contents
|
|
||||||
.toString("utf8")
|
|
||||||
.split("\n")
|
|
||||||
.map((line) => GMI_REGEX.exec(line).groups),
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
cb(null, file);
|
cb(null, file);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue