Skip to content

Instantly share code, notes, and snippets.

@beerendlauwers
Last active September 30, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beerendlauwers/2473a836b8aa26045de0 to your computer and use it in GitHub Desktop.
Save beerendlauwers/2473a836b8aa26045de0 to your computer and use it in GitHub Desktop.
Attempt at loading extra CSS in StackEdit without replacing default.css
// This doesn't seem to work. The browser only noticed the CSS file if it completely replaced <link type="text/css" rel="stylesheet" href="res-min/themes/default.css">.
// So, in a worst-case scenario, you can just copy that CSS file, add your changes to it, host it on Github and do the replacement with a UserCustom extension (https://github.com/benweet/stackedit/wiki/UserCustom-extensions).
// Also tried onReady https://github.com/benweet/stackedit/wiki/userCustom.onReady
$(document).ready( function() {
var loadCSS = function(href) {
var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>");
$("head").append(cssLink);
};
var path = "url/to/css";
loadCSS(path);
alert("loaded");
} );
// This code might also be useful if you want to target the current StackEdit theme <link>.
$("link").filter( function(elem) {
var isStylesheet = $(this).attr("rel") === "stylesheet";
var isDefaultCss = $(this).attr("href").indexOf("res-min/themes/") === 0;
return isStylesheet && isDefaultCss;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment