in that case it's possible that plusplus wasn't working. are they still enabled? if plusplus is working, it should translate http://server.com[links like this] without needing any custom attributes.
by changing them both to AddChildFormatter i got them both to load. plusplus still doesn't do anything, though, but if i echo "plusplus" before the class definition, it shows up.
//actually i guess they were both loading before, just not working. nevermind.
Well, I just took a look and it seems that everything worked properly for both (except for the language="javascript" one). I didn't change anything in the plusplus extension you gave me. I just threw it in the folder and enabled it. Check it out:
What you'd probably want to do is reverse the actions of the HtmlFormatter on the code your parsing (ie. revert entites to their original characters, change back the 'script' conversions [obviously after reverting entities], etc...). As for the language="javascript", I'd either search for language="javascript"/language="JavaScript" or use language="js" instead.
EDIT: mark, I may be wrong, but it seems as if instances of '&' aren't converted to '&' when you're editing a comment, resulting in (intentional) entities to be shown as what they represent, and subsequently saved as such unless manually changed.
EDIT2: yep, that definitely seems to be a bug...
ok.. i just made geshicolor extend StringFormatter instead of HtmlFormatter, and used AddManipulator("Text" instead of "Html", and posted a Text comment with some code, and both extensions work. so it appears that the two (three, really) Html parsers are conflicting somehow.
i think i'm tracking it down. i made it use AddManipulator("Code"), and extend StringFormatter, and both extensions work when you enter a comment with Code selected.
So it looks like this: when GeshiFormatter is piggybacking on the Html manipulator along with HtmlPlusPlusFormatter, vanilla is maybe confused about which parser to use with Html comments, and picks GeshiFormatter every time.
I guess i'm somehow overriding HtmlPlusPlus instead of acting as another formatter in the chain.
Okay, I wanted to prove that you can add multiple child formatters to existing formatters. So, I made a new extension that creates two different formatters and adds them both to the HtmlFormatter. I enabled it, and it works - both of the formatters get parsed as they should.
Here is the code:
<?php
/*
Extension Name: Formatter Test
Extension Url: null
Description: Trying to help ithcy
Version: 1
Author: mark
Author Url: http://markosullivan.ca
*/
if (@$Context->Session->UserID > 0 && in_array($Context->SelfUrl, array("comments.php", "post.php"))) {
class FooFormatter extends StringFormatter {
function Parse($String, $Object, $FormatPurpose) {
if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) return str_replace('foo', 'FOO!!', $String);
else return $String;
}
}
class FeeFormatter extends StringFormatter {
function Parse($String, $Object, $FormatPurpose) {
if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) return str_replace('fee', 'FEE!!', $String);
else return $String;
}
}
$Foo = $Context->ObjectFactory->NewObject($Context, "FooFormatter");
$Fee = $Context->ObjectFactory->NewObject($Context, "FeeFormatter");
$Context->StringManipulator->Formatters["Html"]->AddChildFormatter($Foo);
$Context->StringManipulator->Formatters["Html"]->AddChildFormatter($Fee);
}
?>
i came to the conclusion that rather than undo everything that HtmlFormatter does, i'd be better off giving it its own manipulator and then including code from HtmlFormatter to prevent scripting attacks. SirNot, is that okay with you? If so i'll post the extension to the addons directory.
Well, if you really want to ithcy, but it'd be sort of hard to update one specifically by doing so. Would you mind if I played around with it a little?
Comments
*asks too much
//actually i guess they were both loading before, just not working. nevermind.
It will be a while before the fix is on there, though.
could it be something to do with the Parse classes from the two extensions conflicting?
So it looks like this: when GeshiFormatter is piggybacking on the Html manipulator along with HtmlPlusPlusFormatter, vanilla is maybe confused about which parser to use with Html comments, and picks GeshiFormatter every time.
I guess i'm somehow overriding HtmlPlusPlus instead of acting as another formatter in the chain.
Here is the code:
<?php /* Extension Name: Formatter Test Extension Url: null Description: Trying to help ithcy Version: 1 Author: mark Author Url: http://markosullivan.ca */ if (@$Context->Session->UserID > 0 && in_array($Context->SelfUrl, array("comments.php", "post.php"))) { class FooFormatter extends StringFormatter { function Parse($String, $Object, $FormatPurpose) { if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) return str_replace('foo', 'FOO!!', $String); else return $String; } } class FeeFormatter extends StringFormatter { function Parse($String, $Object, $FormatPurpose) { if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) return str_replace('fee', 'FEE!!', $String); else return $String; } } $Foo = $Context->ObjectFactory->NewObject($Context, "FooFormatter"); $Fee = $Context->ObjectFactory->NewObject($Context, "FeeFormatter"); $Context->StringManipulator->Formatters["Html"]->AddChildFormatter($Foo); $Context->StringManipulator->Formatters["Html"]->AddChildFormatter($Fee); } ?>
thanks mark. sorry for wasting your time.
*shrinks
and thanks SirNot - you're right about needing to undo HtmlFormatter inside the code.
i came to the conclusion that rather than undo everything that HtmlFormatter does, i'd be better off giving it its own manipulator and then including code from HtmlFormatter to prevent scripting attacks. SirNot, is that okay with you? If so i'll post the extension to the addons directory.
<?php /* Extension Name: Html Formatter ++ Extension Url: http://lussumo.com/docs/ Description: An extension for the HtmlFormatter to syntax highlight source code. Version: 1.0 Author: ithcy and SirNotAppearingOnThisForum Author Url: N/A */ define('GESHI_PATH', 'geshi/'); include_once(GESHI_PATH.'geshi.php'); $GeshiLangs = array( 'actionscript-french', 'actionscript', 'ada', 'apache', 'applescript', 'asm', 'asp', 'bash', 'blitzbasic', 'c', 'caddcl', 'cadlisp', 'cpp', 'csharp', 'css', 'c_mac', 'd', 'delphi', 'diff', 'div', 'dos', 'eiffel', 'freebasic', 'gml', 'html4strict', 'ini', 'inno', 'java', 'javascript', 'lisp', 'lua', 'matlab', 'mpasm', 'mysql', 'nsis', 'objc', 'ocaml-brief', 'ocaml', 'oobas', 'oracle8', 'pascal', 'perl', 'php-brief', 'php', 'python', 'qbasic', 'ruby', 'scheme', 'sdlbasic', 'smarty', 'sql', 'vb', 'vbnet', 'vhdl', 'visualfoxpro', 'xml' ); $GeshiLangStr = implode('|', $GeshiLangs); class HtmlFormatterExt extends StringFormatter { function HtmlFormatterExt() { $GLOBALS['Head']->AddString( '<style type="text/css">.syntax_highlight {border-left: 6px solid #ffa;'. 'background: #ffe; padding: 8px 8px 8px 16px; margin: 3px 0;}</style>'); } function ParseCode($Code, $Lang) { //undo htmlformatter's work $Code = str_replace( array( '>', '<', '"', '&', '<br />', '<br>' ), array( '>', '<', '"', '&', "\n", "\n" ), $Code ); $g = new GeSHi($Code, $Lang); //$g->enable_classes(); $g->set_overall_class('syntax_highlight'); $g->set_tab_width(4); $g->set_escape_characters_highlighting(false); $g->set_brackets_highlighting(false); return $g->parse_code(); } function Execute($String) { //undo 'script' conversions where needed, then find what we need to highlight return preg_replace( array( "/<code([^>]+?)language=\"([\w\d]*?)&#(115|83);([\w\d]*?)\"/ei", "/<code([^>]+?)language=\"(".$GLOBALS['GeshiLangStr'].")\"([^>]*?)>(.+?)<\/code>/sei" ), array( '\'<code\\1language="\\2\'.chr(intval(\'\\3\')).\'\\4"\'', '$this->ParseCode(HtmlFormatter::RemoveQuoteSlashes(\'\\4\'), strtolower(\'\\2\'))' ), $String ); } function Parse($String, $Object, $FormatPurpose) { if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) return $this->Execute($String); else return $String; } } $HtmlFormatterExt = $Context->ObjectFactory->NewObject($Context, 'HtmlFormatterExt'); $Context->StringManipulator->Formatters['Html']->AddChildFormatter($HtmlFormatterExt); ?>