Created
January 21, 2015 11:01
-
-
Save visualskyrim/4ef0ab9f546c7a821f51 to your computer and use it in GitHub Desktop.
Lopash nvAlt template with fenced code block enabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>{%title%}</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<style type="text/css"> | |
{%style%} | |
</style> | |
<link rel="stylesheet" href="file://{%support%}/solarized_dark.css"> | |
</head> | |
<body> | |
<div id="wrapper"> | |
<header> | |
<h1 class="doctitle">{%title%}</h1> | |
</header> | |
<div id="contentdiv"> | |
{%content%} | |
</div> | |
</div> <!-- end of #container --> | |
<script src="file://{%support%}/jquery.min.js"></script> | |
<script> | |
(function($){ | |
// widont | |
$('h1,h2,h3,h4').each(function(){ | |
$(this).html($(this).text().replace(/([^\\s])\\s+([^\\s]{1,5})\\s*$/,"$1 $2")); | |
}); | |
// smooth scroll to anchors and footnotes | |
$('a[href^=#]').click(function(){ | |
if( location.pathname.replace(/^\\/,'') === this.pathname.replace(/^\\/,'') && location.hostname === this.hostname) { | |
var $target = $(this.hash); | |
$target = $target.length ? $target : $('[id='+this.hash.slice(1)+']'); | |
if($target.length){ | |
var targetOffset = $target.offset().top; | |
$('#contentdiv').animate({ scrollTop: targetOffset - 40 }, 1000); | |
return false; | |
} | |
} | |
}); | |
// back-to-top link fade in/out | |
$(window).scroll(function(){ | |
if( $(window).scrollTop() > 150) { | |
if(!$('#backtotop').length) { | |
$('h1.doctitle').append($('<a href="javascript:void()" id="backtotop" />').text('Back to top').css({'float':'right','display':'none'}).click(function(){ | |
$('html,body').animate({scrollTop:0},500); | |
})); | |
$('#backtotop').fadeIn(400); | |
} | |
} else { | |
$('#backtotop').fadeOut(400,function(){ | |
$(this).remove(); | |
}); | |
} | |
}); | |
})(jQuery); | |
p_list = document.getElementsByTagName("p"); | |
for (var i = 0; i < p_list.length; i++) { | |
p_o = p_list[i] | |
code_list = p_o.getElementsByTagName("code") | |
if (code_list.length != 0 && code_list[0].nodeName == "CODE") { | |
pre = document.createElement('pre'); | |
pre.innerHTML = p_o.innerHTML; | |
// if there is a language being specified, add specified class | |
code_lines = pre.getElementsByTagName("code")[0].innerText.split("\n"); | |
first_line = code_lines[0]; | |
if (code_lines.length > 1) { | |
if (first_line != "") { | |
pre.className = first_line; | |
} | |
pre.getElementsByTagName("code")[0].innerText = code_lines.slice(1, code_lines.length).join("\n"); | |
p_o.parentNode.insertBefore(pre, p_o); | |
p_o.parentNode.removeChild(p_o); | |
} | |
} | |
}; | |
</script> | |
<script src="file://{%support%}/highlight.pack.js"></script> | |
<script>hljs.initHighlightingOnLoad();</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this works, thanks!