diff -r 000000000000 -r c78d206bf01c TinyMCE.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TinyMCE.php Thu Jun 02 06:24:03 2011 -0400 @@ -0,0 +1,37 @@ +attachHook('compile_template', '$template->add_header_js(\'\');'); +$plugins->attachHook('compile_template', '$template->add_header_js(\'\');'); + +function render_text_tinymce($text) +{ + return '?>' . RenderMan::render($text, RENDER_INLINE); +} + +$plugins->attachHook('get_page_source', 'get_page_src_tinymce($result["src"]);'); + +function get_page_src_tinymce(&$text) +{ + // gently process headings to make tinymce format them correctly + if ( preg_match_all('/^ *?(={1,6}) *(.+?) *\\1 *$/m', $text, $matches) ) + { + foreach ( $matches[0] as $i => $match ) + { + $hi = strlen($matches[1][$i]); + $heading = "{$matches[2][$i]}"; + $text = str_replace_once($match, $heading, $text); + } + } + return $text; +}