Sublime Text 3 users: a python3
branch is also available. Just git checkout python3
from the root of your package installation to use in in ST3. If you upgrade from a previous
ST2 installation or encounter problems with the package, please proceed as detailed below:
https://github.com/n1k0/SublimeHighlight/tree/python3
SublimeHighlight
with Package Control. It should pull the correct branch from Github.This SublimeText2 package allows to highlight & export currently edited code to HTML or RTF using Pygments.
Several commands are added to SublimeText2 when installed:
This latter command, Copy to clipboard as RTF, allows to copy and paste highlighted code from Sublime Tex 2 to other softwares like Powerpoint, Keynotes, Word, etc.
You can find a dedicated user settings file in the Preferences > Package Settings > SublimeHighlight
menu where you can customize Pygments settings:
Sample Settings - User
file:
{
"theme": "monokai",
"linenos": "inline",
"noclasses": true,
"fontface": "Menlo"
}
Check out the available options below.
You can choose the Pygments theme to use by setting the theme
option:
{
"theme": "vim"
}
Available themes are:
autumn
borland
bw
colorful
default
emacs
friendly
fruity
manni
monokai
murphy
native
pastie
perldoc
rrt
tango
trac
vim
vs
Here's a screenshot of what some example code looks like with different themes:
Note: You can add your own pygments files by copying the _theme_.py
to Packages/Highlight/pygments/styles
, and adding your theme to the STYLES_MAP
in SublimeHighlight/pygments/styles/__init__.py
. Eg.:
# Maps style names to 'submodule::classname'.
STYLE_MAP = {
'default': 'default::DefaultStyle',
'mytheme': 'mytheme::MyThemeStyle',
}
You can add line numbering by setting the linenos
option:
{
"linenos": "inline"
}
Accepted values for the linenos
option are table
, inline
or false
— the latter being the default.
You can set the rendered HTML code to use inline styles instead of CSS classes:
{
"noclasses": true
}
SublimeHighlight supports Pygments lexer options. To set an option for a given lexer, eg. PHP
:
{
"lexer_options": {
"PHP": {
"startinline": true
}
}
}
You can set font face used in RTF output by using the fontface setting.
{
"fontface": "Menlo"
}
This is a sample key binding for copying RTF highlighted code contents to your clipboard by pressing ctrl + alt + c:
[
{ "keys": ["ctrl+alt+c"],
"command": "sublime_highlight",
"args": { "target": "clipboard",
"output_type": "rtf"
}},
]
You can combine the target
and output_type
argument values to achieve the stuff you want. Possible values are:
target
:
sublime
: new Sublime Text 2 tabexternal
: new external fileclipboard
: system clipboardoutput_type
:
rtf
: RTF formathtml
: HTML formatMostly for toying around with SublimeText2 plugin API (which is great), but also to ease the process of copying/pasting richly formatted code over softwares like Powerpoint, Word, Keynote and shits like that.
This software is released under the terms of the MIT license.