diff -r 2f3b76a405ce -r c3150cee8dd9 Halftone.php --- a/Halftone.php Tue Mar 27 12:14:14 2012 -0400 +++ b/Halftone.php Tue Mar 27 18:48:23 2012 -0400 @@ -13,7 +13,7 @@ **!*/ $plugins->attachHook('render_wikiformat_posttemplates', 'halftone_process_tags($text);'); -$plugins->attachHook('html_attribute_whitelist', '$whitelist["halftone"] = array("title", "key");'); +$plugins->attachHook('html_attribute_whitelist', '$whitelist["halftone"] = array("title", "transpose");'); $plugins->attachHook('session_started', 'register_special_page(\'HalftoneRender\', \'Halftone AJAX render handler\', false);'); define('KEY_C', 0); @@ -247,6 +247,8 @@ function halftone_process_tags(&$text) { + global $circle_of_fifths; + static $css_added = false; if ( !$css_added ) { @@ -307,15 +309,23 @@ $chord_list = array(); $inner = trim($matches[2][$i]); $song = halftone_render_body($inner, $chord_list); + $src = base64_encode($whole_match); - $key = name_to_key(detect_key($chord_list)); + $origkey = $key = name_to_key(detect_key($chord_list)); + if ( isset($attribs['transpose']) && is_int($tokey = name_to_key($attribs['transpose'])) ) + { + // re-render in new key + $transpose = $tokey - $key; + $song = halftone_render_body($inner, $chord_list, $tokey, $transpose); + $key = $tokey; + } $select = ''; $headid = 'song:' . sanitize_page_id($song_title); @@ -324,12 +334,12 @@ } } -function halftone_render_body($inner, &$chord_list, $inkey = false) +function halftone_render_body($inner, &$chord_list, $inkey = false, $transpose = 0) { global $accidentals; $song = '