transform($text);
}
public function __construct()
{
// doImage is 10, add image url just before
$this->span_gamut['doImageURL'] = 9;
// doLink is 20, add base url just before
$this->span_gamut['doBaseURL'] = 19;
// Add API links
$this->span_gamut['doAPI'] = 90;
// Add note spans last
$this->span_gamut['doNotes'] = 100;
// Parse Kohana view inclusions at the very end
$this->document_gamut['doIncludeViews'] = 99;
// Show table of contents for userguide pages
$this->document_gamut['doTOC'] = 100;
// Call parent constructor.
parent::__construct();
}
/**
* Callback for the heading setext style
*
* Heading 1
* =========
*
* @param array Matches from regex call
* @return string Generated html
*/
function _doHeaders_callback_setext($matches)
{
if ($matches[3] == '-' AND preg_match('{^- }', $matches[1]))
return $matches[0];
$level = ($matches[3]{0} == '=') ? 1 : 2;
$attr = $this->_doHeaders_attr($id =& $matches[2]);
// Only auto-generate id if one doesn't exist
if (empty($attr))
{
$attr = ' id="'.$this->make_heading_id($matches[1]).'"';
}
// Add this header to the page toc
$this->_add_to_toc($level,$matches[1],$this->make_heading_id($matches[1]));
$block = "
'.$match[1].'
'); } protected function _add_to_toc($level, $name, $id) { self::$_toc[] = array( 'level' => $level, 'name' => $name, 'id' => $id); } public function doTOC($text) { // Only add the toc do userguide pages, not api since they already have one if (self::$show_toc AND Route::name(Request::current()->route()) == "docs/guide") { $toc = View::factory('userguide/page-toc') ->set('array', self::$_toc) ->render() ; if (($offset = strpos($text, '')) !== FALSE) { // Insert the page TOC just before the first
, which every // Markdown page should (will?) have. $text = substr_replace($text, $toc, $offset, 0); } } return $text; } } // End Kodoc_Markdown