Skip to content

burinc/viip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4ca9cd7 · May 29, 2024

History

8 Commits
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Jan 27, 2024
Mar 7, 2023
Mar 17, 2023
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Mar 17, 2023
May 29, 2024
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023
Mar 7, 2023

Repository files navigation

VIIP - VIm Interactive Printer

Print any source code using Vim. Ported of my original Ruby's source2pdf to Clojure.

Requirement

  • Working installation of wkhtmltopdf
  • Working installation of ghostscript
  • Working installation of Vim with appropriate colorscheme
  • Working installation of xpdfreader needed for pdfinfo command
  • Working installation of GraalVM need to build native-image - need to set GRAALVM_HOME

For OSX:

brew install wkhtmltopdf \
             ghostscript \
             xpdf

curl -O https://dl.xpdfreader.com/xpdf-tools-mac-4.05.tar.gz

Development/Build

bb tasks
clean
build                     Build classes and uberjar
graalvm                   Checks GRAALVM_HOME env var
native-image-uber         Builds native image from uber
native-image-uber-test    Run native image built from uber
native-image-classes      Builds native image from classes
native-image-classes-test Run native image built from classes
native-image-test         Run integration tests

Then try the following:

bb clean
bb build
bb native-image-test

# If things goes as plan then you would get the native binary in ./target/viip
# You can optionally copy this to your $PATH e.g. ~/bin
mkdir -p ~/bin
\cp ./target/viip ~/bin/viip

Basic Usage

Help

Usage:
  viip [options] --base-dir=<base-dir> --exts=<exts> --output-file=<output-file> [ --preset=<preset> | --color-scheme=<color-scheme> --font-name=<font-name> ]
  viip --list-presets
  viip --version
  viip --help

Options:
  -b, --base-dir=<base-dir>          Base directory [default: .]
  -e, --exts=<exts>                  Extension to print [default: clj,cljc,cljs ]
  -p, --preset=<preset>              Preset to use [default: seoul256-dark]
  -o, --output-file=<output-file>    Output file [default: codes.pdf]
  -c, --color-scheme=<color-scheme>  Color scheme to use [default: jellybeans]
  -f, --font-name=<font-name>        Font name to use [default: Fira Code]
  -z, --paper-size=<paper-size>      Output paper size to use [default: letter]
  -n, --line-numbers                 Print line numbers
  -t, --title=<title>                Title to use [default: vim-interactive-printer]
  -a, --author=<author>              Author for the document [default: viip]
  -s, --tags=<tags>                  Tags to use [default: codes,pdf,command-line]
  -l, --list-presets                 List available presets
  -h, --help                         Print help
  -v, --version                      Display version information

  # ------------------------------------------------------------ ##
  # Common Usage:
  # ------------------------------------------------------------ ##
  ~/bin/viip -b . -e clj,cljc,cljs -c github -f "Fira Code"       -t viip-demo -a viip -o code-github-fira-code.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c github -f "Fira Code Mono"  -t viip-demo -a viip -o code-github-fira-code-mono.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c github -f "Inconsolata"     -t viip-demo -a viip -o code-github-inconsolata.pdf

  ~/bin/viip -b . -e clj,cljc,cljs -c envy -f "Fira Code"       -t viip-demo -a viip -o code-envy-fira-code.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c envy -f "Fira Code Mono"  -t viip-demo -a viip -o code-envy-fira-code-mono.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c envy -f "Inconsolata"     -t viip-demo -a viip -o code-envy-inconsolata.pdf

  ~/bin/viip -b . -e clj,cljc,cljs -c onehalflight -f "Fira Code"      -t viip -a "Vim Interactive Printer" -o code-onehalflight-fira-code.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c onehalflight -f "Fira Code Mono" -t viip -a "Vim Interactive Printer" -o code-onehalflight-fira-code-mono.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c onehalflight -f "Inconsolata"    -t viip -a "Vim Interactive Printer" -o code-onehalflight-inconsolata.pdf

  ~/bin/viip -b . -e clj,cljc,cljs -c onehalfdark -f "Fira Code"       -t viip -a "Vim Interactive Printer" -o code-onehalfdark-fira-code.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c onehalfdark -f "Fira Code Mono"  -t viip -a "Vim Interactive Printer" -o code-onehalfdark-fira-code-mono.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c onehalfdark -f "Inconsolata"     -t viip -a "Vim Interactive Printer" -o code-onehalfdark-inconsolata.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c onehalfdark -f "Fira Code"       -t viip -a "Vim Interactive Printer" -o code-onehalfdark-fira-code.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c onehalfdark -f "Fira Code Mono"  -t viip -a "Vim Interactive Printer" -o code-onehalfdark-fira-code-mono.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c onehalfdark -f "Inconsolata"     -t viip -a "Vim Interactive Printer" -o code-onehalfdark-inconsolata.pdf

  ~/bin/viip -b . -e clj,cljc,cljs -c jellybeans  -f "Fira Code"       -t viip -a "Vim Interactive Printer" -o code-jellybeans-fira-code.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c jellybeans  -f "Fira Code Mono"  -t viip -a "Vim Interactive Printer" -o code-jellybeans-fira-code-mono.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c jellybeans  -f "Inconsolata"     -t viip -a "Vim Interactive Printer" -o code-jellybeans-inconsolata.pdf

  ~/bin/viip -b . -e clj,cljc,cljs -c PaperColor -f "Fira Code"       -t viip-demo -a "Vim Interactive Printer" -o code-papercolor-fira-code.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c PaperColor -f "Fira Code Mono"  -t viip-demo -a "Vim Interactive Printer" -o code-papercolor-fira-code-mono.pdf
  ~/bin/viip -b . -e clj,cljc,cljs -c PaperColor -f "Inconsolata"     -t viip-demo -a "Vim Interactive Printer" -o code-papercolor-inconsolata.pdf

  # ------------------------------------------------------------ ##
  ## Show help
  viip -h

  # ------------------------------------------------------------ ##
  ## Show version
  viip -v

Example

~/bin/viip -b . -e clj -p seoul256-dark -z letter -t "Vim Printer Demo" -o viip-codes.pdf -x /Users/bchoomnuan/codes/b12n-viip/resources/pdfmarks.tmpl

Which generate the output in the screenshot above.