NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
// ==UserScript== | |
// @name Use Markdown, sometimes, in your HTML. | |
// @author Paul Irish <http://paulirish.com/> | |
// @link http://git.io/data-markdown | |
// @match * | |
// ==/UserScript== | |
// If you're not using this as a userscript just delete from this line up. It's cool, homey. |
NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
function ellipsis(numOfWords, text, wordCount ) { | |
wordCount = text.trim().replace(/\s+/g, ' ').split(' ').length; | |
if(numOfWords <= 0 || numOfWords === wordCount){ | |
return text; | |
} else { | |
text = text.trim().split(' '); | |
text.splice(numOfWords, wordCount, '...'); | |
return text.join(' '); | |
} | |
} |
/* | |
* Quick and Dirty sprintf | |
* Copyright 2011 Nicholas C. Zakas. All rights reserved. | |
* BSD licensed | |
*/ | |
/* | |
* This function does not attempt to implement all of sprintf, just %s, | |
* which is the only one that I ever use. | |
*/ |