Skip to content

Commit

Permalink
Prepare first public release
Browse files Browse the repository at this point in the history
At this stage, the repo contains:

* a functional Markdown -> Gemini converter
* a program md2gmn that provides an interface to the converter for
  testing purposes
  • Loading branch information
tdemin committed Nov 8, 2020
2 parents 178647b + 9bc1f8e commit 4763bf1
Show file tree
Hide file tree
Showing 7 changed files with 1,128 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
@@ -0,0 +1,18 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# store test data here
test
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions README.md
@@ -0,0 +1,49 @@
# Hugo-to-Gemini converter

This repo holds a converter of Hugo Markdown posts to
[text/gemini][Gemtext] (also named Gemtext in this README). The
converter is supposed to make people using [Hugo](https://gohugo.io)'s
entrance to [Project Gemini][Gemini], the alternate web, somewhat
simpler.

[Gemini]: https://gemini.circumlunar.space
[Gemtext]: https://gemini.circumlunar.space/docs/specification.html

At this stage of development this repo contains the actual renderer
(`internal/gemini`) and the `md2gmn` program that converts Markdown
input to Gemtext and is supposed to facilitate testing.

The renderer is somewhat hasty, and is NOT supposed to be able to
convert the entirety of possible Markdown to Gemtext (as it's not
possible to do so, considering Gemtext is a lot simpler than Markdown),
but instead a selected subset of it, enough for conveying your mind in
Markdown.

The renderer uses the [gomarkdown][gomarkdown] library for parsing
Markdown.

[gomarkdown]: https://github.com/gomarkdown/markdown

## md2gmn

This program reads Markdown input from either text file (if `-f
filename` is given), or stdin. The resulting Gemtext goes to stdout.

```
Usage of md2gmn:
-f string
input file
```

## TODO

+ [x] convert Markdown text to Gemtext
+ [ ] prepend contents of YAML front matter to Gemtext data
+ [ ] render all Hugo content files to Gemtext in accordance with front
matter data and Hugo config

## License

This program is redistributed under the terms and conditions of the GNU
General Public License, more specifically under version 3 of the
License. For details, see [COPYING](COPYING).
8 changes: 8 additions & 0 deletions cmd/gmnhg/main.go
@@ -0,0 +1,8 @@
// gmnhg converts Hugo posts to gemini content.
//
// TODO: it is yet to actually do that.
package main

func main() {
println("in development")
}
50 changes: 50 additions & 0 deletions cmd/md2gmn/main.go
@@ -0,0 +1,50 @@
// This file is part of gmnhg.

// gmnhg is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// gmnhg is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with gmnhg. If not, see <https://www.gnu.org/licenses/>.

// md2gmn converts Markdown text files to text/gemini.
package main

import (
"flag"
"io/ioutil"
"os"

gemini "git.tdem.in/tdemin/gmnhg"
)

func main() {
var (
input string
file *os.File
)
flag.StringVar(&input, "f", "", "input file")
flag.Parse()

if input != "" {
var err error
file, err = os.Open(input)
if err != nil {
panic(err)
}
} else {
file = os.Stdin
}
text, err := ioutil.ReadAll(file)
if err != nil {
panic(err)
}

os.Stdout.Write(gemini.RenderMarkdown(text))
}

0 comments on commit 4763bf1

Please sign in to comment.