Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarsun72 committed Sep 19, 2024
1 parent 4103a46 commit e58248c
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 171 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ textBox2中輸入 `fc` :雙欄目錄或詩偈類型文本的排版(fc=format
#### 小注
Alt + s :小注不換行、夾注不換行
>還有其餘類似功能,詳後開列。
#### 《古籍酷》自動標點
Alt + F10 、 Alt + F11 : 將textBox1中選取的文字送去《古籍酷》自動標點。若無選取則將整個textBox1的內容送去。(小於20字元不處理)20240808(臺灣父親節)

Ctrl + F10、 Ctrl + F11: 將textBox1中選取的文字送去《古籍酷》**舊版**自動標點。若無選取則將整個textBox1的內容送去。(小於20字元不處理)20240808(臺灣父親節)
### 文本檢測
Alt + v: 檢查[查字.mdb].[異體字反正]資料表中是否已有該字記錄,以便程式將`異體字轉正`時參照。如果已有資料對應,則閃示橘紅色(表單顏色=Color.Tomato)0.02秒以示警

Expand Down Expand Up @@ -343,7 +347,7 @@ Ctrl + Alt + f10: 將textBox1中選取的文字送去《古籍酷》自動標

Ctrl + F10、 Ctrl + F11: 將textBox1中選取的文字送去《古籍酷》舊版自動標點。若無選取則將整個textBox1的內容送去。(小於20字元不處理)20240808(臺灣父親節)

F12 : 同 F8 或 Ctrl + Shift + Alt + + 或在非自動且手動輸入模式下,在textBox1 單獨按下數字鍵盤的「+
F12 : 同 F8 或 Ctrl + Shift + Alt + + 或在非自動且手動輸入模式下,在textBox1 單獨按下數字鍵盤的「`+`

Alt + shift + F12 : 更新最後的備份頁文本

Expand Down
Binary file modified TextForCtextPortable.zip
Binary file not shown.
119 changes: 94 additions & 25 deletions WindowsFormsApp1/Browser.cs

Large diffs are not rendered by default.

31 changes: 26 additions & 5 deletions WindowsFormsApp1/CnText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Diagnostics;
using Microsoft.Office.Interop.Word;
using static System.Net.Mime.MediaTypeNames;
using OpenQA.Selenium.DevTools.V125.Runtime;
//using static System.Windows.Forms.VisualStyles.VisualStyleElement;
//using static System.Net.Mime.MediaTypeNames;
//using System.Reflection;
Expand Down Expand Up @@ -699,9 +700,9 @@ internal static int HasPlatecenterTextIncluded(string xChecking)
if (similarity >= threshold)
{
//前一段若為「|」通常是卷末題目
if (i > lines.Length - 2 &&
if (i > lines.Length - 2 &&
("|" + Environment.NewLine).IndexOf(lines[i - 1]) > -1) //也分段/行符號可能還未自動轉換成「|」
continue;
continue;

location = xChecking.IndexOf(lines[i]);
if (location == -1)
Expand Down Expand Up @@ -1031,7 +1032,8 @@ public static void Spaces2Braces(ref string text)
/// <param name="originalText"></param>
/// <param name="punctuatedText"></param>
/// <returns></returns>
public static string RestoreParagraphs(ref string originalText, ref string punctuatedText)
public static string RestoreParagraphs(string originalText,ref string punctuatedText)
//public static string RestoreParagraphs(ref string originalText, ref string punctuatedText)
{

// Define a set of punctuation marks to ignore
Expand Down Expand Up @@ -1082,7 +1084,11 @@ int FindAdjustedPosition(string text, int pos, string before, string after)
else
{
Debugger.Break();
break;
//text=RemovePunctuation(text);
adjustedPos = (before.Length + offset1 + 1);
Form1.playSound(Form1.soundLike.error);
//return -1;
//break;
}
}
if (subTextWithoutPunctuation.Contains(before))
Expand Down Expand Up @@ -1135,7 +1141,7 @@ int FindAdjustedPosition(string text, int pos, string before, string after)
punctuatedText = punctuatedText.Replace(Environment.NewLine, string.Empty);
//清除標點符號以利分段符號之比對搜尋
originalText = RemovePunctuation(originalText);
//清除縮排即凸排格式標記,即將分段符號前後的空格「 」均予清除
//清除縮排即凸排格式標記,即將分段符號前後的空格「 」均予清除//當寫在送去自動標點前!!20240918//發現問題出在使用了 .Text屬性值 故先還原再觀察
originalText = Regex.Replace(originalText, $@"\s*{Environment.NewLine}+\s*", Environment.NewLine);
#endregion

Expand All @@ -1152,6 +1158,21 @@ int FindAdjustedPosition(string text, int pos, string before, string after)
string before = originalText.Substring(start, index - start);
string after = originalText.Substring(index + newLine.Length, end - index - newLine.Length);

//if (char.IsHighSurrogate(before.LastOrDefault()))
// before = originalText.Substring(start, index - start + 1);
if (char.IsLowSurrogate(before.FirstOrDefault()))
{
Debugger.Break();
before = originalText.Substring(start - 1, index - start);
}
if (char.IsHighSurrogate(after.LastOrDefault()))
{
Debugger.Break();
after = originalText.Substring(index + newLine.Length, end - index - newLine.Length + 1);
}
//if (char.IsLowSurrogate(after.FirstOrDefault()))
// after = originalText.Substring(index + newLine.Length, end - index - newLine.Length);

// Ensure 'before' and 'after' do not include newline characters
while (before.Contains('\r') || before.Contains('\n'))
{
Expand Down
Loading

0 comments on commit e58248c

Please sign in to comment.