README

highlight_diff

Build Status GoDoc

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.

Installation

go get -u github.com/shurcooL/highlight_diff

License

Expand ▾ Collapse ▴

Documentation

Overview

    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

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func Annotate

    func Annotate(src []byte) (annotate.Annotations, error)
    Example
    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

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

    func Print

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

    Types

    type HTMLAnnotator

    type HTMLAnnotator HTMLConfig

    func (HTMLAnnotator) Annotate

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

    type HTMLConfig

    type HTMLConfig []string

    type HTMLPrinter

    type HTMLPrinter HTMLConfig

    func (HTMLPrinter) Print

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

    type Scanner

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

    func NewScanner

    func NewScanner(src []byte) *Scanner

    func (*Scanner) Err

    func (s *Scanner) Err() error

    func (*Scanner) Scan

    func (s *Scanner) Scan() bool

    func (*Scanner) Token

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

    Source Files