highlight_diff: github.com/shurcooL/highlight_diff Index | Examples | Files

package highlight_diff

import "github.com/shurcooL/highlight_diff"

Package highlight_diff provides syntaxhighlight.Printer and syntaxhighlight.Annotator implementations for diff format. It implements intra-block character-level inner diff highlighting.

It uses GitHub Flavored Markdown .css class names "gi", "gd", "gu", "gh" for outer blocks, "x" for inner emphasis blocks.

Index

Examples

Package Files

main.go

func Annotate Uses

func Annotate(src []byte) (annotate.Annotations, error)

Code:

anns, err := highlight_diff.Annotate([]byte(`@@ -1,6 +1,6 @@
 language: go
 go:
-  - 1.4
+  - 1.5
 install:
   - go get golang.org/x/tools/cmd/vet
 script:
`))
if err != nil {
    panic(err)
}

goon.DumpExpr(len(anns))
for _, ann := range anns {
    goon.DumpExpr(ann.Start, ann.End)
    goon.DumpExpr(string(ann.Left), string(ann.Right))
    goon.DumpExpr(ann.WantInner)
}

Output:

len(anns) = (int)(1)
ann.Start = (int)(0)
ann.End = (int)(16)
string(ann.Left) = (string)("<span class=\"gu input-block\">")
string(ann.Right) = (string)("</span>")
ann.WantInner = (int)(0)

func HighlightedDiffFunc Uses

func HighlightedDiffFunc(leftContent, rightContent string, segments *[2][]*annotate.Annotation, offsets [2]int)

func Print Uses

func Print(s *Scanner, w io.Writer) error

type HTMLAnnotator Uses

type HTMLAnnotator HTMLConfig

func (HTMLAnnotator) Annotate Uses

func (a HTMLAnnotator) Annotate(start int, kind syntaxhighlight.Kind, tokText string) (*annotate.Annotation, error)

type HTMLConfig Uses

type HTMLConfig []string

type HTMLPrinter Uses

type HTMLPrinter HTMLConfig

func (HTMLPrinter) Print Uses

func (p HTMLPrinter) Print(w io.Writer, kind syntaxhighlight.Kind, tokText string) error

type Scanner Uses

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

func NewScanner Uses

func NewScanner(src []byte) *Scanner

func (*Scanner) Err Uses

func (s *Scanner) Err() error

func (*Scanner) Scan Uses

func (s *Scanner) Scan() bool

func (*Scanner) Token Uses

func (s *Scanner) Token() ([]byte, syntaxhighlight.Kind)

Package highlight_diff imports 7 packages (graph) and is imported by 2 packages. Updated 2017-05-18. Refresh now. Tools for package owners.