markdown

package module
v0.0.0-...-f3381c4 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2015 License: MIT Imports: 6 Imported by: 1

README

markdown

A markdown parser library for Go. Used to power etherealmachine.github.io.

Major features
Inline HTML

Markdown was designed to let you easily fallback to raw HTML. This is great, but it limits you when you want to mix HTML and Markdown. For example, if you try wrapping some Markdown in a div for styling:

<div style="float: left;">
# Some header
More markdown, maybe with *emphasis*
</div>

The Markdown passes right through without being parsed, like so:

<div style="float: left;">
# Some header
More markdown, maybe with *emphasis*
</div>

Ethereal Markdown parses the text inside the div, letting you mix Markdown inside your usual HTML:

<div style="float: left;">
  <h1>Some header</h1>
  <p>More markdown, maybe with <em>emphasis</em></p>
</div>
Directives

Sometimes you need a little more control over the HTML generated by the parser. For example, Github-Flavored Markdown (GFM) can produce awesome tables:

Col1 | Col2
---- | ----
Foo  | Bar

Turns into:

<table>
  <tr><th>Col1></th><th>Col2</th></tr>
  <tr><td>Foo></td><td>Bar</td></tr>
</table>

But if you're using Bootstrap, or some other CSS library, you need to add class="table" to your tables, and you're SOL.

In Ethereal Markdown, you can use the table directive:

<!--table class="table"-->
Col1 | Col2
---- | ----
Foo  | Bar

To get :

<table class="table">
  <tr><th>Col1></th><th>Col2</th></tr>
  <tr><td>Foo></td><td>Bar</td></tr>
</table>
Differences from Github-Flavored Markdown
  • No URL autolinking
  • No strikethrough
  • Syntax highlighting: The optional language identifier is added as a class on the block's pre tag
  • Tables: Cannot use pipes on the table end
Differences from plain Markdown
  • Headers only accept the Atx # format (e.g. # Header
  • No horizontal rules
  • No automatic links

Documentation

Index

Constants

View Source
const (
	EOF = iota
	H1
	H2
	H3
	H4
	H5
	H6
	EM
	STRONG
	NEWLINE
	TEXT
	LINK_TEXT
	IMG_ALT
	HREF
	CODE
	HTML_TAG
	CODE_BLOCK
	ORDERED_LIST
	UNORDERED_LIST
	MATHML
	TD
)

Variables

This section is empty.

Functions

func Markdown

func Markdown(input string) string

func Parse

func Parse(input string) []*html.Token

func PrettyPrint

func PrettyPrint(tokens []*html.Token) string

Types

type ErrUnexpectedToken

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

func (ErrUnexpectedToken) Error

func (e ErrUnexpectedToken) Error() string

type Parser

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

type Scanner

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

func NewScanner

func NewScanner(src string) *Scanner

func (*Scanner) Next

func (s *Scanner) Next() *Token

type Token

type Token struct {
	Type TokenType
	Lit  string
	Raw  string
}

func (*Token) String

func (t *Token) String() string

type TokenType

type TokenType int

func (TokenType) String

func (t TokenType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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