From ae83bebc98037e64aaeb09c484d5b6d766115e48 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sat, 23 Jun 2007 18:58:51 +0000 Subject: [PATCH] Convert handleStart to the new format. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1211 48356398-32a2-884e-a903-53898d9a118a --- .../HTMLPurifier/Injector/AutoParagraph.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/library/HTMLPurifier/Injector/AutoParagraph.php b/library/HTMLPurifier/Injector/AutoParagraph.php index 4e5357ba..fd589f96 100644 --- a/library/HTMLPurifier/Injector/AutoParagraph.php +++ b/library/HTMLPurifier/Injector/AutoParagraph.php @@ -34,6 +34,20 @@ class HTMLPurifier_Injector_AutoParagraph extends HTMLPurifier_Injector } } + function handleStart(&$token, $config, &$context) { + // check if we're inside a tag already, if so, don't add + // paragraph tags + $current_nesting = $context->get('CurrentNesting'); + if (!empty($current_nesting)) return; + + // check if the start tag counts as a "block" element + $definition = $config->getHTMLDefinition(); + if (isset($definition->info['p']->auto_close[$token->name])) return; + + // append a paragraph tag before the token + $token = array(new HTMLPurifier_Token_Start('p'), $token); + } + /** * Sub-function for auto-paragraphing that takes a token and splits it * up into paragraphs unconditionally. Requires that a paragraph was @@ -117,16 +131,6 @@ class HTMLPurifier_Injector_AutoParagraph extends HTMLPurifier_Injector return $end_paragraph; } - function handleStart(&$token, $config, &$context) { - $current_nesting =& $context->get('CurrentNesting'); - if (!empty($current_nesting)) return; - $definition = $config->getHTMLDefinition(); - // to be replaced with new auto-auto_close algorithm - if (isset($definition->info['p']->auto_close[$token->name])) return; - $result =& $context->get('OutputTokens'); - $result[] = $current_nesting[] = new HTMLPurifier_Token_Start('p'); - } - } ?> \ No newline at end of file