Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
7 changed files
with
1,128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} |
Oops, something went wrong.