Skip to content

Instantly share code, notes, and snippets.

@edvakf
Created September 18, 2009 05:32
Show Gist options
  • Save edvakf/188895 to your computer and use it in GitHub Desktop.
Save edvakf/188895 to your computer and use it in GitHub Desktop.
/* "foobar RT @hoge : blah blah..." into "<q>blah blah... (<a>@hoge</a>)<q> foobar" */
(function(){
var re = /^([\s\S]*?)RT\s*(<[aA].*?>@\w+<\/[aA]>)[:\s]*(\S[\s\S]*)$/;
function semanticRT(html){
return html.replace(re, function(str, $1, $2, $3){
return '↪ <q class="retweet">' + semanticRT($3) + ' <cite>(' + $2 + ')</cite></q> ' + $1;
})
}
function betterRT(elem){
var st = elem.getElementsByClassName('status')[0];
if (!re.test(st.innerHTML)) return;
st.innerHTML = semanticRT(st.innerHTML);
}
registerPlugin({
newMessageElement : betterRT
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment