johansan 48 Posted April 30, 2023 Share Posted April 30, 2023 Hello all, If you (maybe based on the recent price increase) have tried to move from Evernote to Apple Notes, you might have noticed that ordered and unordered lists have double line spacing when imported into Apple Notes, like: First item Second item Third item This is due to list item contents being encapsulated within DIV tags, which causes Apple Notes ENEX-importer to add extra lines. To fix this I wrote together a quick Python script to fix the issue. To run it, just install something like PyCharm, then: Start a new project Paste the text below Change the root folder on the last line to the folder where you have all your ENEX files. The script searches recursively in subfolders. import the library dependencies (just right click pathlib, re and glob at the top Then run it Please note that I take no responsibility for any issues this script might cause, by copying the code below you acknowledge that you take full responsibility for running it on your computer. from pathlib import Path import re import glob def remove_nested_div_tags(text): # Regex pattern for nested DIV tags within LI tags pattern = r'(<li[^>]*>)(.*?)(<\/li>)' # Function to process each match found def process_match(match): list_start, list_content, list_end = match.groups() list_content = re.sub(r'<div[^>]*>(.*?)<\/div>', r'\1', list_content) return list_start + list_content + list_end # Replace the nested DIV tags with their content output_str = re.sub(pattern, process_match, text) return output_str def process_files(root_dir): # root_dir needs a trailing slash (i.e. /root/dir/) for filename in glob.iglob(root_dir + '**/*.enex', recursive=True): print(filename) with open(filename, "r+") as enex_file: content = enex_file.readlines() # Combine the lines in the list into a string content = "".join(content) content = remove_nested_div_tags(content) p = Path(filename) path = str(p.parent) name = p.stem extension = p.suffix outname = path + '/_' + name + extension with open(outname, 'w') as file: file.write(content) file.close() enex_file.close() if __name__ == '__main__': process_files('/Users/johan/Desktop/Evernote 20230430/') 3 Link to comment
eric99 1,081 Posted April 30, 2023 Share Posted April 30, 2023 2 hours ago, johansan said: Hello all, If you (maybe based on the recent price increase) have tried to move from Evernote to Apple Notes, you might have noticed that ordered and unordered lists have double line spacing when imported into Apple Notes, like: First item Second item Third item This is due to list item contents being encapsulated within DIV tags, which causes Apple Notes ENEX-importer to add extra lines. To fix this I wrote together a quick Python script to fix the issue. To run it, just install something like PyCharm, then: Start a new project Paste the text below Change the root folder on the last line to the folder where you have all your ENEX files. The script searches recursively in subfolders. import the library dependencies (just right click pathlib, re and glob at the top Then run it Please note that I take no responsibility for any issues this script might cause, by copying the code below you acknowledge that you take full responsibility for running it on your computer. from pathlib import Path import re import glob def remove_nested_div_tags(text): # Regex pattern for nested DIV tags within LI tags pattern = r'(<li[^>]*>)(.*?)(<\/li>)' # Function to process each match found def process_match(match): list_start, list_content, list_end = match.groups() list_content = re.sub(r'<div[^>]*>(.*?)<\/div>', r'\1', list_content) return list_start + list_content + list_end # Replace the nested DIV tags with their content output_str = re.sub(pattern, process_match, text) return output_str def process_files(root_dir): # root_dir needs a trailing slash (i.e. /root/dir/) for filename in glob.iglob(root_dir + '**/*.enex', recursive=True): print(filename) with open(filename, "r+") as enex_file: content = enex_file.readlines() # Combine the lines in the list into a string content = "".join(content) content = remove_nested_div_tags(content) p = Path(filename) path = str(p.parent) name = p.stem extension = p.suffix outname = path + '/_' + name + extension with open(outname, 'w') as file: file.write(content) file.close() enex_file.close() if __name__ == '__main__': process_files('/Users/johan/Desktop/Evernote 20230430/') Does Apple Notes have note links? If so, how will you port them? Link to comment
Level 5 PinkElephant 8,802 Posted April 30, 2023 Level 5 Share Posted April 30, 2023 The only links I am aware of in Apple notes are links to the internet, the usual URL type. There are no note2note links, and no backlinks. Link to comment
johansan 48 Posted April 30, 2023 Author Share Posted April 30, 2023 1 hour ago, PinkElephant said: The only links I am aware of in Apple notes are links to the internet, the usual URL type. There are no note2note links, and no backlinks. Yes, no note-2-note links, no backlinks. No highlight color, no code block. And pretty poor text formatting as well (no extra line spacing before headings etc). Apple Notes is pretty ***** unfortunately, which means I will probably stay with Evernote myself despite the price increase. Link to comment
Level 5 PinkElephant 8,802 Posted April 30, 2023 Level 5 Share Posted April 30, 2023 Apple is rarely competing head on against smaller developers. The basic functions are ok, but more advanced functions are often missing. They participate in the end when we users load the devs apps from the AppStore. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now