Skip to content

Instantly share code, notes, and snippets.

@PedroHLC
Last active December 29, 2020 20:05
Show Gist options
  • Save PedroHLC/0dc566f2cc4a9783eb0e85d37b49a7e1 to your computer and use it in GitHub Desktop.
Save PedroHLC/0dc566f2cc4a9783eb0e85d37b49a7e1 to your computer and use it in GitHub Desktop.
[UserScript] Hightlights for Slack
// ==UserScript==
// @name Hightlights for Slack
// @namespace https://pedrohlc.com/
// @version 0.1.1
// @downloadURL https://gist.github.com/PedroHLC/0dc566f2cc4a9783eb0e85d37b49a7e1/raw/slack.highlight.js
// @updateURL https://gist.github.com/PedroHLC/0dc566f2cc4a9783eb0e85d37b49a7e1/raw/slack.highlight.meta.js
// @description Slack code block syntax highlighting with highlight.js!
// @author PedroHLC
// @match app.slack.com/*
// @resource css https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.1/styles/default.min.css
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.1/highlight.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.1/languages/elm.min.js
// @require https://raw.githubusercontent.com/uzairfarooq/arrive/master/minified/arrive.min.js
// @grant GM_addStyle
// @grant GM_getResourceText
// ==/UserScript==
GM_addStyle("code, pre, .c-mrkdwn__pre {font-family: Fira Code !important; font-size: 13px !important; font-variant-ligatures: normal !important;}");
GM_addStyle(GM_getResourceText("css"));
hljs.initHighlightingOnLoad();
unsafeWindow.hljs = hljs;
document.arrive(".c-mrkdwn__pre", function() {
var content = this.innerText.split('\n');
var lang = content[0];
this.className += " lang-"+lang;
this.innerText = content.slice(1).join('\n');
window.hljs.highlightBlock(this);
});
// ==UserScript==
// @name Hightlights for Slack
// @namespace https://pedrohlc.com/
// @version 0.1.1
// @description Slack code block syntax highlighting with highlight.js!
// @author PedroHLC
// @match app.slack.com/*
// @resource css https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.1/styles/default.min.css
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.1/highlight.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.1/languages/elm.min.js
// @require https://raw.githubusercontent.com/uzairfarooq/arrive/master/minified/arrive.min.js
// @grant GM_addStyle
// @grant GM_getResourceText
// ==/UserScript==
@PedroHLC
Copy link
Author

PedroHLC commented May 14, 2020

Add language name in first line! E.g.:
```ruby
example = 0x50
```

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