• This repository has been archived on 10/Nov/2017
  • Stars
    star
    788
  • Rank 57,762 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A humble SublimeText package for exporting highlighted code as RTF or HTML

SublimeHighlight

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:

  • Remove the package, if installed, using Package Control.
  • Add a repository: https://github.com/n1k0/SublimeHighlight/tree/python3
  • Install SublimeHighlight with Package Control. It should pull the correct branch from Github.
  • Restart Sublime Text 3

This SublimeText2 package allows to highlight & export currently edited code to HTML or RTF using Pygments.

Several commands are added to SublimeText2 when installed:

  • SublimeHighlight: convert to HTML: will convert current code to highlighted HTML in a new SublimeText tab.
  • SublimeHighlight: convert to RTF: will convert current code to highlighted RTF in a new SublimeText tab.
  • SublimeHighlight: view as HTML: will convert current code to highlighted HTML and open it in your default browser.
  • SublimeHighlight: view as RTF: will convert current code to an RTF document and open the generated file with your default program.
  • SublimeHighlight: copy to clipboard as HTML: will convert current code to highlighted HTML and store it into the system clipboard.
  • SublimeHighlight: copy to clipboard as RTF: will convert current code to raw highlighted RTF and store it into the system clipboard.

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.

capture

Settings

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.

Themes

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:

Themes Screenshot

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',
}

Line numbering

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.

Inline styling

You can set the rendered HTML code to use inline styles instead of CSS classes:

{
    "noclasses": true
}

Lexer options

SublimeHighlight supports Pygments lexer options. To set an option for a given lexer, eg. PHP:

{
    "lexer_options": {
        "PHP": {
            "startinline": true
        }
    }
}

Font face

You can set font face used in RTF output by using the fontface setting.

{
    "fontface": "Menlo"
}

Setting up shortcuts

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 tab
  • external: new external file
  • clipboard: system clipboard

output_type:

  • rtf: RTF format
  • html: HTML format

Why this package?

Mostly 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.

License

This software is released under the terms of the MIT license.

More Repositories

1

tinysynth

A drums looper made with React and the WebAudio API
JavaScript
249
star
2

tooty

An alternative multi-accounts Web client for Mastodon.
Elm
156
star
3

kept

Personal notes as widgets, inspired by Google Keep
JavaScript
133
star
4

readable-proxy

Node proxy server attempting to fetch readable contents from any provided URL.
JavaScript
104
star
5

backbone-events-standalone

Standalone, minimal version of Backbone.Events
JavaScript
63
star
6

nicolas.perriault.net

My personal blog
CSS
53
star
7

npAssetsOptimizerPlugin

[No more maintained] Symfony 1.3+ plugin for Web assets compression, combination and optimization.
PHP
37
star
8

stpackages

A webapp listing Sublime Text packages powered by node, elasticsearch & angularjs
JavaScript
20
star
9

SublimeText-CasperJS

A SublimeText2 bundle for CasperJS
20
star
10

akDoctrineTemplateCacheInvaliderPlugin

[No more maintained] A Symfony plugin to manage dynamic templates cache invalidation on Doctrine objects save
PHP
17
star
11

wordlem

A simplistic port of the popular Wordle game in Elm.
Elm
17
star
12

toctoc

Generates and maintain a Table of Content for your README.md.
JavaScript
16
star
13

sfDoctrineEditableComponentPlugin

Symfony plugin for setting up edit-in-place, plain or wysiwyg/html components
JavaScript
13
star
14

elm-daterange-picker

A date range picker written in Elm.
Elm
12
star
15

djortunes

Fortunes manager written in Django.
Python
7
star
16

nodetunes

A fortune manager written using node, express, mongoose and coffeescript
CoffeeScript
7
star
17

docbrown

Minimalistic Flux implementation.
JavaScript
6
star
18

myshows

A simple Elm app to list and rate your favorite TV shows.
Elm
5
star
19

jquery-expander

A jQuery plugin to truncate/expand long texts
JavaScript
4
star
20

jqPlanize

jQuery plugin and bookmarklet to provide HTML documents some hierarchical organization
JavaScript
4
star
21

inslides

Silly slide generator inspired by outslides
JavaScript
3
star
22

casperjs-docs

Sphinx documentation for CasperJS
Python
3
star
23

sftunes

Fortunes manager written in Symfony.
PHP
3
star
24

gameoflife

Conway's Game of Life implemented in JavaScript
JavaScript
3
star
25

jetlagged

A mozilla jetpack extension allowing to translate any selected text using the google API
JavaScript
3
star
26

elm-kitten

Create an SPA using Elm and SASS.
Elm
3
star
27

swwwitch

Web port of the Switch game.
JavaScript
3
star
28

ckMediaEmbed

A CKEditor plugin allowing to embed html code snippet in an editor instance, using a convenient button
JavaScript
3
star
29

monkeypox-stats

Experiments with open data & dataviz about the monkeypox pandemic
Elm
2
star
30

checkio-solutions

My solutions for the check.io webgame
Python
2
star
31

exercisms

Personal solutions & attempts for exercism.io. For archiving purpose.
Elm
2
star
32

Presentations

Slides from talks I gave at random conferences
JavaScript
2
star
33

github-sync-upstream

Python script to automatically synchronize read-only forked repositories of a github org/user with their upstream parents.
Python
2
star
34

gastrobot

A mastodon bot posting random recipe names in French, daily.
JavaScript
2
star
35

elm-advent-2021

Advent of Code 2021, in Elm
Elm
1
star
36

jetconv

JetConv is a mozilla Jetpack allowing to convert an amount of money into another currency, using the Google Finance API.
JavaScript
1
star
37

atelier-djangocong-2015

Atelier Djangocong 2015.
JavaScript
1
star
38

NSMemcached

A simple implementation of a namespaced Python client for memcached
Python
1
star
39

n1k0.github.com

1
star
40

loop-ui-toolkit

Temporary repository for the Loop client UI toolkit.
CSS
1
star
41

cyclobot

A mastodon bot posting random silly bicycle innovations
JavaScript
1
star