Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 13... Línea 13...
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
17
/**
17
/**
18
 * Code highlighter filter.
18
 * File only retained to prevent fatal errors in code that tries to require/include this.
-
 
19
 *
19
 *
20
 * @todo MDL-82708 delete this file as part of Moodle 6.0 development.
20
 * Filter converting text code into a well-styled block of code.
-
 
21
 *
21
 * @deprecated This file is no longer required in Moodle 4.5+.
22
 * @package    filter_codehighlighter
22
 * @package filter_codehighlighter
23
 * @copyright  2023 Meirza <meirza.arson@moodle.com>
23
 * @copyright Meirza <meirza.arson@moodle.com>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
-
 
26
class filter_codehighlighter extends moodle_text_filter {
-
 
27
    /**
25
 */
28
     * Apply the filter to the text
-
 
29
     *
-
 
30
     * @param string $text to be processed by the text
-
 
31
     * @param array $options filter options
-
 
32
     * @return string text after processing
-
 
33
     */
-
 
34
    public function filter($text, array $options = []): string {
-
 
35
        global $PAGE;
-
 
36
 
-
 
37
        if (!isset($options['originalformat'])) {
-
 
38
            return $text;
-
 
39
        }
-
 
40
 
-
 
41
        // The pattern.
-
 
42
        $re = '/<pre.+?class=".*?language-.*?"><code>/i';
-
 
43
 
-
 
44
        // Stops looking after the first match.
-
 
45
        preg_match($re, $text, $matches);
-
 
46
        if ($matches) {
-
 
47
            $PAGE->requires->js_call_amd('filter_codehighlighter/prism-init');
-
 
Línea 48... Línea 26...
48
        }
26
defined('MOODLE_INTERNAL') || die();
49
 
-
 
50
        return $text;
-