orange

package module
Version: v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2015 License: MIT Imports: 16 Imported by: 4

README

orange-cat

buildstatus

A Markdown previewer written in Go

Why orange-cat?

GitHub suggested naming it as orange-cat.

Great repository names are short and memorable. Need inspiration? How about orange-cat.

GitHub is always right and I had to obey it.

Demo

demo

How it works

To launch orange-cat, simply run the orange command.

$ orange README.md
Listening :6060 ...

Then orange-cat will start watching the Markdown file and open a browser window where the preview of the file will be displayed. You can also open http://localhost:6060/some_file.md manually.

When you modify the file, orange-cat watcher will catch the modification and send the modified data to the browser through a websocket connection. It means, you don't even need to refresh the page.

To stop it, simply enter ^C.

Why another Markdown preview?

I know there're already plenty of Markdown previewers, such as Atom's Markdown preview package, some Vim plugins and other web-based or desktop apps.

However, I don't use any modern IDE or editor. I love Vim. There must be people who love their own prefered editors, like me. I wanted to make a previewer running offline, with any editor, without any dependency.

This is a binary executable, not a script. We don't need any gem, npm or pip to use this. How to use is completely up to you.

I sincerely hope you like orange-cat :)

Install

You can download binaries for your environment in Releases.

If you're using Go, you can just go get orange-cat.

$ go get github.com/noraesae/orange-cat/cmd/orange

If you prefer building from source, it's also very easy.

$ cd $GOPATH/src/github.com/noraesae
$ git clone git@github.com:noraesae/orange-cat.git
$ cd orange-cat
$ make build

The binary orange will be created at $GOPATH/bin/orange.

Custom CSS

orange-cat will try to find a custom CSS file from ~/.orange-cat.css. If there's no custom CSS file, it'll use a default CSS style, which shows a similar output to GitHub's one.

Contribution

I welcome every kind of contribution.

If you have any problem using orange-cat, please file an issue in Issues.

If you'd like to contribute on source, please upload a pull request in Pull Requests. Please don't forget to check if it's gofmt'ed and passes every test before uploading a new pull request. It can be done with following commands.

$ make fmt # gofmt for every source code
$ make test # run Ginkgo test suite

If needed, please add a new test case with your patch.

License

MIT

Documentation

Index

Constants

View Source
const (
	ListeningTestInterval = 500
	MaxListeningTestCount = 10
)
View Source
const (
	MarkdownChanSize = 3
	Version          = "0.2.2"
)
View Source
const (
	WatcherInterval = 500
	DataChanSize    = 10
)
View Source
const (
	WriteTimeout = 5 * time.Second
	BufferSize   = 2048
)

Variables

View Source
var DefaultStyle = `` /* 7125-byte string literal not displayed */
View Source
var MdConverter = NewMarkdownConverter()

Global Converter

Functions

func CustomCSS added in v0.2.0

func CustomCSS() (*string, error)

func Template

func Template(w http.ResponseWriter, filepath string)

Types

type DataChan

type DataChan struct {
	Raw chan *[]byte
	Req chan bool
}

type HTTPServer

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

func NewHTTPServer

func NewHTTPServer(port int) *HTTPServer

func (*HTTPServer) Addr added in v0.2.0

func (s *HTTPServer) Addr() string

func (*HTTPServer) Listen

func (s *HTTPServer) Listen()

func (*HTTPServer) ListenAndServe

func (s *HTTPServer) ListenAndServe()

func (*HTTPServer) ServeHTTP

func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HTTPServer) ServeStatic added in v0.2.0

func (s *HTTPServer) ServeStatic(w http.ResponseWriter, path string)

func (*HTTPServer) Stop

func (s *HTTPServer) Stop()

type MarkdownConverter added in v0.2.0

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

func NewMarkdownConverter added in v0.2.0

func NewMarkdownConverter() *MarkdownConverter

func (*MarkdownConverter) Convert added in v0.2.0

func (md *MarkdownConverter) Convert(raw []byte) []byte

func (*MarkdownConverter) UseBasic added in v0.2.0

func (md *MarkdownConverter) UseBasic()

type Orange

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

func NewOrange

func NewOrange(port int) *Orange

func (*Orange) Run

func (o *Orange) Run(files ...string)

func (*Orange) Stop

func (o *Orange) Stop()

func (*Orange) UseBasic

func (o *Orange) UseBasic()

type Watcher

type Watcher struct {
	C *DataChan
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher(path string) *Watcher

func (*Watcher) Start

func (w *Watcher) Start()

func (*Watcher) Stop

func (w *Watcher) Stop()

type Websocket

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

func NewWebsocket

func NewWebsocket(path string) *Websocket

func (*Websocket) Reader

func (ws *Websocket) Reader(c *goWs.Conn, closed chan<- bool)

func (*Websocket) Serve

func (ws *Websocket) Serve(w http.ResponseWriter, r *http.Request)

func (*Websocket) Writer

func (ws *Websocket) Writer(c *goWs.Conn, closed <-chan bool)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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