Skip to content

boyter/searchcode-server-highlighter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A very simple Go HTTP based Syntax highlighter. Run it, then post some code to the default port and it will return CSS + HTML syntax highlighted code.

Build Status Scc Count Badge

Build step to create smallest builds

GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" && upx searchcode-server-highlighter.exe && mv searchcode-server-highlighter.exe searchcode-server-highlighter-x86_64-pc-windows.exe
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" && upx searchcode-server-highlighter && mv searchcode-server-highlighter searchcode-server-highlighter-x86_64-unknown-linux
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" && upx searchcode-server-highlighter && mv searchcode-server-highlighter searchcode-server-highlighter-x86_64-apple-darwin

The resulting build for each file should be ~3 MB

Sample Usage

Install httpie and jq, then run the following snippet to generate a local HTML file.

FILE=$GOPATH/src/github.com/boyter/searchcode-server-highlighter/main.go
LANG=go
STYLE=tango

# send up the file
http POST localhost:8089/v1/highlight/ languageName=$LANG fileName=$(basename $FILE) style=$STYLE content=@$FILE > res

# munch results
CSS=$(cat res| jq --raw-output .css  | sed 's/\\n/\n/g')
HTML=$(cat res| jq --raw-output .html | sed 's/\\n/\n/g')

cat  << EOF > $(basename $FILE).html
<!DOCTYPE html>
<html>
<head>
<style>
$CSS
</style>
</head>
<body>
$HTML
</body>
</html>
EOF

echo "Done: $(basename $FILE).html"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published