A HTML to Gemtext conversion API
I’ve made a simple API which will convert any HTML into Gemtext (source code on gitlab). In coming weeks I will create a WordPress plugin to automatically generate and update a gemlog, using this API for converting content. You might like to use this API for something too!
Because I’m using RapidAPI to host the API you will need a free API key from RapidAPI to access it.
Here is an example request to convert some HTML to Gemtext:
Simply send a HTTP POST to https://html-to-gemtext-or-markdown.p.rapidapi.com/html2gmi/ with your key in the Headers and some JSON in the body.
JSON structure
“html” should contain the HTML you wish to convert.
Optionally, you can also provide two extra parameters: “html2md_options” and “md2gmi_options” which give you access to all the options of the underlying HTML to Markdown library and the Markdown to Gemtext library. In the example above I’m setting the “link mode” to “paragraph” which people seem to prefer.
Bonus: HTML ==> Markdown and Markdown ==> Gemtext endpoints
Internally, this API converts HTML to Markdown and from there converts that Markdown to Gemtext. So it was trivial to expose those conversions as additional endpoints:
POST https://html-to-gemtext-or-markdown.p.rapidapi.com/html2md/
{ "html": "<h1>Some html</h1>", "autolinks": true }
POST https://html-to-gemtext-or-markdown.p.rapidapi.com/md2gmi/
{ "markdown": "# Some markdown", "links": "paragraph" }
UPDATE 2 Dec 2022: The WordPress plugin is usable. Grab it from the git repository. See an example of it in action.