mobiledoc

package module
v0.0.0-...-93522d8 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: MIT Imports: 6 Imported by: 2

README

Mobiledoc Renderer

MIT License

This is a library for rendering the Mobiledoc format used by Mobiledoc-Kit.

Currently this library only supports rendering to Markdown.

Motivation

This project was created to help with the conversion of Ghost Blog exports to Hugo Blog format, using the tool ghostToHugo. Starting in version 2.0.0 Ghost switched from using Markdown to using Mobiledoc as the underlying format of the post content. This made the conversion tool requirements more complicated since understanding Mobiledoc was now necessary.

Build status

GitHub release Build Status Go Report Card

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Installation

Mobiledoc is a Go package library and is intended to be used by other tools. To make use of this library, you just need to use the go tools to fetch the library and then import into your code.

$ go get -u github.com/jbarone/mobiledoc
package main

import "github.com/jbarone/mobiledoc"

API Reference

GoDocs

Tests

Tests are written using the standard go testing package.

$ go test

Credits

Much credit is given to mobiledoc-markdown-renderer, from which much inspiration for this code was taken.

License

Released under the MIT license.

Documentation

Index

Constants

View Source
const (
	BOLD          = "b"
	CODE          = "code"
	STRONG        = "strong"
	ITALIC        = "i"
	EMPHASIS      = "em"
	H1            = "h1"
	H2            = "h2"
	H3            = "h3"
	H4            = "h4"
	ANCHOR        = "a"
	IMAGE         = "img"
	LISTITEM      = "li"
	BLOCKQUOTE    = "blockquote"
	PARAGRAPH     = "p"
	DIV           = "div"
	ORDEREDLIST   = "ol"
	UNORDEREDLIST = "ul"
	UNDERLINE     = "u"
	SUBSCRIPT     = "sub"
	SUPERSCRIPT   = "sup"
	STRIKETHROUGH = "s"
	TEXT          = ""
)

Tag Types

Variables

This section is empty.

Functions

This section is empty.

Types

type Atom

type Atom func(value string, payload interface{}) string

Atom renders an Atom

type Card

type Card func(payload interface{}) string

Card renders a Card

type Mobiledoc

type Mobiledoc struct {
	// contains filtered or unexported fields
}

Mobiledoc models the data required to render a mobiledoc document

func NewMobiledoc

func NewMobiledoc(src io.Reader) Mobiledoc

NewMobiledoc creates a new Mobiledoc instance

func (*Mobiledoc) Render

func (md *Mobiledoc) Render(w io.Writer) error

Render the Mobiledoc is rendered to the given writer

func (Mobiledoc) WithAtom

func (md Mobiledoc) WithAtom(name string, atom Atom) Mobiledoc

WithAtom creates a new Mobiledoc instance that has a registered Atom

func (Mobiledoc) WithCard

func (md Mobiledoc) WithCard(name string, card Card) Mobiledoc

WithCard creates a new Mobiledoc instance that has a registered Card

Jump to

Keyboard shortcuts

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