Convert text/gemini to text/html
Go to file
2021-01-28 00:09:12 +00:00
.gitignore ignore node_modules 2021-01-26 18:18:51 +00:00
example.html fix unclosed pre 2021-01-26 23:00:33 +00:00
gmi.css light/dark mode 2021-01-26 00:54:35 +00:00
gmi.js Update docs + preliminary editablity 2020-12-30 00:27:29 +00:00
Makefile formalize the minify dependency 2021-01-26 18:18:18 +00:00
package-lock.json update package-lock.json 2021-01-28 00:09:12 +00:00
package.json add package.json 2021-01-27 23:29:01 +00:00
README.md example.html 2021-01-26 22:29:24 +00:00

gmi-web

CC0

Vision: Provide the lowest common denominator between HTML/CSS/JS and Gemini

HTML spec

Check out the annotated example.html!

  • accessibility
  • pre alt text

Due to the ambiguity of HTML several translations from Gemini exist in the wild. I propose the following standard:

<ul>         ↔ *
<blockquote> ↔ >
<pre>        ↔ ``` 
<a>          ↔ => 
<h[1-3]>     ↔ #[##]
<p>

The <a> for a link should be presented without any parent elements. Many implementations use <div> to enforce "block" styling as opposed to the default "inline" which renders the link next to the previous block instead of below it. But the nested markup adds an unnecessary layer of indirection in semantics and when parsing. <a style"display: block;"> has the same effect (gmi.css uses this).

contenteditable

Empty lines should simply be represented as <p><br></p> this sets up contenteditable=true to add content to the line compared to just <br>.

When contenteditable=true, <p>, <ul>, <blockquote> and <pre> may also have line-breaks which will be represented in .innerHTML like so:

<p>          ↔ <br>
<blockquote> ↔ <div><br></div>
<ul>         ↔ <li><br></li>
<pre>        ↔ \n (or <br>)

This is important mostly for DOM development (as opposed to static HTML generation) where it is likely to occur.

inline media

  • TODO

gmi.css

Style your HTML generated Gemini content in a readable, predicable and mobile-friendly fashion!

<meta name="color-scheme" content="dark light">
<link rel="stylesheet" href="https://talon.computer/gmi.min.css"/>

The following variables (shown with their defaults) can be customized using the style attribute of your document's <html> tag.

--foreground: black;
--background: white;
--line-height: 1.5;
--font-size: 1.25rem;
--mono: Consolas, monaco, monospace;
--serif: font-family: georgia, times, serif;
--sans-serif: -apple-system, BlinkMacSystemFont,
             'avenir next', avenir,
             helvetica, 'helvetica neue',
             ubuntu,
             roboto, noto,
             'segoe ui', arial,
             sans-serif;

gmi.css will respect system dark mode preferences by inverting --foreground and --background.

<html style="style="--foreground:#555555; --background:#9EEBCF;">

gmi.js

Manipulate the DOM with a Gemini inspired API.

const line = Gemini.line("manipulate the dom\nbut like in a Gemini way\ntry it!")
document.body.prepend(line.dom)

Try changing the type and content and observing the effects.

line.type = "UL"
line.content = "now\nit's\na\nlist"

A document provides a way to handle many lines together.

window.gmi = new Gemini(document.body)
window.gmi.lines = [
  Gemini.line("interesting", "H1"),
  Gemini.line("that's convenient"),
  Gemini.line("http://talon.computer/js/ now... take me back please", "A"),
]
window.gmi.lines[0].type = "H3"

The gemtext source is available via .source

window.gmi.source

All the gmi.css variables are also available as properties.

let foreground = window.gmi.foreground
let background = window.gmi.background
window.gmi.foreground = background
window.gmi.background = foreground