12
12
using System . Diagnostics ;
13
13
using Microsoft . Office . Interop . Word ;
14
14
using static System . Net . Mime . MediaTypeNames ;
15
+ using OpenQA . Selenium . DevTools . V125 . Runtime ;
15
16
//using static System.Windows.Forms.VisualStyles.VisualStyleElement;
16
17
//using static System.Net.Mime.MediaTypeNames;
17
18
//using System.Reflection;
@@ -699,9 +700,9 @@ internal static int HasPlatecenterTextIncluded(string xChecking)
699
700
if ( similarity >= threshold )
700
701
{
701
702
//前一段若為「|」通常是卷末題目
702
- if ( i > lines . Length - 2 &&
703
+ if ( i > lines . Length - 2 &&
703
704
( "|" + Environment . NewLine ) . IndexOf ( lines [ i - 1 ] ) > - 1 ) //也分段/行符號可能還未自動轉換成「|」
704
- continue ;
705
+ continue ;
705
706
706
707
location = xChecking . IndexOf ( lines [ i ] ) ;
707
708
if ( location == - 1 )
@@ -1031,7 +1032,8 @@ public static void Spaces2Braces(ref string text)
1031
1032
/// <param name="originalText"></param>
1032
1033
/// <param name="punctuatedText"></param>
1033
1034
/// <returns></returns>
1034
- public static string RestoreParagraphs ( ref string originalText , ref string punctuatedText )
1035
+ public static string RestoreParagraphs ( string originalText , ref string punctuatedText )
1036
+ //public static string RestoreParagraphs(ref string originalText, ref string punctuatedText)
1035
1037
{
1036
1038
1037
1039
// Define a set of punctuation marks to ignore
@@ -1082,7 +1084,11 @@ int FindAdjustedPosition(string text, int pos, string before, string after)
1082
1084
else
1083
1085
{
1084
1086
Debugger . Break ( ) ;
1085
- break ;
1087
+ //text=RemovePunctuation(text);
1088
+ adjustedPos = ( before . Length + offset1 + 1 ) ;
1089
+ Form1 . playSound ( Form1 . soundLike . error ) ;
1090
+ //return -1;
1091
+ //break;
1086
1092
}
1087
1093
}
1088
1094
if ( subTextWithoutPunctuation . Contains ( before ) )
@@ -1135,7 +1141,7 @@ int FindAdjustedPosition(string text, int pos, string before, string after)
1135
1141
punctuatedText = punctuatedText . Replace ( Environment . NewLine , string . Empty ) ;
1136
1142
//清除標點符號以利分段符號之比對搜尋
1137
1143
originalText = RemovePunctuation ( originalText ) ;
1138
- //清除縮排即凸排格式標記,即將分段符號前後的空格「 」均予清除
1144
+ //清除縮排即凸排格式標記,即將分段符號前後的空格「 」均予清除//當寫在送去自動標點前!!20240918//發現問題出在使用了 .Text屬性值 故先還原再觀察
1139
1145
originalText = Regex . Replace ( originalText , $@ "\s*{ Environment . NewLine } +\s*", Environment . NewLine ) ;
1140
1146
#endregion
1141
1147
@@ -1152,6 +1158,21 @@ int FindAdjustedPosition(string text, int pos, string before, string after)
1152
1158
string before = originalText . Substring ( start , index - start ) ;
1153
1159
string after = originalText . Substring ( index + newLine . Length , end - index - newLine . Length ) ;
1154
1160
1161
+ //if (char.IsHighSurrogate(before.LastOrDefault()))
1162
+ // before = originalText.Substring(start, index - start + 1);
1163
+ if ( char . IsLowSurrogate ( before . FirstOrDefault ( ) ) )
1164
+ {
1165
+ Debugger . Break ( ) ;
1166
+ before = originalText . Substring ( start - 1 , index - start ) ;
1167
+ }
1168
+ if ( char . IsHighSurrogate ( after . LastOrDefault ( ) ) )
1169
+ {
1170
+ Debugger . Break ( ) ;
1171
+ after = originalText . Substring ( index + newLine . Length , end - index - newLine . Length + 1 ) ;
1172
+ }
1173
+ //if (char.IsLowSurrogate(after.FirstOrDefault()))
1174
+ // after = originalText.Substring(index + newLine.Length, end - index - newLine.Length);
1175
+
1155
1176
// Ensure 'before' and 'after' do not include newline characters
1156
1177
while ( before . Contains ( '\r ' ) || before . Contains ( '\n ' ) )
1157
1178
{
0 commit comments