8,282
edits
(Imported functionality from minecraft.wiki) |
(Add support for custom hex code colors) |
||
Line 115: | Line 115: | ||
// No title or title only contains formatting codes | // No title or title only contains formatting codes | ||
if ( title === undefined || title !== '' && title.replace( /&([0-9a- | if ( title === undefined || title !== '' && title.replace( /&([0-9a-jl-qs-vyzr]|#[0-9a-fA-F]{6}|\$[0-9a-fA-F]{3})/g, '' ) === '' ) { | ||
// Find deepest child title | // Find deepest child title | ||
var childElem = $elem[0], childTitle; | var childElem = $elem[0], childTitle; | ||
Line 158: | Line 158: | ||
// Add classes for minecraft formatting codes | // Add classes for minecraft formatting codes | ||
while ( content.search( /&[0-9a- | while ( content.search( /&(?:[0-9a-jl-qs-vyz]|#[0-9a-fA-F]{6}|\$[0-9a-fA-F]{3})/ ) > -1 ) { | ||
content = content.replace( /&([0-9a- | content = content.replace( /&([0-9a-jl-qs-vyz])(.*?)(&r|$)/g, '<span class="format-$1">$2</span>&r' ); | ||
content = content.replace( /&(?:#([0-9a-fA-F]{6})|\$([0-9a-fA-F]{3}))(.*?)(&r|$)/g, '<span class="format-custom" style="color: #$1$2;">$3</span>&r' ); | |||
} | } | ||
// Remove reset formatting | // Remove reset formatting |