* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @package syntax */ if (!defined("DOKU_INC")) die(); // the plugin must be run within Dokuwiki require_once "method.php"; // common methods used by PyCode plugin /** * This class defines all the methods used by the PyCode plugin to produce * the plugin's output. * * It extends DokuWiki's basic syntax defined in lib/plugins/syntax.php. * * @package syntax_pycode */ class syntax_plugin_pycode extends DokuWiki_Syntax_Plugin { /** * Constructor method for class suitable for any initialization. */ public function __construct() { $this->mpp = new method_pycode_plugin; } /** * Define the syntax types that this plugin applies when founds * its token: it is simply replaced. * * @return (str) */ public function getType() { return "substition"; } /** * Define how the plugin's output is handled regarding paragraphs. * * Open paragraphs will be closed before plugin output and * the plugin output will not starts with a paragraph: *
foo
*bar
* * @return (str) */ public function getPType() { return "block"; } /** * Define the priority used to determine in which order modes are added: * the mode with the lowest sort number will win. * * Since this plugin provides text codes and internal links, it is * sorted at: * Doku_Parser_Mode_code (= 200) < PyCode plugin * Doku_Parser_Mode_internallink (= 310) < PyCode plugin * * @return (int) */ public function getSort() { return 315; } /** * Define the regular expression needed to match the plugin's syntax. * * This plugin use the following general syntax: *"; foreach ($range as $number) { if (strlen(end($range)) <= 4) { $number = str_pad($number, 4, " ", STR_PAD_LEFT); } else { $number = str_pad($number, 5, " ", STR_PAD_LEFT); } $renderer->doc .= "$number
"; } $renderer->doc .= "
"; $renderer->doc .= $this->mpp->_get_geshi_code($code, $lang); $renderer->doc .= ""; if ($title != "none") { $renderer->doc .= "
"; $renderer->emphasis_open(); foreach ($all_brief[0] as $line) { $renderer->doc .= $line . ""; } $renderer->listcontent_close(); //
"; } $renderer->emphasis_close(); $renderer->doc .= "
"; $renderer->emphasis_open(); foreach ($all_brief[$key] as $line) { $renderer->doc .= $line . ""; } $renderer->listcontent_close(); //
"; } $renderer->emphasis_close(); $renderer->doc .= "