Format calendar event description
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:linkify/linkify.dart';
|
||||
class SanitizeAutolinkFilter {
|
||||
|
||||
final HtmlEscape htmlEscape;
|
||||
final bool escapeHtml;
|
||||
final _linkifyOption = const LinkifyOptions(
|
||||
humanize: true,
|
||||
looseUrl: true,
|
||||
@@ -18,7 +19,7 @@ class SanitizeAutolinkFilter {
|
||||
const UrlLinkifier()
|
||||
];
|
||||
|
||||
SanitizeAutolinkFilter(this.htmlEscape);
|
||||
SanitizeAutolinkFilter(this.htmlEscape, {this.escapeHtml = true});
|
||||
|
||||
String process(String inputText) {
|
||||
try {
|
||||
@@ -36,7 +37,7 @@ class SanitizeAutolinkFilter {
|
||||
|
||||
for (var element in elements) {
|
||||
if (element is TextElement) {
|
||||
final escapedHtml = htmlEscape.convert(element.text);
|
||||
final escapedHtml = escapeHtml ? htmlEscape.convert(element.text) : element.text;
|
||||
htmlTextBuffer.write(escapedHtml);
|
||||
} else if (element is EmailElement) {
|
||||
final emailLinkTag = _buildEmailLinkTag(
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:core/presentation/utils/html_transformer/base/text_transformer.dart';
|
||||
|
||||
class NewLineTransformer extends TextTransformer {
|
||||
const NewLineTransformer();
|
||||
|
||||
@override
|
||||
String process(String text, HtmlEscape htmlEscape) {
|
||||
return text
|
||||
.replaceAll('\n', '<br>')
|
||||
.replaceAll('\r', ' ')
|
||||
.replaceAll('\t', ' ');
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:core/presentation/utils/html_transformer/base/text_transformer.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/sanitize_autolink_filter.dart';
|
||||
|
||||
class SanitizeAutolinkUnescapeHtmlTransformer extends TextTransformer {
|
||||
const SanitizeAutolinkUnescapeHtmlTransformer();
|
||||
|
||||
@override
|
||||
String process(String text, HtmlEscape htmlEscape) {
|
||||
return SanitizeAutolinkFilter(htmlEscape, escapeHtml: false).process(text);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user