Skip to content

Instantly share code, notes, and snippets.

@digital-carver
Last active March 5, 2019 08:03
Show Gist options
  • Select an option

  • Save digital-carver/6401390 to your computer and use it in GitHub Desktop.

Select an option

Save digital-carver/6401390 to your computer and use it in GitHub Desktop.
A Greasemonkey script to enable syntax highlighting when viewing module sources on CPAN
// ==UserScript==
// @name CPANSyntaxHighlight
// @namespace abiteasier.in
// @description Enable syntax highlighting when viewing the source on CPAN
// @include http://cpansearch.perl.org/src/*
// @version 0.9
// @require http://yandex.st/highlightjs/7.3/highlight.min.js
// @resource syntaxHighlightCSS http://yandex.st/highlightjs/7.3/styles/github.min.css
// @grant GM_addStyle
// @grant GM_getResourceText
// ==/UserScript==
var syntax_highlighter_CSS = GM_getResourceText("syntaxHighlightCSS");
GM_addStyle(syntax_highlighter_CSS);
var p = document.getElementsByTagName('pre')[0];
p.className += ' language-perl';
hljs.highlightBlock(p);
@digital-carver
Copy link
Author

Note: This uses Github style highlighting by default, which looks pretty nice, but you have a few other options: the list in http://api.yandex.ru/jslibs/libs.xml#highlightjs that starts "Arta, Ascetic, ..."

@digital-carver
Copy link
Author

Copy link

ghost commented Feb 21, 2018

Thanks buddy 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment