Highlight Source code Paste Into Keynote

Kimi
2 min readJun 28, 2021

--

Highlight converts sourcecode to HTML, XHTML, RTF, LaTeX, TeX, SVG, BBCode and terminal escape sequences with coloured syntax highlighting.‌

You can paste result into keynote.

ps. source code to image, online tool https://carbon.now.sh/

Installation

brew install highlight‌

Examples

1. Show result in terminal

highlight -O rtf -S go -K 24 -k Courier-Bold -s Moria main.go -l

argument

http://www.andre-simon.de/doku/highlight/en/highlight.php

-O, --out-format=<format>      output file in given format<format>=[html, xhtml, latex, tex, odt, rtf,ansi, xterm256, truecolor, bbcode, pango, svg]-S, --syntax=<type|path>       specify type of source code or syntax file path--syntax-by-name=<name>    specify type of source code by given namewill not read a file of this name, useful for stdin-K, --font-size=<num?>         set font size (specific to output format)-k, --font=<font>              set font (specific to output format)-s, --style=<style|path>       set colour style (theme) or theme file path-l, --line-numbers             print line numbers in output file

‌more style samples

http://www.andre-simon.de/doku/highlight/en/syntax-samples.php

2. Output result into your clipboard

highlight -O rtf -S go -K 24 -k Courier-Bold -s Moria main.go -l | pbcopy

3. Create command as : hpas‌

You can copy your code and run command hpas go. It will auto generate highlight code, then paste it to keynote or other.‌

1. create a file name hpas

pbpaste | highlight -O rtf -S $1 -K 24 -k Courier-Bold --style Moria -l | pbcopy

2. run vi ~/.zshrc

export PATH="$PATH:/Users/kimiimac/myscript"

3. run source ~/.zshrc

Result

Reference

--

--