You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using ArabicSupport;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
public static class ArabicFixerHelper
|
|
|
|
|
{
|
|
|
|
|
public static string FixPreservingTags(string rawText)
|
|
|
|
|
{
|
|
|
|
|
// Match <link=...><3E></link> and preserve it
|
|
|
|
|
var regex = new Regex(@"<link=.*?</link>", RegexOptions.IgnoreCase);
|
|
|
|
|
var matches = regex.Matches(rawText);
|
|
|
|
|
|
|
|
|
|
string fixedText = rawText;
|
|
|
|
|
|
|
|
|
|
foreach (Match match in matches)
|
|
|
|
|
{
|
|
|
|
|
string tag = match.Value;
|
|
|
|
|
string placeholder = $"[[LINK{match.Index}]]";
|
|
|
|
|
|
|
|
|
|
fixedText = fixedText.Replace(tag, placeholder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Apply ArabicFixer to the full string with placeholders
|
|
|
|
|
fixedText = ArabicFixer.Fix(fixedText);
|
|
|
|
|
|
|
|
|
|
// Replace placeholders back with original tags
|
|
|
|
|
foreach (Match match in matches)
|
|
|
|
|
{
|
|
|
|
|
string tag = match.Value;
|
|
|
|
|
string placeholder = ArabicFixer.Fix($"[[LINK{match.Index}]]");
|
|
|
|
|
fixedText = fixedText.Replace(placeholder, tag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fixedText;
|
|
|
|
|
}
|
|
|
|
|
}
|