Convert text/gemini to text/html
Go to file
Talon Poole 06a8bab54a format
2021-01-28 23:13:02 +00:00
.editorconfig documentation 2021-01-28 17:56:02 +00:00
.gitignore it works 2021-01-28 23:07:57 +00:00
cli.js format 2021-01-28 23:13:02 +00:00
example.html documentation 2021-01-28 17:56:02 +00:00
gmi-web.1.scd it works 2021-01-28 23:07:57 +00:00
gmi.css documentation 2021-01-28 17:56:02 +00:00
gmi.js make format 2021-01-28 06:18:32 +00:00
gmi.regex.js it works 2021-01-28 23:07:57 +00:00
Makefile tokenize 2021-01-28 21:03:30 +00:00
package-lock.json tokenize 2021-01-28 21:03:30 +00:00
package.json tokenize 2021-01-28 21:03:30 +00:00
README.md it works 2021-01-28 23:07:57 +00:00
to-html.js format 2021-01-28 23:13:02 +00:00
tokenize.js it works 2021-01-28 23:07:57 +00:00
UNLICENSE documentation 2021-01-28 17:56:02 +00:00

gmi-web

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

HTML spec

Check out the annotated example.html!

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).

inline media

Optionally, if a link is consumable by <img>, <audio> or <video> you may insert the media inline. Images and video should be styled to have max-width: 100%; so they don't overflow the body. It's a good idea to also include the "controls" attribute for videos and audio. <audio> tags require display: block; just like <a>.

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.

gmi.css

Style your HTML generated Gemini content in a readable, predictable 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;
  --p-size: 1.25rem;
  --p-indent: 0rem;
  --a-size: var(--p-size);
  --pre-size: 1rem;
  --h1-size: 3rem;
  --h2-size: 2.25rem;
  --h3-size: 1.5rem;
  --ul-size: var(--p-size);
  --blockquote-size: var(--p-size);
  --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;

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

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

gmi-web(1)

gmi-web [--no-css] [files..]

Convert .gmi to .html. See gmi-web(1) for more details.

Positionals:
  files  .gmi files to convert to .html                               [required]

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]
  --css      Toggle inclusion of gmi.css.              [boolean] [default: true]

You will need:

make install

License

gmi-web is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.