From 45ac20c7a4d632bbb23aaba50c2d79ac5ebac465 Mon Sep 17 00:00:00 2001 From: winter Date: Fri, 14 Feb 2025 17:56:45 +0000 Subject: implement formatted note contents (html and commonmark) --- Digitigrade/FormattingProvider/SanitisedHtml.php | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Digitigrade/FormattingProvider/SanitisedHtml.php (limited to 'Digitigrade/FormattingProvider/SanitisedHtml.php') diff --git a/Digitigrade/FormattingProvider/SanitisedHtml.php b/Digitigrade/FormattingProvider/SanitisedHtml.php new file mode 100644 index 0000000..fa2e5eb --- /dev/null +++ b/Digitigrade/FormattingProvider/SanitisedHtml.php @@ -0,0 +1,31 @@ +sanitiser = new HtmlSanitizer((new HtmlSanitizerConfig()) + ->allowSafeElements() + ->allowLinkSchemes(self::ALLOWED_URL_SCHEMES) + ); + } + + public function renderToHtml(string $input): string { + return $this->sanitiser->sanitize($input); + } + + public function renderToPlainText(string $input): string { + // TODO: somehow remove tags and leave the unformatted content behind + return htmlspecialchars($input); + } +} \ No newline at end of file -- cgit v1.3