markdown

package
v0.0.0-...-c8f16ef Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 8 Imported by: 56

Documentation

Overview

Package markdown provides a Markdown renderer.

Example
package main

import (
	"log"
	"os"

	"github.com/shurcooL/markdownfmt/markdown"
)

func main() {
	input := []byte(`Title
=

This is a new paragraph. I wonder    if I have too     many spaces.
What about new paragraph.
But the next one...

  Is really new.

1. Item one.
1. Item TWO.


Final paragraph.
`)

	output, err := markdown.Process("", input, nil)
	if err != nil {
		log.Fatalln(err)
	}

	os.Stdout.Write(output)

}
Output:

Title
=====

This is a new paragraph. I wonder if I have too many spaces. What about new paragraph. But the next one...

Is really new.

1.	Item one.
2.	Item TWO.

Final paragraph.
Example (Two)
package main

import (
	"log"
	"os"

	"github.com/shurcooL/markdownfmt/markdown"
)

func main() {
	input := []byte(`Title
==

Subtitle
---

How about ` + "`this`" + ` and other stuff like *italic*, **bold** and ***super    extra***.
`)

	output, err := markdown.Process("", input, nil)
	if err != nil {
		log.Fatalln(err)
	}

	os.Stdout.Write(output)

}
Output:

Title
=====

Subtitle
--------

How about `this` and other stuff like *italic*, **bold** and ***super extra***.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRenderer

func NewRenderer(opt *Options) blackfriday.Renderer

NewRenderer returns a Markdown renderer. If opt is nil the defaults are used.

func Process

func Process(filename string, src []byte, opt *Options) ([]byte, error)

Process formats Markdown. If opt is nil the defaults are used. Error can only occur when reading input from filename rather than src.

Types

type Options

type Options struct {
	// Terminal specifies if ANSI escape codes are emitted for styling.
	Terminal bool
}

Options specifies options for formatting.

Jump to

Keyboard shortcuts

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