mklink

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

README

Build Status GitHub license

Install

$ go get github.com/spiegel-im-spiegel/mklink

Installing by dep.

$ dep ensure -add github.com/spiegel-im-spiegel/mklink

Usage

link, err := mklink.New("https://git.io/vFR5M")
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(link.Encode(mklink.StyleMarkdown))
// Output:
// [GitHub - spiegel-im-spiegel/mklink: Make Link with Markdown Format](https://github.com/spiegel-im-spiegel/mklink)

Command Line Interface

$ mklink -h
Usage:
  mklink [flags] [URL [URL]...]

Flags:
  -h, --help           help for mklink
  -i, --interactive    interactive mode
      --log string     output log
  -s, --style string   link style (default "markdown")
  -v, --version        output version of mklink
$ mklink https://git.io/vFR5M
[GitHub - spiegel-im-spiegel/mklink: Make Link with Markdown Format](https://github.com/spiegel-im-spiegel/mklink)
$ echo https://git.io/vFR5M | mklink
[GitHub - spiegel-im-spiegel/mklink: Make Link with Markdown Format](https://github.com/spiegel-im-spiegel/mklink)
$ mklink --log log.txt https://git.io/vFR5M
[GitHub - spiegel-im-spiegel/mklink: Make Link with Markdown Format](https://github.com/spiegel-im-spiegel/mklink)

$ cat log.txt
[GitHub - spiegel-im-spiegel/mklink: Make Link with Markdown Format](https://github.com/spiegel-im-spiegel/mklink)
Interactive Mode
$ mklink -i
Input 'q' or 'quit' to stop
mklimk> https://git.io/vFR5M
[GitHub - spiegel-im-spiegel/mklink: Make Link with Markdown Format](https://github.com/spiegel-im-spiegel/mklink)
mklimk>
Support Other Style
$ mklink -s html https://git.io/vFR5M
<a href="https://github.com/spiegel-im-spiegel/mklink">GitHub - spiegel-im-spiegel/mklink: Make Link with Markdown Format</a>

Support: markdown, wiki, html, csv

Dependencies

dep status -dot | dot -Tpng -o dependency.png

Dependencies

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	//ErrNoImplement is error "no implementation"
	ErrNoImplement = errors.New("no implementation")
)

Functions

func StyleList

func StyleList() string

StyleList returns string Style list

func ToUTF8 added in v0.1.7

func ToUTF8(body []byte) string

ToUTF8 returns string with UTF-8 encoding

Types

type CharEncode added in v0.1.7

type CharEncode int

CharEncode is type of character encoding

const (
	//CharUnknown is unknown character
	CharUnknown CharEncode = iota
	//CharUTF8 is UTF-8
	CharUTF8
	//CharISO8859_1 is ISO-8859-1
	CharISO8859_1
	//CharShiftJIS is Shift-JIS
	CharShiftJIS
	//CharEUCJP is EUC-JP
	CharEUCJP
	//CharISO2022JP is ISO-2022-JP
	CharISO2022JP
)

func DetectCharEncode added in v0.1.7

func DetectCharEncode(body []byte) CharEncode

DetectCharEncode returns character encoding

func TypeofCharEncode added in v0.1.7

func TypeofCharEncode(s string) CharEncode

TypeofCharEncode returns CharEncode from string

func (CharEncode) String added in v0.1.7

func (e CharEncode) String() string
type Link struct {
	URL         string `json:"url,omitempty"`
	Location    string `json:"location,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
}

Link class is information of URL

func New

func New(url string) (*Link, error)

New returns new Link instance

Example
link, err := New("https://git.io/vFR5M")
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(link.Encode(StyleMarkdown))
Output:

[GitHub - spiegel-im-spiegel/mklink: Make Link with Markdown Format](https://github.com/spiegel-im-spiegel/mklink)

func (*Link) Encode

func (lnk *Link) Encode(t Style) io.Reader

Encode returns string (io.Reader) with other style

func (*Link) JSON

func (lnk *Link) JSON() (io.Reader, error)

JSON returns string (io.Reader) with JSON format

func (*Link) String

func (lnk *Link) String() string

func (*Link) TitleName

func (lnk *Link) TitleName() string

TitleName returns string of title name

type Style

type Style int

Style as link style

const (
	//StyleUnknown is unknown link style
	StyleUnknown Style = iota
	//StyleMarkdown is unknown markdown style
	StyleMarkdown
	//StyleWiki is unknown wiki style
	StyleWiki
	//StyleHTML is unknown HTML anchor style
	StyleHTML
	//StyleCSV is CSV data format
	StyleCSV
)

func GetStyle

func GetStyle(s string) (Style, error)

GetStyle returns Style from string

func (Style) String

func (t Style) String() string

Directories

Path Synopsis
cli
mklink command

Jump to

Keyboard shortcuts

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