/** * Handle a node * * Handle / transform a given node, and return the result of the * conversion. * * @param ezcDocumentElementVisitorConverter $converter * @param DOMElement $node * @param mixed $root * @return mixed */ public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root) { // Visit paragraph contents $contents = $converter->visitChildren($node, ''); // Remove all line breaks inside the paragraph. $contents = trim(preg_replace('(\\s+)', ' ', $contents)); $root .= ezcDocumentDocbookToWikiConverter::wordWrap($contents) . "\n\n"; return $root; }
/** * Render a directive * * Render a directive with the given paramters. * * @param string $name * @param string $parameter * @param array $options * @param string $content * @return string */ protected function renderDirective($name, $parameter, array $options, $content = null) { $indentation = str_repeat(' ', ezcDocumentDocbookToWikiConverter::$indentation); // Show directive with given parameters $directive = sprintf("\n%s.. %s:: %s\n", $indentation, $name, $parameter); // Append options foreach ($options as $key => $value) { $directive .= sprintf("%s :%s: %s\n", $indentation, ezcDocumentDocbookToWikiConverter::escapeWikiText($key), ezcDocumentDocbookToWikiConverter::escapeWikiText($value)); } // Append content, if given if ($content !== null) { $directive .= "\n" . str_repeat(' ', ezcDocumentDocbookToWikiConverter::$indentation + 3) . trim(ezcDocumentDocbookToWikiConverter::wordWrap($content, 3)) . "\n"; } // Append an additional newline after the directive contents $directive .= "\n"; return $directive; }
/** * Initialize destination document * * Initialize the structure which the destination document could be build * with. This may be an initial DOMDocument with some default elements, or * a string, or something else. * * @return mixed */ protected function initializeDocument() { self::$indentation = 0; self::$wordWrap = $this->options->wordWrap; return ''; }