npm install from git
This commit is contained in:
parent
34ed5cf36c
commit
21c5e5bfef
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,2 @@
|
||||||
*.min.*
|
|
||||||
node_modules/
|
node_modules/
|
||||||
gmi-web.1
|
|
||||||
capsule/
|
capsule/
|
||||||
|
|
|
@ -93,11 +93,11 @@ Options:
|
||||||
|
|
||||||
*You will need*:
|
*You will need*:
|
||||||
- [node(1) (w/ npm(1))](https://nodejs.org/en/) (to build/run the cli)
|
- [node(1) (w/ npm(1))](https://nodejs.org/en/) (to build/run the cli)
|
||||||
- [scdoc(1)](https://git.sr.ht/~sircmpwn/scdoc) (for the man pages)
|
|
||||||
|
|
||||||
```sh
|
|
||||||
make install
|
|
||||||
```
|
```
|
||||||
|
npm install -g git+https://codeberg.org/talon/gmi-web.git
|
||||||
|
```
|
||||||
|
|
||||||
<!-- TODO
|
<!-- TODO
|
||||||
### gmi.js
|
### gmi.js
|
||||||
|
|
||||||
|
|
79
gmi-web.1
Normal file
79
gmi-web.1
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
.\" Generated by scdoc 1.10.1
|
||||||
|
.\" Complete documentation for this program is not available as a GNU info page
|
||||||
|
.ie \n(.g .ds Aq \(aq
|
||||||
|
.el .ds Aq '
|
||||||
|
.nh
|
||||||
|
.ad l
|
||||||
|
.\" Begin generated content:
|
||||||
|
.TH "gmi-web" "1" "2021-01-29" "0.1.0"
|
||||||
|
.P
|
||||||
|
.SH NAME
|
||||||
|
.P
|
||||||
|
gmi-web - A bridge between Gemini and HTML
|
||||||
|
.P
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.P
|
||||||
|
\fBgmi-web\fR [\fIOPTIONS\fR...] [\fIFILES\fR...]
|
||||||
|
.P
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.P
|
||||||
|
Convert your Gemini \fIFILES\fR to semantic HTML styled in a readable, predictable
|
||||||
|
and mobile-friendly fashion!
|
||||||
|
.P
|
||||||
|
.SH OPTIONS
|
||||||
|
.P
|
||||||
|
\fB--images\fR \fB--audio\fR \fB--video\fR
|
||||||
|
.RS 4
|
||||||
|
Include the respective media inline.
|
||||||
|
.P
|
||||||
|
.RE
|
||||||
|
\fB--no-css\fR
|
||||||
|
.RS 4
|
||||||
|
Do not include gmi.css in the rendered HTML markup.
|
||||||
|
.P
|
||||||
|
.RE
|
||||||
|
\fB--silent\fR
|
||||||
|
.RS 4
|
||||||
|
Do not log anything to stdout
|
||||||
|
.P
|
||||||
|
.RE
|
||||||
|
.SH EXAMPLES
|
||||||
|
.P
|
||||||
|
The following example will create .html converted files next to their .gmi counterparts on the filesystem.
|
||||||
|
.P
|
||||||
|
.nf
|
||||||
|
.RS 4
|
||||||
|
$ gmi-web gmi/*\&.gmi
|
||||||
|
.fi
|
||||||
|
.RE
|
||||||
|
.P
|
||||||
|
.SH AUTHORS
|
||||||
|
.P
|
||||||
|
Maintained by Talon Poole <code@talon.computer>. Up-to-date sources can be
|
||||||
|
found at https://codeberg.org/talon/gmi-web
|
||||||
|
.P
|
||||||
|
.SH COPYRIGHT
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
.P
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
.P
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
.P
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
.P
|
||||||
|
For more information, please refer to <http://unlicense.org/>
|
1
gmi.min.css
vendored
Normal file
1
gmi.min.css
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
:root{--foreground:black;--background:white;--p-size:1.25rem;--p-indent:0rem;--p-line-height:1.5;--a-size:var(--p-size);--pre-size:1rem;--pre-line-height:1;--h1-size:3rem;--h2-size:2.25rem;--h3-size:1.5rem;--heading-line-height:1.25;--ul-size:var(--p-size);--ul-line-height:1.25;--blockquote-size:var(--p-size);--blockquote-line-height:1.25;--mono:Consolas,monaco,monospace;--serif:georgia,times,serif;--sans-serif:-apple-system,BlinkMacSystemFont,"avenir next",avenir,helvetica,"helvetica neue",ubuntu,roboto,noto,"segoe ui",arial,sans-serif}body{max-width:48rem;padding:.5rem;margin:0 auto}a,audio,blockquote,h1,h2,h3,img,p,pre,ul,video{display:block;max-width:100%;margin:0;padding:0;overflow-wrap:anywhere}h1,h2,h3{font-family:var(--sans-serif);line-height:var(--heading-line-height)}p{font-size:var(--p-size);font-family:var(--serif);text-indent:var(--p-indent);line-height:var(--p-line-height)}a::before{font-size:var(--p-size);font-family:var(--mono);content:"⇒";padding-right:.25rem;vertical-align:middle}a{font-size:var(--p-size);font-family:var(--serif);text-decoration:none}pre{font-size:var(--pre-size);font-family:var(--mono);line-height:var(--pre-line-height);padding:1.25rem;overflow-y:auto}h1{font-size:var(--h1-size)}h2{font-size:var(--h2-size)}h3{font-size:var(--h3-size)}ul{font-size:var(--p-size);font-family:var(--serif);line-height:var(--ul-line-height);list-style-type:none}li::before{font-size:var(--p-size);font-family:var(--mono);content:"*";vertical-align:middle;padding-right:.5rem}blockquote{font-size:var(--p-size);font-family:var(--serif);line-height:var(--blockquote-line-height);padding-left:.75rem}pre+blockquote{padding-top:.5rem;padding-bottom:.5rem}a,blockquote,body,h1,h2,h3,html,p,pre::-moz-selection,pre::selection,ul{color:var(--foreground);background-color:var(--background)}blockquote{border-left:.5rem solid var(--foreground)}::-moz-selection,::selection,a:hover,pre{color:var(--background);background-color:var(--foreground)}@media (prefers-color-scheme:dark){a,blockquote,body,h1,h2,h3,html,p,pre::-moz-selection,pre::selection,ul{color:var(--background);background-color:var(--foreground)}blockquote{border-left:.5rem solid var(--background)}::-moz-selection,::selection,a:hover,pre{color:var(--foreground);background-color:var(--background)}}
|
1
gmi.min.js
vendored
Normal file
1
gmi.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
class Gemini{static syntax={P:"",A:"=>",UL:"*",BLOCKQUOTE:">",PRE:"```",H1:"#",H2:"##",H3:"###"};static line(e,t){"string"==typeof e&&(e={content:e,type:t||"P"});let n=Gemini.render(e).dom;return{get dom(){return n},get type(){return this.dom.nodeName},set type(e){n=Gemini.render({dom:this.dom,type:e,content:Gemini.contentFrom(this.dom)}).dom},get content(){return Gemini.contentFrom(n)},set content(e){Gemini.render({dom:n,type:n.nodeName,content:e})},get editable(){return"true"===this.dom.contentEditable},set editable(e){Gemini.render({dom:this.dom,type:this.type,content:this.content,editable:e})},delete(){return this.dom.remove()},get gmi(){const e=Gemini.syntax[this.type],t=Gemini.contentFrom(this.dom).replace(/\n?$/,"");switch(this.type.toUpperCase()){case"PRE":return`${e}\n${t}\n${e}`;default:return t.split("\n").map((t=>`${""!==e?e+" ":""}${t}`)).join("\n")}},get before(){return Gemini.line(this.dom.previousElementSibling)},set before(e){this.before.dom.after(e.dom)},get after(){return Gemini.line(this.dom.nextElementSibling)},set after(e){this.after.dom.before(e.dom)}}}static render(e){if(e.dom&&e.dom.nodeName!==e.type){const t=document.createElement(e.type);e.dom.replaceWith(t),e.dom=t}else e.nodeName?e={dom:e,type:e.nodeName,content:Gemini.contentFrom(e),editable:e.contentEditable}:e.dom=e.dom||document.createElement(e.type||"P");switch(e.dom.contentEditable=e.editable||"inherit",e.type.toUpperCase()){case"A":const{href:t,content:n}=Gemini.link(e.content);e.dom.innerHTML=e.editable&&t!==n?`${t} ${n}`:n,e.dom.href=t;break;case"UL":e.dom.innerHTML=e.content.split("\n").map((e=>e.length>0?`<li>${e}</li>`:"")).join("\n");break;case"BLOCKQUOTE":e.dom.innerHTML=e.content.split("\n").map((e=>`<div>${e}</div>`)).join("\n");break;case"PRE":e.dom.textContent=e.content;break;default:e.dom.innerHTML=e.content.replace(/\n+/g,"<br>")}return e}static contentFrom(e){switch(e.nodeName.toUpperCase()){case"BLOCKQUOTE":return Array.from(e.childNodes).map((e=>e.textContent)).join("\n");case"UL":return Array.from(e.children).map((e=>e.textContent)).join("\n");case"A":const{href:t,content:n}=Gemini.link(e.textContent);return`${t||e.href} ${n}`;case"PRE":return e.textContent;default:return e.innerHTML.replace(/<br>/g,"\n")}}static link(e=""){return/((?<href>[^\s]+\/\/[^\s]+)\s)?(?<content>.+)/.exec(e).groups}constructor(e){this.root=e}get editable(){return"true"===this.root.contentEditable}set editable(e){this.root.contentEditable=e,this.lines.forEach((t=>t.editable=e))}get lines(){return Array.from(this.root.children).filter((e=>["P","BLOCKQUOTE","A","PRE","UL","H1","H2","H3"].includes(e.nodeName))).map(Gemini.line)}set lines(e){this.root.textContent="",this.root.append(...e.map((e=>e.dom)))}get source(){return this.lines.map((e=>e.gmi)).join("\n")}download(){const e=document.createElement("a");e.setAttribute("href","data:text/gemini;charset=utf-8,"+encodeURIComponent(this.source)),e.setAttribute("download",`${this.lines[0].content.replace(/\s/g,"_")}.gmi`),e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e)}get foreground(){return getComputedStyle(this.root).getPropertyValue("--foreground")}set foreground(e){return this.root.style.setProperty("--foreground",e)}get background(){return getComputedStyle(this.root).getPropertyValue("--background")}set background(e){return this.root.style.setProperty("--background",e)}get size(){return getComputedStyle(this.root).getPropertyValue("--font-size")}set size(e){return this.root.style.setProperty("--font-size",e)}get lineHeight(){return getComputedStyle(this.root).getPropertyValue("--line-height")}set lineHeight(e){return this.root.style.setProperty("--line-height",e)}get serif(){return getComputedStyle(this.root).getPropertyValue("--serif")}set serif(e){return this.root.style.setProperty("--serif",e)}get sans(){return getComputedStyle(this.root).getPropertyValue("--sans")}set sans(e){return this.root.style.setProperty("--sans",e)}get mono(){return getComputedStyle(this.root).getPropertyValue("--mono")}set mono(e){return this.root.style.setProperty("--mono",e)}}
|
|
@ -2,10 +2,11 @@
|
||||||
"name": "gmi-web",
|
"name": "gmi-web",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "A bridge between the HTML and Gemini",
|
"description": "A bridge between the HTML and Gemini",
|
||||||
"main": "gmi.css",
|
"main": "cli.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"gmi-web": "cli.js"
|
"gmi-web": "cli.js"
|
||||||
},
|
},
|
||||||
|
"man": "./gmi-web.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"map-stream": "0.0.7",
|
"map-stream": "0.0.7",
|
||||||
"minify": "^6.0.1",
|
"minify": "^6.0.1",
|
||||||
|
|
Loading…
Reference in a new issue