register_hook( 'PARSER_HANDLER_DONE', 'AFTER', $this, '_post_processing', array() ); } /** * Transform the special heading atx call * in an enter and exit heading atx calls * * Add the section close / open * * Build the toc * And create the main are * * Code extracted and adapted from the end of {@link Doku_Handler::header()} * * @param $event Doku_Event */ function _post_processing(&$event, $param) { /** * @var Doku_Handler $handler */ $handler = $event->data; $executionContext = ExecutionContext::getActualOrCreateFromEnv(); try { $fetcherMarkup = $executionContext->getExecutingMarkupHandler(); $isFragment = $fetcherMarkup->isFragment() === true; try { $executingPath = $fetcherMarkup->getRequestedExecutingPath(); } catch (ExceptionNotFound $e) { $executingPath = null; } } catch (ExceptionNotFound $e) { /** * Not on admin pages */ $action = $executionContext->getExecutingAction(); if($action===ExecutionContext::ADMIN_ACTION){ return; } /** * What fucked up is fucked up ! * {@link pageinfo()} in common may starts before the {@link action_plugin_combo_docustom handler } is called * {@link action_plugin_combo_docustom} */ $requestedPath = $executionContext->getRequestedPath(); $executingPath = null; $isFragment = true; try { $executingId = $executionContext->getExecutingWikiId(); /** * In preview mode, this is always a `fragment run` * * otherwise we get warning on the outline because the heading should start with heading 1 or 2, not 3 * * and this is used in {@link \ComboStrap\Parser::parseMarkupToHandler()} */ if ($executionContext->getExecutingAction() !== ExecutionContext::PREVIEW_ACTION) { $isSlot = MarkupPath::createPageFromPathObject($requestedPath)->isSlot(); if ($isSlot === false) { if ($executingId === $requestedPath->getWikiId()) { $isFragment = false; } } } $executingPath = WikiPath::createMarkupPathFromId($executingId); } catch (ExceptionNotFound $e) { // } } /** * Fragment execution */ if ($isFragment) { $callStack = CallStack::createFromHandler($handler); // no outline or edit button for dynamic rendering // but closing of atx heading $handler->calls = Outline::createFromCallStack($callStack, null, true) ->toFragmentInstructionCalls(); return; } /** * Document execution * (add outline section, ...) */ $callStack = CallStack::createFromHandler($handler); if ($executingPath !== null) { $executingMarkupPath = MarkupPath::createPageFromPathObject($executingPath); } else { $executingMarkupPath = null; } $outline = Outline::createFromCallStack($callStack, $executingMarkupPath, $isFragment); $handler->calls = $outline->toHtmlSectionOutlineCalls(); /** * No more supported * $handler->calls = $outline->toDokuWikiTemplateInstructionCalls(); */ } }