I recently needed to print out all the code associated with a project. Whilst I could've copied everything from my IDE to a word processor, I thought it might be nice to have a tool that could do this for me, highlighting the code along the way.
Install it globally using npm or Yarn.
npm i -g @mrbbot/hilite
yarn global add @mrbbot/hilite
To highlight all files in the src
directory, and output index.html
and index.pdf
in the current directory run the
following command:
hilite src
You can specify as many locations to highlight so if you also wanted to highlight files in the dist
directory:
hilite src dist
You can also specify globs to match:
hilite src/**/*.js
Hilite will also include png, jpeg, gif and svg images in the output if they're matched.
If you want to change the output file names, you can use the --output
(-o
) flag. For example, the following command
will output to code.html
and code.pdf
instead of the normal index
:
hilite src -o code
Additionally, if you're just looking for HTML output, you can disable the PDF export with the --pdf
(-p
) flag:
hilite src -p false
This will only generate an index.html
file.
Hilite uses Prism for code highlighting, so if you don't like the default theme, you can easily change it using the --theme
(-t
) flag to either one of the
presets, or your own custom one.
If you wanted to change the output to use the funky theme:
hilite src -t funky
Other available presets are:
If you had a custom theme stored in theme.css
, you could use it with the following command:
hilite src -t theme.css
Finally, you can also change the amount of margin in the PDF export using the --margin
(-m
) flag.
hilite src -m 1in
You must include the unit in your value.