2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
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/>.
18 * Wrapper for Html2Text
20 * This wrapper allows us to modify the upstream library without hacking it too much.
23 * @copyright 2015 Andrew Nicols <andrew@nicols.uk>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') ||
die();
29 require_once($CFG->libdir
. '/html2text/Html2Text.php');
30 require_once(__DIR__
. '/override.php');
33 * Wrapper for Html2Text
35 * This wrapper allows us to modify the upstream library without hacking it too much.
38 * @copyright 2015 Andrew Nicols <andrew@nicols.uk>
39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41 class core_html2text
extends \Html2Text\Html2Text
{
46 * If the HTML source string (or file) is supplied, the class
47 * will instantiate with that source propagated, all that has
48 * to be done it to call get_text().
50 * @param string $html Source HTML
51 * @param array $options Set configuration options
53 function __construct($html = '', $options = array()) {
54 // Call the parent constructor.
55 parent
::__construct($html, $options);
57 // MDL-27736: Trailing spaces before newline or tab.
58 $this->entSearch
[] = '/[ ]+([\n\t])/';
59 $this->entReplace
[] = '\\1';
63 * Strtoupper multibyte wrapper function with HTML entities handling.
65 * @param string $str Text to convert
66 * @return string Converted text
68 protected function strtoupper($str) {
69 return core_text
::strtoupper($str);