Skip to content

Commit

Permalink
patch from Endre Szesztay:
Browse files Browse the repository at this point in the history
-the first empty rows after a paragraph disappeared during the transfer. It happens in the onenote api, but adding a &nbsp; before <br> seems to solve it
-simple formatting disappeared, like text and background color. I think it was not intentional, i corrected it and for me it works.
  • Loading branch information
stefankueng committed Jan 15, 2024
1 parent 47ea29d commit a6042d5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions evernote2onenote/src/MainFrm.cs
Expand Up @@ -74,7 +74,7 @@ public partial class MainFrm : Form
private readonly Regex _rxNote = new Regex("<title>(.+)</title>", RegexOptions.IgnoreCase);
private readonly Regex _rxComment = new Regex("<!--(.+)-->", RegexOptions.IgnoreCase);
private readonly Regex _rxDtd = new Regex(@"<!DOCTYPE en-note SYSTEM \""http:\/\/xml\.evernote\.com\/pub\/enml\d*\.dtd\"">", RegexOptions.IgnoreCase | RegexOptions.Compiled);

private readonly Regex _rxBrOnly = new Regex("<br( |/)", RegexOptions.IgnoreCase);
public MainFrm(string cmdNotebook, string cmdDate)
{
InitializeComponent();
Expand Down Expand Up @@ -609,11 +609,13 @@ private void ImportNotesToOnenote(List<Note> notesEvernote, string exportFile)
note.Attachments.Clear();

htmlBody = _rxFontFamily.Replace(htmlBody, string.Empty);
// Insert &nbsp; before <br> to newline being effective
htmlBody = _rxBrOnly.Replace(htmlBody, "&nbsp;$&");
htmlBody = _rxStyle.Replace(htmlBody, delegate (Match m)
{
if (m.Value.Contains("--en-codeblock:true;"))
return m.Result("<br><br>${text}") + "style=\"background-color:#B0B0B0; font-family: Consolas, Courier New, monospace; font-size: 15px;\"";
return m.Result("${text}");
return m.Result("$&"); // this "$&" restores the original row, so formatting remains in the xml
});
htmlBody = htmlBody.Replace("<pre>", "<br><br><pre style=\"font-family: Consolas, Courier New, monospace; font-size: 15px; background-color:#B0B0B0;\">");
htmlBody = htmlBody.Replace("</pre>", "</pre><br><br>");
Expand Down

0 comments on commit a6042d5

Please sign in to comment.