Improve editing values with {return} in text fields; Add hyperlink detection.

This commit is contained in:
Alex Shvartzkop
2023-10-15 01:45:39 +03:00
parent 95032bd487
commit 9ed19192de
10 changed files with 91 additions and 27 deletions
+21
View File
@@ -33,6 +33,7 @@
#include <richio.h> // StrPrintf
#include <string_utils.h>
#include <fmt/chrono.h>
#include <wx/regex.h>
/**
@@ -548,6 +549,26 @@ wxString UnescapeHTML( const wxString& aString )
}
wxString RemoveHTMLTags( const wxString& aInput )
{
wxString str = aInput;
wxRegEx( wxS( "<[^>]*>" ) ).ReplaceAll( &str, wxEmptyString );
return str;
}
wxString LinkifyHTML( wxString aStr )
{
wxRegEx regex( wxS( "\\b(https?|ftp|file)://([-\\w+&@#/%?=~|!:,.;]*[^.<>\\s\u00b6])" ),
wxRE_ICASE );
regex.ReplaceAll( &aStr, "<a href=\"\\0\">\\0</a>" );
return aStr;
}
bool NoPrintableChars( const wxString& aString )
{
wxString tmp = aString;