Skip to content

Commit

Permalink
handle empty notes
Browse files Browse the repository at this point in the history
closes #24 and #25
  • Loading branch information
stefankueng committed Jul 22, 2023
1 parent c3371d9 commit 5c36966
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions evernote2onenote/src/MainFrm.cs
Expand Up @@ -64,6 +64,9 @@ public partial class MainFrm : Form
private readonly Regex _rxCdata = new Regex(@"<!\[CDATA\[<\?xml version=[""']1.0[""'][^?]*\?>", RegexOptions.IgnoreCase);
private readonly Regex _rxCdata2 = new Regex(@"<!\[CDATA\[<!DOCTYPE en-note \w+ ""https?://xml.evernote.com/pub/enml2.dtd"">", RegexOptions.IgnoreCase);
private readonly Regex _rxCdataInner = new Regex(@"\<\!\[CDATA\[(?<text>.*)\]\]\>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
private readonly Regex _rxEmptyCdata = new Regex(@"<!\[CDATA\[<\?xml version=[""']1.0[""'][^?]*\?>[\s\n]+\]\]>", RegexOptions.IgnoreCase);
private readonly Regex _rxEmptyCdata2 = new Regex(@"<!\[CDATA\[[\s\n]+\]\]>", RegexOptions.IgnoreCase);
private readonly Regex _rxEmptyCdata3 = new Regex(@"<!\[CDATA\[>[\s\n]+\]\]>", RegexOptions.IgnoreCase);
private readonly Regex _rxBodyStart = new Regex(@"<en-note[^>/]*>", RegexOptions.IgnoreCase);
private readonly Regex _rxBodyEnd = new Regex(@"</en-note\s*>\s*]]>", RegexOptions.IgnoreCase);
private readonly Regex _rxBodyEmpty = new Regex(@"<en-note[^>/]*/>\s*]]>", RegexOptions.IgnoreCase);
Expand Down Expand Up @@ -551,6 +554,9 @@ private void ImportNotesToOnenote(List<Note> 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);
Expand Down

0 comments on commit 5c36966

Please sign in to comment.