From d26f6eca566376a9af6a999558cbc6f502940c9d Mon Sep 17 00:00:00 2001 From: Laurence Luo Date: Sun, 24 Nov 2024 18:31:09 +0800 Subject: [PATCH] Update --- KindleMate2/FrmMain.cs | 13 +++++++++++-- KindleMate2/KindleMate2.csproj | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/KindleMate2/FrmMain.cs b/KindleMate2/FrmMain.cs index ef90a9f..02170aa 100644 --- a/KindleMate2/FrmMain.cs +++ b/KindleMate2/FrmMain.cs @@ -11,6 +11,7 @@ using KindleMate2.Entities; using KindleMate2.Properties; using Markdig; +using Markdig.Helpers; namespace KindleMate2 { public partial class FrmMain : Form { @@ -840,6 +841,7 @@ .. File.ReadAllLines(clippingsPath) var delimiterIndex = new List(); for (var i = 0; i < lines.Count; i++) { + lines[i] = RemoveControlChar(lines[i]); if (lines[i].StartsWith("===") && lines[i - 2].Trim().Equals("") && lines[i].EndsWith("===")) { delimiterIndex.Add(i); } @@ -897,7 +899,7 @@ .. File.ReadAllLines(clippingsPath) clippingtypelocation = split_b[0][1..].Trim(); } var pagenumber = -1; - var pagenPattern = @"#\d+(-\d+)?"; + var pagenPattern = @"\d+(-\d+)?"; var isPagenIsMatch = Regex.IsMatch(clippingtypelocation, pagenPattern); var romanPattern = @"^(M{0,3})(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$"; var isRomanMatched = Regex.IsMatch(clippingtypelocation, romanPattern); @@ -1535,7 +1537,6 @@ private void MenuImportKindle_Click(object sender, EventArgs e) { private void SetProgressBar(bool isShow) { progressBar.Enabled = isShow; progressBar.Visible = isShow; - Enabled = !isShow; } private void MenuImportKindleMate_Click(object sender, EventArgs e) { @@ -2716,5 +2717,13 @@ private void TreeViewWords_KeyDown(object sender, KeyEventArgs e) { MenuBooksDelete_Click(sender, e); } } + + private static string RemoveControlChar(string input) { + var output = new StringBuilder(); + foreach (var c in input.Where(c => !c.IsControl() && !c.IsNewLineOrLineFeed() && c != 65279)) { + output.Append(c); + } + return output.ToString(); + } } } \ No newline at end of file diff --git a/KindleMate2/KindleMate2.csproj b/KindleMate2/KindleMate2.csproj index e10e057..0bf8aac 100644 --- a/KindleMate2/KindleMate2.csproj +++ b/KindleMate2/KindleMate2.csproj @@ -22,7 +22,7 @@ latest https://github.com/lzcapp/KindleMate2/blob/main/LICENSE - 2024.10.9 + 2024.11.21 false