for converting Markdown into gemtext
Go to file
kirbylife 122f9d120b Fix table tests 2024-07-31 00:20:17 -06:00
src Fix table tests 2024-07-31 00:20:17 -06:00
.build.yml write the library 2020-10-05 05:35:17 -06:00
.gitignore write the library 2020-10-05 05:35:17 -06:00
Cargo.lock use latest gemtext 2020-10-06 18:45:20 -06:00
Cargo.toml Add table support 2024-07-30 01:28:51 -06:00
LICENSE.md set cargo metadata 2020-10-05 06:35:17 -06:00
README.gmi add example run on README 2020-10-05 13:28:27 -06:00
README.md write tests 2020-10-05 06:23:57 -06:00

README.md

md2gemtext

builds.sr.ht status

for converting Markdown into gemtext.

standalone usage

cargo install md2gemtext
md2gemtext /path/to/some/file.md /path/to/some/file.gmi

library usage

let gemtext = md2gemtext::convert("some markdown")?;

translation rules

  • "thematic breaks" (hr tags) are translated to ----- on a line by itself
  • headings turn into headings, levels beyond 3 get capped at 3
  • code blocks get turned into code blocks (info strings are discarded)
  • something happens to HTML, i forget what
  • paragraphs get empty lines between them, because i think that looks better
  • block quotes get turned into quotes (multi-paragraph contiguous block quotes break though)
  • lists get turned into lists ("loose lists" probably misbehave, nested lists definitely misbehave, numbering is not preserved)
  • `markdown code spans` retain their backticks
  • _italics_ are surrounded by single underscores
  • **bold** is surrounded by double asterisks
  • a [link](a://url) with context turns into a link with context followed by => a://url link
  • an ![inline](a://url) image turns into an [image: inline] image followed by => a://url [image: inline]
  • if a link or image is its own paragraph, it becomes just the gemtext link, to not be redundant