зеркало из https://github.com/microsoft/Power-Fx.git
Fix PlainText's handling of open tags (#2691)
Fixes #2679 . Currently the PlainText doesn't handle some open tags correctly - the function is supposed to convert things like <br/> to a new line or <p> to two new lines, but it is matching tags such as <bra> and <para> which should not be matched.
This commit is contained in:
Родитель
d53c8425c1
Коммит
ac3d51d049
|
@ -47,8 +47,8 @@ namespace Microsoft.PowerFx.Functions
|
||||||
private static readonly Regex _secondsDetokenizeRegex = new Regex("[\u0008][\u0008]+", RegExFlags);
|
private static readonly Regex _secondsDetokenizeRegex = new Regex("[\u0008][\u0008]+", RegExFlags);
|
||||||
private static readonly Regex _milisecondsDetokenizeRegex = new Regex("[\u000e]+", RegExFlags);
|
private static readonly Regex _milisecondsDetokenizeRegex = new Regex("[\u000e]+", RegExFlags);
|
||||||
private static readonly Regex _tdTagRegex = new Regex("<\\s*(td)[\\s\\S]*?\\/{0,1}>", RegExFlags_IgnoreCase);
|
private static readonly Regex _tdTagRegex = new Regex("<\\s*(td)[\\s\\S]*?\\/{0,1}>", RegExFlags_IgnoreCase);
|
||||||
private static readonly Regex _lineBreakTagRegex = new Regex("<\\s*(br|li)[\\s\\S]*?\\/{0,1}>", RegExFlags_IgnoreCase);
|
private static readonly Regex _lineBreakTagRegex = new Regex("<\\s*(br|li)((\\s+[\\s\\S]*?)|(\\s*\\/\\s*))?>", RegExFlags_IgnoreCase);
|
||||||
private static readonly Regex _doubleLineBreakTagRegex = new Regex("<\\s*(div|p|tr)[\\s\\S]*?\\/{0,1}>", RegExFlags_IgnoreCase);
|
private static readonly Regex _doubleLineBreakTagRegex = new Regex("<\\s*(div|p|tr)((\\s+[\\s\\S]*?)|(\\s*\\/\\s*))?>", RegExFlags_IgnoreCase);
|
||||||
private static readonly Regex _commentTagRegex = new Regex("<!--[\\s\\S]*?--\\s*>", RegExFlags_IgnoreCase);
|
private static readonly Regex _commentTagRegex = new Regex("<!--[\\s\\S]*?--\\s*>", RegExFlags_IgnoreCase);
|
||||||
private static readonly Regex _headerTagRegex = new Regex("<\\s*(header)[\\s\\S]*?>[\\s\\S]*?<\\s*\\/\\s*(header)\\s*>", RegExFlags_IgnoreCase);
|
private static readonly Regex _headerTagRegex = new Regex("<\\s*(header)[\\s\\S]*?>[\\s\\S]*?<\\s*\\/\\s*(header)\\s*>", RegExFlags_IgnoreCase);
|
||||||
private static readonly Regex _scriptTagRegex = new Regex("<\\s*(script)[\\s\\S]*?>[\\s\\S]*?<\\s*\\/\\s*(script)\\s*>", RegExFlags_IgnoreCase);
|
private static readonly Regex _scriptTagRegex = new Regex("<\\s*(script)[\\s\\S]*?>[\\s\\S]*?<\\s*\\/\\s*(script)\\s*>", RegExFlags_IgnoreCase);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
>> PlainText("")
|
>> PlainText("")
|
||||||
""
|
""
|
||||||
|
|
||||||
>> PlainText("<>")
|
>> PlainText("<>")
|
||||||
|
@ -97,4 +97,13 @@ Error({Kind:ErrorKind.Div0})
|
||||||
"1\r\n\r\n2\r\n\r\n3\r\n\r\n4"
|
"1\r\n\r\n2\r\n\r\n3\r\n\r\n4"
|
||||||
|
|
||||||
>> PlainText("Hello<br/>world")
|
>> PlainText("Hello<br/>world")
|
||||||
"Hello<br/>world"
|
"Hello<br/>world"
|
||||||
|
|
||||||
|
>> PlainText("Many character entities: <>&"'¢£¥€©®áèõçûαβγδΔ")
|
||||||
|
"Many character entities: <>&""'¢£¥€©®áèõçûαβγδΔ"
|
||||||
|
|
||||||
|
>> PlainText("More character references: 🥰 - 🥈")
|
||||||
|
"More character references: 🥰 - 🥈"
|
||||||
|
|
||||||
|
>> PlainText("<para>Not a <break>line break.</para><para>Also not a line break.</para>")
|
||||||
|
"Not a line break.Also not a line break."
|
||||||
|
|
Загрузка…
Ссылка в новой задаче