Parsers for NBBC and Markdown should use this function to format thier spoilers.
All spoilers in HTML-formatted posts are saved in this way. We use javascript in
spoilers.js to add markup and render Spoilers with the "Spoiler" css class name.
public static spoilerHtml ( string $spoilerText ) : string | ||
$spoilerText | string | The inner text of the spoiler. |
return | string |
protected function _doSpoilers_callback($matches) { $bq = $matches[1]; # trim one level of quoting - trim whitespace-only lines $bq = preg_replace('/^[ ]*>![ ]?|^[ ]+$/m', '', $bq); $bq = $this->runBlockGamut($bq); # recurse $bq = preg_replace('/^/m', " ", $bq); # These leading spaces cause problem with <pre> content, # so we need to fix that: $bq = preg_replace_callback('{(\\s*<pre>.+?</pre>)}sx', array(&$this, '_doSpoilers_callback2'), $bq); return "\n" . $this->hashBlock(Gdn_Format::spoilerHtml($bq)) . "\n\n"; }
/** * Renders spoilers. * * @param object $bbCode Instance of NBBC parsing * @param int $action Value of one of NBBC's defined constants. Typically, this will be BBCODE_CHECK. * @param string $name Name of the tag * @param string $default Value of the _default parameter, from the $params array * @param array $params A standard set parameters related to the tag * @param string $content Value between the open and close tags, if any * * @return string HTML-formatted spoiler value */ public function doSpoiler($bbCode, $action, $name, $default, $params, $content) { return Gdn_Format::spoilerHtml($content); }