Return a sanitized version of a text which can be assigned to a javascript variable.

@param string $text The text to sanitize

@return string
332318
public function script($text)
    {
        return htmlspecialchars(
               $this->getService('anahita:filter.string')
               ->sanitize(AnHelperString::str_ireplace(array("\r\n", "\n"), '', $text)), ENT_QUOTES);
    }
293302
public function sanitizeString($string)
    {
        $string = str_replace('_', '-', GeneralUtility::camelCaseToLowerCaseUnderscored($string));

        while (strpos($string, '--')) {
            $string = str_replace('--', '-', $string);
        }

        return $string;
    }
711619
static function parse($text)
    {
        $parser = new \Parsedown();

        $text = static::cleanLeadingSpace($text);

        return $parser->text($text);
    }
1241713
private static function toCamelCase(string $text): string
    {
        if (strpos($text, '_') !== false) {
            $text = str_replace(' ', '', ucwords(str_replace('_', ' ', $text)));
        }
        $text[0] = strtolower($text[0]);

        return $text;
    }
1362530
public function processText(string $text): string
    {
        $text = str_replace("<br>", "", $text);
        $text = str_replace("<br/>", "", $text);
        $text = str_replace("<br />", "", $text);
        $text = str_replace("\n", "<br>", $text);
        $text = str_replace("\t", "&nbsp; &nbsp; &nbsp;", $text);

        return preg_replace($this->pattern, $this->replace, $text);
    }
1132628
public static function clearText(string $text = null) : string
    {
        if (is_null($text)){
            return '';
        }
        return strip_tags(trim($text));
    }
1080856
public function quoteIdentifier($text)
    {
        if ($this->getTable()->isIdentifierQuotingEnabled()) {
            return $this->getPlatform()->doQuoting($text);
        }

        return $text;
    }
382967
public static function htmlEntities($text)
    {
        $flag = defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : ENT_IGNORE;
        return htmlspecialchars($text, ENT_COMPAT | $flag, 'UTF-8');
    }
1007413
public function text($text) {

        if(false === is_string($text)) {
            return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($text)), E_USER_ERROR);
        }

    	$this -> text = $text;

    	return $this;
    }
871325
public function getElementName(string $text = null): string
    {
        if ($text) {
            $text = str_replace('.', '_', $text);

            return '_' . $text;
        }

        return 'js_amiGridList_' . $this->id;
    }
41409
public static function underscore($text) {
        $pregRule = '#[A-Z]+#';
        $text = preg_replace_callback($pregRule, function($match) { return "_" . strtolower($match[0]); }, $text);

        return self::slugify($text, '_');
    }
285991
public static function transliterate($text)
    {
        self::init();

        if (preg_match_all(self::$regex, $text, $matches)) {
            for ($i = 0; $i < count($matches[0]); $i++) {
                $char = $matches[0][$i];
                if (isset (self::$map[$char])) {
                    $text = str_replace($char, self::$map[$char], $text);
                }
            }
        }

        return $text;
    }
1289491
public static function cleanText(string $text)
    {
        $text = preg_replace('/<script[^>]*>.*?</script>/si', '', $text);
        $text = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $text);
        $text = preg_replace('/<!--.+?-->/', '', $text);
        $text = preg_replace('/{.+?}/', '', $text);
        $text = preg_replace('/&nbsp;/', ' ', $text);
        $text = preg_replace('/&amp;/', ' ', $text);
        $text = preg_replace('/&quot;/', ' ', $text);
        $text = strip_tags($text);
        $text = htmlspecialchars($text);

        return $text;
    }
920559
function sanitiseString($string)
    {
        $search = array('–', '’');
        $replace = array('-', '\'');
        $string = str_replace($search, $replace, $string);
        return $string;
    }
362733
private function normalizeText($text): string
    {
/* @TODO: try to resolve at a later date; Twig's `| raw` just returns a string, not `Markup` so we can't use that as a check
        if ($text instanceof Markup) {
            // Either came from a Redactor field (or the like) or they manually added a |raw tag. We can trust it
            $text = (string)$text;
        } else {
            // We don't trust it, so escape any HTML
            $twig = Craft::$app->view->twig;
            try {
                $text = twig_escape_filter($twig, $text);
            } catch (\Twig_Error_Runtime $e) {
                $error = $e->getMessage();
                Craft::error($error, __METHOD__);
                // We don't want unescaped text slipping through, so set the text to the error message
                $text = $error;
            }
        }
*/
        // If it's null or otherwise empty, just return an empty string
        if (empty($text)) {
            $text = '';
        }
        $text = (string)$text;

        $settings = Typogrify::$plugin->getSettings();

        if ($settings['default_escape'] === true) {
            $twig = Craft::$app->view->twig;
            $text = twig_escape_filter($twig, $text);
        }

        return $text;
    }
793472
protected function get_illegal_tag_error($text) {
        // Remove legal tags.
        $strippedtext = $text;
        foreach ($this->allowedhtmltags as $htmltag) {
            $tagpair = "~<\s*/?\s*$htmltag\b\s*[^>]*>~";
            $strippedtext = preg_replace($tagpair, '', $strippedtext);
        }

        $textarray = array();
        preg_match_all($this->htmltstarttagsandattributes, $strippedtext, $textarray);
        if ($textarray[0]) {
            return $this->allowed_tags_message($textarray[0][0]);
        }

        preg_match_all($this->htmltclosetags, $strippedtext, $textarray);
        if ($textarray[0]) {
            return $this->allowed_tags_message($textarray[0][0]);
        }

        return '';
    }
1191300
public function quote($text)
    {
        if ($con = $this->getConnection()) {
            return $con->quote($text);
        } else {
            return "'" . $this->disconnectedEscapeText($text) . "'";
        }
    }