gemini

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2021 License: GPL-3.0 Imports: 8 Imported by: 1

README

Hugo-to-Gemini converter

PkgGoDev

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

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 library for parsing Markdown. gomarkdown has a few quirks at this time, the most notable one being unable to parse links/images inside other links.

gmnhg

This program converts Hugo Markdown content files from content/ in accordance with templates found in gmnhg/ to the output dir. It also copies static files from static/ to the output dir.

For more details about the rendering process, see the doc attached to the program.

Usage of gmnhg:
  -output string
        output directory (will be created if missing) (default "output/")
  -working string
        working directory (defaults to current directory)

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

md2gmn is mainly made to facilitate testing the Gemtext renderer but can be used as a standalone program as well.

License

This program is redistributed under the terms and conditions of the GNU General Public License, more specifically version 3 of the License. For details, see COPYING.

Documentation

Overview

Package gemini provides functions to convert Markdown files to Gemtext. It supports the use of YAML front matter in Markdown.

Index

Constants

This section is empty.

Variables

View Source
var ErrPostIsDraft = errors.New("post is draft")

ErrPostIsDraft indicates the post rendered is a draft and is not supposed to be rendered.

Functions

This section is empty.

Types

type HugoMetadata

type HugoMetadata struct {
	PostTitle   string    `yaml:"title"`
	PostIsDraft bool      `yaml:"draft"`
	PostLayout  string    `yaml:"layout"`
	PostDate    time.Time `yaml:"date"`
}

HugoMetadata implements gemini.Metadata, providing the bare minimum of possible post props.

func RenderMarkdown

func RenderMarkdown(md []byte, settings Settings) (geminiText []byte, metadata HugoMetadata, err error)

RenderMarkdown converts Markdown text to Gemtext using gomarkdown. It appends Hugo YAML front matter data to the post header if WithMetadata is set.

Only a subset of front matter data parsed by Hugo is included in the final document. At this point it's just title and date.

Draft posts are still rendered, but with an error of type ErrPostIsDraft.

func (HugoMetadata) Date

func (h HugoMetadata) Date() time.Time

Date returns post date.

func (HugoMetadata) Title

func (h HugoMetadata) Title() string

Title returns post title.

type Settings added in v0.1.1

type Settings uint

Settings is a bitmask for renderer preferences.

const (
	// Defaults simply renders the document.
	Defaults Settings = 0b0
	// WithMetadata indicates that the metadata should be included in
	// the text produced by the renderer.
	WithMetadata Settings = 0b1
)

func (Settings) Has added in v0.1.1

func (s Settings) Has(setting Settings) bool

Has uses AND to check whether a flag is set.

Directories

Path Synopsis
cmd
gmnhg
gmnhg converts Hugo content files to a Gemini site.
gmnhg converts Hugo content files to a Gemini site.
md2gmn
md2gmn converts Markdown text files to text/gemini.
md2gmn converts Markdown text files to text/gemini.
internal
gemini
Package gemini contains an implementation of markdown => text/gemini renderer for github.com/gomarkdown/markdown.
Package gemini contains an implementation of markdown => text/gemini renderer for github.com/gomarkdown/markdown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL