golst is a Go command line tool for generating readable program
listings. It was inspired by Luke Gorries' post
and, in particular, his
Listings that are written to a file are written as <file.go>.<format>; for
example, producing listings for
- markdown ->
- HTML ->
- PDF ->
To produce an HTML listing for
golst -o html listing.go
This will produce
listing.go.html, which is a standalone page. The template for this page is contained in the
html.gosource file, and is taken from my site tyrfingr.
To produce a PDF listing for
golst -o pdf pandoc.go
Similar to the previous example, this will produce the PDF file
To produce a markdown listing for
html.goand have this printed to standard output:
golst -o - html.go
You can produce listings for multiple files at the same time:
golst -o pdf *.go
If you ran this on the
golstdirectory, you would have
Supported Output Formats
Standalone listings are generated; the following formats (selected with
-o flag) are supported:
- html - generate HTML listing
- latex - uses pandoc to convert the markdown to a LaTeX listing.
- md - generate markdown listing
- pdf - uses pandoc to convert the markdown to a PDF listing.
- tex - rudimentary pure-Go TeX listing.
blackfridayfor producing HTML from the listing. This will automatically be pulled in by
pandocis required for conversion to PDF.
golst is released under an ISC license. For details, see
LICENSE in the source repository.