Skip to content

Instantly share code, notes, and snippets.

@jdcauley
Created May 30, 2014 16:47
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 jdcauley/dd503af5f808f48f7df6 to your computer and use it in GitHub Desktop.
Save jdcauley/dd503af5f808f48f7df6 to your computer and use it in GitHub Desktop.
Format Blockquotes
$(function quotes() {
blockquotes = document.getElementsByTagName('blockquote');
if (blockquotes) {
for (var i = 0; i < blockquotes.length; i++){
var blockquote = blockquotes[i];
var currentId = 'block-' + i;
blockquote.id = currentId;
paragraphs = blockquote.getElementsByTagName('p');
if ( 1 < paragraphs.length ){
var citation = document.getElementById(currentId);
var lastParagraph = citation.querySelector('p:last-child').innerText;
var comma = lastParagraph.indexOf(','); // Contains 24 //
var speaker = lastParagraph.substring(0, comma);
var title = lastParagraph.substring(comma, citation.length);
var res = lastParagraph.replace(lastParagraph, '<strong>' + speaker + '</strong>' + title);
$( 'p:last-child' ).addClass("last");
$('p:last-child').html(res);
}
}
}
});
@jdcauley
Copy link
Author

jQuery dependent

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