How do I create a Gistpen and insert it into the post?

You can also create and insert a Gistpen directly into your post/page from the visual editor by clicking the pen button. From the pop-up, select one of the recent Gistpens or create a new one by pasting in your code and clicking “Insert”.

After inserting the shortcode, your code will appear in your post, highlighted by PrismJS.

How do I highlight specific lines in my Gistpen?

To highlight a specific line, add highlight="^^", where ^^ is a line number or range of numbers you want highlighted, like this (via PrismJS documentation):

A single number refers to the line with that number

Ranges are denoted by two numbers, separated with a hyphen (-)

Multiple line numbers or ranges are separated by commas.

Whitespace is allowed anywhere and will be stripped off.

Examples:

highlight="5": The 5th line

highlight="1-5": Lines 1 through 5

highlight="1,4": Line 1 and line 4

highlight="1-2,5,9-20": Lines 1 through 2, line 5, lines 9 through 20

Offset does not yet work but will be added soon.

How do I link to a specific line?

You can link to a specific line in your Gistpen by linking to #gistpen-{gistpen-slug}.{lines}. The lines don’t need to be highlighted in advance for the link to work, and they will be highlighted when the link is clicked. The {lines} should match the same format as above.

What is the future of this plugin?

Eventually, I hope to make this plugin interoperable with Gist, allowing you to import your current Gists, fork other people’s Gists into your Gistpen, and publishing your Gistpens to Gist.

Additionally, I want to make Gistpens embeddable on other websites the same way you can embed Gists, but both of those larger features are likely a long way off.

Essentially, the idea is to build a fully-featured Gist clone in WordPress

Screenshots

The Insert Gistpen dialog after you click the pen in the visual editor.

Default theme – How your code will appear in your post.

Twilight theme with line numbers enabled. Check out all the themes at PrismJS.com.