top | item 32550198

Show HN: Inlyne, a GPU powered, browser-less, Markdown previewer

25 points| trimental | 3 years ago |github.com

Markdown files are used universally in almost every git repository and yet you need a browser or electron app like VS Code to quickly open one.

To help this I'm trying to create a markdown viewer that renders on the gpu without needing a browser. If this interests you please help try out `cargo install inlyne`. Using it is as simple as `inlyne README.md` and you can set themes, fonts and scaling as you'd like.

12 comments

order

anaganisk|3 years ago

I’m just curious as to what GPU helps with for rendering plain html/markdown? What huge numbers is it crunching to render say a markdown file vs a 3D scene? Also browser doesn’t render MD right? All browser based implementations are done in JS or server side so what does it mean when its browserless?

trimental|3 years ago

Thanks for the question. Markdown files are basically html files with syntax sugar, and a lot of markdown files directly use html. So to properly render most files you need a basic html renderer at minimum. Although yes, you don't need the other features of a browser but typically most markdown renderers are either web-based (GitHub) or electron based (VS Code).

GPU rendering helps for scaling images, rendering text and drawing other primitives efficiently. It frees up CPU time, and can redraw many times faster in scrolls and resizes. This is why most browsers use the GPU when most web content is 2D. GPU's don't really crunch huge numbers but instead utilise parallelisation.

SahAssar|3 years ago

Most graphical markdown renderers seems to convert markdown to html and then render that html using a browser engine. This includes basically any based on electron (vscode, atom, obsidian, roam) and a lot of others that do it via platform web views.

The point of the browser-less claim is that it converts the md to html the same way most existing engines do, but then does not use a browser engine to render it, instead using something faster and more purpose-built.

As for the GPU-thing I'm not sure, but for example terminals are sometimes written to take advantage of GPU's (kitty for example: https://sw.kovidgoyal.net/kitty/#design-philosophy ) so why not this?

msravi|3 years ago

Very cool! The rendering looks great! A wishlist:

1. Rendering of LaTeX equations

2. Vim keybindings (/ for search, ^F/^B for PgDn/PgUp, etc.)

3. Should work with vim markdown composer (by setting g:markdown_composer_browser = 'inlyne' - not sure why this just doesn't work now...)

trimental|3 years ago

Thanks for this. It's great to get suggestions on improvements.

LaTex rendering might be very easy or very hard depending on the rust ecosystem for it, so I'll look into that. And I'm not too surprised it doesn't work with vim markdown composer but if it's a simple enough mechanism it'd be a great feature. Vim bindings could very easily be done though :)

boywitharupee|3 years ago

Which font rendering technique are you using? Are the layouts computed on the gpu?

trimental|3 years ago

Glyph rendering is done (through a rust crate called ab-glyph) by computing glyph vertices on the CPU, and then rendering and storing the glyph textures to the gpu. Layouts are calculated on the CPU.