mdopen

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

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 11 Imported by: 0

README

mdopen

Allows to view markdown files in the default browser. For more details, see the API documentation.

CLI

Install:

go get gopkg.in/romanyx/mdopen.v1/cmd/mdopen

Create a markdown file:

echo "# Hello from markdown" > hello.md

View it in the default browser as html:

mdopen hello.md

Library

Install:

go get github.com/mdwhatcott/mdopen
package main

import "github.com/mdwhatcott/mdopen"

func main() {
    f := strings.NewReader("# Hello from markdown")

    opener := mdopen.New()
    if err := opener.Open(f); err != nil {
        log.Fatal(err)
    }
}

Documentation

Index

Constants

View Source
const Template = `` /* 223-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type Opener

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

Opener holds layout and command name to open default browser. Use New function to initialize correct one.

func New

func New(options ...Option) *Opener

New returns initialized Opener.

func (*Opener) Open

func (this *Opener) Open(f io.Reader) error

Open will create a tmp file, execute layout template with given markdown into it and then open it in browser.

type Option

type Option func(*Opener)

Option for initializer.

func ParseTemplate

func ParseTemplate() Option

ParseTemplate option sets layout as github.com template.

Directories

Path Synopsis
cmd
mdopen command

Jump to

Keyboard shortcuts

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