Comment by ๐ŸŒป Nexy

Re: "Gemini to HTML generator"

In: s/Gemini

I know it is posible because I seen it before pages made automaticaly from a gemini, but i can't remember the name of the program they use and also, can't find the blog who made the tutorial...

๐ŸŒป Nexy

2025-05-04 ยท 1 year ago

15 Later Comments โ†“

๐Ÿ™ norayr ยท 2025-05-04 at 03:26:

i woud just use kineto to proxy content to http world. afaik it allows to specify custom css.

๐Ÿš€ clseibold [๐Ÿ›‚] ยท 2025-05-04 at 08:23:

Oh, writing a gemini to html converter is very easy to do.

I'm sure there is some converter that is already available, but I don't know of any off the top of my head, aside from what the HTTP to Gemini proxies use. But just in case there isn't, I'll describe how it's done below very generally. As a sidenote, you don't need any special CSS classes to attach CSS to this stuff. Just use *tag selectors.*

All of the line types in Gemini have HTML equivalents (whereas the vice versa of course is not true). Parse your gemtext by line, and turn headings into <h1>-<h4>, blockquotes into <blockquote>, links into <a> (or <p><a></p> - links need to be block elements, but this can instead be handled in CSS if you want).

Then you just need to handle list items, which are slightly more complicated only because you need to wrap your entire list with <ul>. But to do this, the first list line that follows a non-list line you see will use <ul><li>text</li>, then do all the other list items if they are available with just <li>, and at the list item line that precedes a non-list line, which is the end of your list, add on the closing </ul>

Preformatted blocks should translate to <pre> and </pre>, iirc. And I think that's pretty much everything. All the other lines should be <p></p>

Lastly, prepend the HTML heading part (`<!DOCTYPE html><html><head></head><body>`) and append the footer part (`</body></html>`) to your HTML string you are constructing.

CSS can be done by just using tag selectors - you can just style specific tags. If you wanted, you can add to the CSS `a { display: block; }` so that links are always blocks without having to wrap them in paragraph tags.

The only other CSS thing you might want to do is center the page on the screen (like what lagrange and profectus do to gemini pages - a maximum width page that's centered horizontally). I can't remember if you can do this with the body, but the other option is to just wrap the entire body in a div with an id (#wrapper) and then add this CSS: #wrapper { margin: auto; max-width: 600px; }

This extra CSS stuff can be inline, so you can just place it right in the <head> section that you are prepending to your HTML string.

๐Ÿ‘พ fab ยท 2025-05-04 at 15:26:

I use the kineto proxy with a custom stylesheet. It was a bit difficult to get the line distance right for me but it's definitely doable with CSS.

โ€” https://sr.ht/~sircmpwn/kineto/

I've put it behind my nginx reverse proxy, which is advised, but it's definitely a very easy way to get your Gemini content to the web.

๐ŸŒฒ byte [OP] ยท 2025-05-04 at 16:03:

@clseibold yeah that what i ended up doing for now, just styling the html tags :) also added a bit of functionality to inject headers and footers and have a classic menus this way

๐Ÿš€ frecklemaster ยท 2025-05-04 at 16:32:

TBH+seems+like+a+simple+script.

๐Ÿฆ roughnecks ยท 2025-05-05 at 05:59:

I tried loxy first, then september, then kineto. Always went back to loxy ยฏ\_(ใƒ„)_/ยฏ

๐Ÿฆ‚ zzo38 ยท 2025-05-05 at 06:09:

I have written a Gemini to HTML converter (and I mentioned it in Usenet), although it does not use CSS at all (since I don't like CSS and I think the default styles are usually better anyways). (Maybe later I will copy it here too, since I have made a few changes since I put it on Usenet.)

๐Ÿš€ mbays ยท 2025-05-05 at 10:24:

Here's one simple implementation of gemtext -> HTML; no CSS, but that should be easy to hack in.

โ€” gemini.thegonz.net/gmi2html.sed

๐Ÿ‘ zeerooth ยท 2025-05-05 at 13:24:

There is also

โ€” https://codeberg.org/snonux/gemtexter

๐Ÿ‘ฝ TKurtBond ยท 2025-05-06 at 01:55:

I use the static site generation feature of Lichen, a CMS written in Forth, to generate the HTML version of consp.org.

Lichen is at https://codeberg.org/stringbone/lichen/src/branch/master

๐Ÿ‘ป mediocregopher [...] ยท 2025-05-06 at 06:40:

If you happen to be using Caddy as your webserver, I wrote a plugin for it which can do what you want. There's an example of how to use it in the repo as well.

โ€” https://dev.mediocregopher.com/mediocre-caddy-plugins/#httphandlersgemtext

๐ŸŒฒ byte [OP] ยท 2025-05-07 at 23:01:

@mediocregopher oh wow that's amazing! i should try that :3

๐Ÿ‘ป ps ยท 2025-05-08 at 04:12:

Thought, I should use Markdown for preprocessing and then convert it separately to Gemtext, HTML, and any other format. I made a mistake when translated my existing documents from Markdown to Gemtext, just imho.

๐Ÿ‘ป mediocregopher [...] ยท 2025-05-08 at 07:16:

@byte feel free to email me if you have any questions about using it :)

๐Ÿš€ clseibold [๐Ÿ›‚] ยท 2025-05-08 at 10:10:

@ps That seems like a good way to do it. Going from MD to another format will allow you to use more features that are HTML that get discarded in the gemtext. I wonder if anybody has done anything with AsciiDoc to HTML and Gemtext?

Original Post

๐ŸŒ’ s/Gemini

๐ŸŒฒ byte:

Gemini to HTML generator โ€” hi, i was wondering if there are any reliable projects that i could use to convert my capsule with gemlogs into html with css automatically? i got a physical server and will be transfering my stuff onto it, so i decided to give a common web a try as well. as web is inferior to gemini and hand-editing it absolutely sucks, i'd prefer to still write my posts in gemtext for my capsule, and then pass them through some soft that either converts them once or acts as a proxy...

๐Ÿ’ฌ 16 comments ยท 2025-05-04 ยท 1 year ago