decorate

package module
v0.0.0-...-11c9596 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2014 License: MIT Imports: 9 Imported by: 1

README

decorate

Go syntax highlighting framework

Installation

go get github.com/speedata/decorate

How to use decorate?

See the application gohigh for an example: https://github.com/speedata/gohigh

decorate.HighlightFile(inputfile, inputfilter, outputfilter)

where inputfile is the filename (+ path) to the input file, inputfilter the name of the input filter (currently only text and xml are supported) and outputfilter is currently either html or text.

How to contribute?

See the file inputfilter/text/text.go for a sample input filter (a language lexer) and outputfilter/text/text.go for a dummy output filter. Just follow the code there and add an import statement in decorate.go to activate the filter.

Other:

Status: pre alpha
Supported/maintained: yes
Contribution welcome: yes (pull requests, issues)
Main page: https://github.com/speedata/decorate
License: MIT
Contact: gundlach@speedata.de

Documentation

Overview

The package decorate is used to highlight code by passing it though an input filter and output filter. Both filters can be configured.

code -> input filter -> (intermediate format) -> output filter -> output

for example

code.xml -> xml lexer -> html renderer -> output.html

The intermediate format is not visible to the user and only used as a protocol between the input and output filter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Highlight

func Highlight(data []byte, inputfilter string, outputfilter string) (string, error)

func HighlightFile

func HighlightFile(filename string, inputfilter string, outputfilter string) (string, error)

Return a string rendering the given file using the outputfilter and running the inputfilter as a lexer.

func InputFilters

func InputFilters() []string

Return a list of input filters (lexers).

func OutputFilters

func OutputFilters() []string

Return a list of output filters (renderer)

Types

This section is empty.

Directories

Path Synopsis
inputfilter
lua
Syntax highlighting for Lua programs.
Syntax highlighting for Lua programs.
text
Sample input filter (basicly a no-op)
Sample input filter (basicly a no-op)
xml
Syntax highlighting for XML files.
Syntax highlighting for XML files.
outputfilter
debug
Sample output filter for debugging purpose.
Sample output filter for debugging purpose.
html
Package html is an output filter to generate an html chunk wrapped in a div to be highlighted by CSS.
Package html is an output filter to generate an html chunk wrapped in a div to be highlighted by CSS.
text
Sample output filter (basicly a no-op).
Sample output filter (basicly a no-op).
Main controller package for syntax highlighting
Main controller package for syntax highlighting
sanitizer
noop
Just a dummy filter do demonstrate the sanitizers
Just a dummy filter do demonstrate the sanitizers
removeduplicates
Merge two adjacent tokens with the same major and minor number into one token.
Merge two adjacent tokens with the same major and minor number into one token.

Jump to

Keyboard shortcuts

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