<commit_before><?php
/**
 * Plugin Webcode: Show webcode (Css, HTML) in a iframe
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     <NAME>
 */

// must be run within Dokuwiki
use dokuwiki\Extension\Event;

if (!defined('DOKU_INC')) die();

/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_webcode_basis extends DokuWiki_Syntax_Plugin
{

    const EXTERNAL_RESOURCES_ATTRIBUTE_DISPLAY = 'externalResources'; // In the action bar
    const EXTERNAL_RESOURCES_ATTRIBUTE_KEY = 'externalresources'; // In the code

    // Simple cache bursting implementation for the webCodeConsole.(js|css) file
    // They must be incremented manually when they changed
    const WEB_CONSOLE_CSS_VERSION = 1.1;
    const WEB_CONSOLE_JS_VERSION = 2.1;

    /**
     * @var array that holds the iframe attributes
     */
    private $attributes = array();
    /**
     * @var array That holds the code parts
     */

    private $codes = array();

    /**
     * Print the output of the console javascript function ?
     */
    private $useConsole = false;

    /**
     * @param $mode
     * @param array $instructions
     * @param array $info - the $info of the renderer to pass context information
     * @return string|null
     * Wrapper around {@link p_render()} that pass the $info through tho the created Renderer
     */
    private static function p_render($mode, array $instructions, array &$info)
    {
        if (is_null($instructions)) return '';
        if ($instructions === false) return '';

        $Renderer = p_get_renderer($mode);
        if (is_null($Renderer)) return null;

        $Renderer->reset();
        if (!empty($info)) {
            $Renderer->info = $info;
        }

        $Renderer->smileys = getSmileys();
        $Renderer->entities = getEntities();
        $Renderer->acronyms = getAcronyms();
        $Renderer->interwiki = getInterwiki();

        // Loop through the instructions
        foreach ($instructions as $instruction) {
            // Execute the callback against the Renderer
            if (method_exists($Renderer, $instruction[0])) {
                call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1] ? $instruction[1] : array());
            }
        }

        //set info array
        $info = $Renderer->info;

        // Post process and return the output
        $data = array($mode, & $Renderer->doc);
        Event::createAndTrigger('RENDERER_CONTENT_POSTPROCESS', $data);
        return $Renderer->doc;

    }


    /**
     * Syntax Type.
     *
     * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
     * @see https://www.dokuwiki.org/devel:syntax_plugins#syntax_types
     *
     * container because it may contain header in case of how to
     */
    public function getType()
    {
        // formatting ?
        // container
        return 'container';
    }

    /**
     * @return array
     * Allow which kind of plugin inside
     *
     * array('container', 'baseonly','formatting', 'substition', 'protected', 'disabled', 'paragraphs')
     *
     */
    public function getAllowedTypes()
    {
        return array('container', 'baseonly', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs');
    }

    /*
     * Don't accept the code mode
     * in order to get the code block
     * in the DOKU_LEXER_MATCHED state through addPattern
     */
    function accepts($mode)
    {
        if ($mode == "code") {
            return false;
        }
        return parent::accepts($mode);
    }


    /**
     * @see Doku_Parser_Mode::getSort()
     * The mode (plugin) with the lowest sort number will win out
     *
     * See {@link Doku_Parser_Mode_code}
     */
    public function getSort()
    {
        return 100;
    }

    /**
     * Called before any calls to ConnectTo<commit_msg>Allow the plugin_combo_code inside a webcode<commit_after><?php
/**
 * Plugin Webcode: Show webcode (Css, HTML) in a iframe
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     <NAME>
 */

// must be run within Dokuwiki
use dokuwiki\Extension\Event;

if (!defined('DOKU_INC')) die();

/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_webcode_basis extends DokuWiki_Syntax_Plugin
{

    const EXTERNAL_RESOURCES_ATTRIBUTE_DISPLAY = 'externalResources'; // In the action bar
    const EXTERNAL_RESOURCES_ATTRIBUTE_KEY = 'externalresources'; // In the code

    // Simple cache bursting implementation for the webCodeConsole.(js|css) file
    // They must be incremented manually when they changed
    const WEB_CONSOLE_CSS_VERSION = 1.1;
    const WEB_CONSOLE_JS_VERSION = 2.1;

    /**
     * @var array that holds the iframe attributes
     */
    private $attributes = array();
    /**
     * @var array That holds the code parts
     */

    private $codes = array();

    /**
     * Print the output of the console javascript function ?
     */
    private $useConsole = false;

    /**
     * @param $mode
     * @param array $instructions
     * @param array $info - the $info of the renderer to pass context information
     * @return string|null
     * Wrapper around {@link p_render()} that pass the $info through tho the created Renderer
     */
    private static function p_render($mode, array $instructions, array &$info)
    {
        if (is_null($instructions)) return '';
        if ($instructions === false) return '';

        $Renderer = p_get_renderer($mode);
        if (is_null($Renderer)) return null;

        $Renderer->reset();
        if (!empty($info)) {
            $Renderer->info = $info;
        }

        $Renderer->smileys = getSmileys();
        $Renderer->entities = getEntities();
        $Renderer->acronyms = getAcronyms();
        $Renderer->interwiki = getInterwiki();

        // Loop through the instructions
        foreach ($instructions as $instruction) {
            // Execute the callback against the Renderer
            if (method_exists($Renderer, $instruction[0])) {
                call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1] ? $instruction[1] : array());
            }
        }

        //set info array
        $info = $Renderer->info;

        // Post process and return the output
        $data = array($mode, & $Renderer->doc);
        Event::createAndTrigger('RENDERER_CONTENT_POSTPROCESS', $data);
        return $Renderer->doc;

    }


    /**
     * Syntax Type.
     *
     * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
     * @see https://www.dokuwiki.org/devel:syntax_plugins#syntax_types
     *
     * container because it may contain header in case of how to
     */
    public function getType()
    {
        // formatting ?
        // container
        return 'container';
    }

    /**
     * @return array
     * Allow which kind of plugin inside
     *
     * array('container', 'baseonly','formatting', 'substition', 'protected', 'disabled', 'paragraphs')
     *
     */
    public function getAllowedTypes()
    {
        return array('container', 'baseonly', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs');
    }

    /*
     * Don't accept the code mode
     * in order to get the code block
     * in the DOKU_LEXER_MATCHED state through addPattern
     */
    function accepts($mode)
    {
        if ($mode == "code" || $mode == "plugin_combo_code") {
            return false;
        }
        return parent::accepts($mode);
    }


    /**
     * @see Doku_Parser_Mode::getSort()
     * The mode (plugin) with the lowest sort number will win out
     *
     * See {@link Doku_Parser_Mode_code}
     */
    public function getSort()
    {
        return 100;
    }

    /**
     * Called before any calls to ConnectTo
{'fraction_non_alphanumeric': 0.11661402400505369, 'fraction_numerical': 0.0030322173089071384, 'mean_word_length': 2.4120689655172414, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1306752', 'n_tokens_mistral': 2356, 'n_tokens_neox': 2253, 'n_words': 666}