// Render KaTeX math typesetting, but only if the
has the class // feature-math $( function() { if ( $( "body.feature-math:not(.feature-nomath)" ).length ) { renderMathInElement(document.body); } }); // Render abcjs sheet music, but only if the has the class // feature-music. Do this by removing the
// and replacing it with a which will be used to hold the
// generated sheet music. Remark's code syntax highlighting transforms the
// block into a bunch of
// K: Emin
// one per line, so we have to reassemble those to get back linebreaks.
$( function() {
if ( $( "body.feature-music:not(.feature-nomusic)" ).length ) {
$( "code.language-abc, code.abc" ).each(function(i, e){
var $this = $(this);
var abc = $this.text();
if ( $this.hasClass("remark-code") ) {
abc = "";
$this.children().each(function(i, e) {
abc += "\n" + $(this).text();
});
abc = abc.trim();
}
var p = $this.parent().before('');
$this.parent().hide();
ABCJS.renderAbc("music-" + (i+1), abc, {
paddingtop: 0,
paddingbottom: 0,
paddingright: 0,
paddingleft: 0,
responsive: "resize"
});
});
}
});
// Render tweet-styled blockquotes, if
has the class feature-tweetquote and the blockquote ends
// with a twitter permalink URL.
$( function() {
if ( $( "body.feature-tweetquote:not(.feature-notweetquote)" ).length ) {
$("blockquote p:first-child a[href*='twitter.com']").each(function(i, e){
$(this.parentElement.parentElement).addClass("tweet sans-serif mw6");
$(this).addClass("no-underline b");
$(this).prepend('');
var m = $(this).attr('href').match(/twitter.com\/([^\/]*)\//);
if (m.length > 1) {
$(this).append('
@' + m[1] + '');
}
});
}
});
// Render perspective book images, if has the class
// feature-3dbook-covers
$( function() {
$( "body.feature-3dbook-covers article a" ).has( "img[src~='3dbook']" ).each(function(i, e) {
$( this ).addClass("book");
$( this ).parent().addClass("books");
});
});
// Highlight code listings, if has the class
// feature-highlight
$( function() {
if ( $( "body.feature-highlight:not(.feature-nohighlight)" ).length ) {
hljs.initHighlightingOnLoad();
}
});
/* Turn images into figures with captions. Several scenarios are handled, in
* order:
* If the img is followed by an , then transform the into a caption.
* If the img has a title, use that as the caption.
* If the img has an alt, use that.
* The following features have to be enabled:
* - feature-figcaption has to be enabled or the whole thing is disabled
* - feature-figcaption-hidden makes the captions invisible till you hover
* - feature-fignum adds figure numbering
* - feature-figlink adds automatic links of text like "Figure 4"
*/
$( function() {
$("body.feature-figcaption:not(.feature-nofigcaption) article img").each(function(i, e) {
var $this = $(this);
// Don't put captions on images that have URL fragment pseudo-classes.
if ( $this.attr('src').match(/#/) ) return;
var $txt = false;
if ( $this.next().is("em") ) {
$txt = $this.next().html();
$this.next().remove();
} else {
$txt = $this.attr('title') ? $this.attr('title')
: $this.attr('alt') ? $this.attr('alt')
: false;
}
if ( $txt ) {
var $fig = $this.wrap('