2020-10-05 11:35:17 +00:00
|
|
|
# md2gemtext
|
|
|
|
|
|
|
|
[![builds.sr.ht status](https://builds.sr.ht/~boringcactus/md2gemtext.svg)](https://builds.sr.ht/~boringcactus/md2gemtext?)
|
|
|
|
|
|
|
|
for converting Markdown into [gemtext](https://gemini.circumlunar.space/docs/specification.html).
|
|
|
|
|
|
|
|
## standalone usage
|
|
|
|
|
|
|
|
```shell script
|
|
|
|
cargo install md2gemtext
|
|
|
|
md2gemtext /path/to/some/file.md /path/to/some/file.gmi
|
|
|
|
```
|
|
|
|
|
|
|
|
## library usage
|
|
|
|
|
|
|
|
```rust
|
|
|
|
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
|
2020-10-05 12:23:57 +00:00
|
|
|
- block quotes get turned into quotes (multi-paragraph contiguous block quotes break though)
|
2020-10-05 11:35:17 +00:00
|
|
|
- lists get turned into lists ("loose lists" probably misbehave, nested lists *definitely* misbehave, numbering is not preserved)
|
2020-10-05 12:23:57 +00:00
|
|
|
- `` `markdown code spans` `` retain their backticks
|
|
|
|
- `_italics_` are surrounded by single underscores
|
|
|
|
- `**bold**` is surrounded by double asterisks
|
2020-10-05 11:35:17 +00:00
|
|
|
- `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
|