Created
May 30, 2014 16:47
-
-
Save jdcauley/dd503af5f808f48f7df6 to your computer and use it in GitHub Desktop.
Format Blockquotes
This file contains hidden or 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
$(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); | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jQuery dependent