From 5c36966537860bfa548ff39757786c53241c005e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=BCng?= Date: Sat, 22 Jul 2023 18:00:29 +0200 Subject: [PATCH] handle empty notes closes #24 and #25 --- evernote2onenote/src/MainFrm.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/evernote2onenote/src/MainFrm.cs b/evernote2onenote/src/MainFrm.cs index 217da48..a05a23f 100644 --- a/evernote2onenote/src/MainFrm.cs +++ b/evernote2onenote/src/MainFrm.cs @@ -64,6 +64,9 @@ public partial class MainFrm : Form private readonly Regex _rxCdata = new Regex(@"", RegexOptions.IgnoreCase); private readonly Regex _rxCdata2 = new Regex(@"", RegexOptions.IgnoreCase); private readonly Regex _rxCdataInner = new Regex(@"\<\!\[CDATA\[(?.*)\]\]\>", RegexOptions.IgnoreCase | RegexOptions.Singleline); + private readonly Regex _rxEmptyCdata = new Regex(@"[\s\n]+\]\]>", RegexOptions.IgnoreCase); + private readonly Regex _rxEmptyCdata2 = new Regex(@"", RegexOptions.IgnoreCase); + private readonly Regex _rxEmptyCdata3 = new Regex(@"[\s\n]+\]\]>", RegexOptions.IgnoreCase); private readonly Regex _rxBodyStart = new Regex(@"/]*>", RegexOptions.IgnoreCase); private readonly Regex _rxBodyEnd = new Regex(@"\s*]]>", RegexOptions.IgnoreCase); private readonly Regex _rxBodyEmpty = new Regex(@"/]*/>\s*]]>", RegexOptions.IgnoreCase); @@ -551,6 +554,9 @@ private void ImportNotesToOnenote(List notesEvernote, string exportFile) htmlBody = _rxFontFamily.Replace(htmlBody, string.Empty); htmlBody = _rxStyle.Replace(htmlBody, "${text}"); htmlBody = _rxComment.Replace(htmlBody, string.Empty); + htmlBody = _rxEmptyCdata.Replace(htmlBody, string.Empty); + htmlBody = _rxEmptyCdata2.Replace(htmlBody, string.Empty); + htmlBody = _rxEmptyCdata3.Replace(htmlBody, string.Empty); htmlBody = _rxCdata.Replace(htmlBody, string.Empty); htmlBody = _rxCdata2.Replace(htmlBody, string.Empty); htmlBody = _rxDtd.Replace(htmlBody, string.Empty);