Commit 94ace1f424
Unsigned
Layout: unified · split
content/blog/2024-04-06-convert-onenote-to-markdown.org added +80
| @@ -0,0 +1,80 @@ | ||
| 1 | #+title: Convert OneNote to Markdown (or Org-Mode) | |
| 2 | #+date: <2024-04-06 Sat 10:00:00> | |
| 3 | #+description: Learn how to convert OneNote pages or tabs to another format, such as Markdown or Org-Mode. | |
| 4 | #+filetags: :dev: | |
| 5 | #+slug: convert-onenote-to-markdown | |
| 6 | ||
| 7 | If you're looking to convert your OneNote content to another format, such as | |
| 8 | Markdown or Org-Mode, you're in luck. I use a solution that doesn't require | |
| 9 | other programs, such as Evernote or Notion. Personally, I used this solution on | |
| 10 | a managed corporate laptop that doesn't allow installation of other programs | |
| 11 | like these. | |
| 12 | ||
| 13 | This solution uses OneNote and Pandoc on Windows 10. | |
| 14 | ||
| 15 | * Export OneNote Content to Word | |
| 16 | ||
| 17 | To start, export any pages or tabs from OneNote to the Word format (=.docx=): | |
| 18 | ||
| 19 | 1. Open OneNote desktop. | |
| 20 | 2. Select =File= and then =Export=. | |
| 21 | 3. Select the scope of content to export, such as =Tab= or =Page=. | |
| 22 | 4. Name and save the file in an easy to remember location. I recommend your | |
| 23 | Downloads or Desktop folder. | |
| 24 | ||
| 25 | * Download Pandoc | |
| 26 | ||
| 27 | Start by downloading Pandoc from their [[https://github.com/jgm/pandoc/releases][GitHub releases]] page. I cannot install | |
| 28 | =.msi= files on my corporate laptop, so I downloaded the = | |
| 29 | pandoc-3.1.12.3-windows-x86_64.zip= file, which contains a simple =.exe= file | |
| 30 | that you do not need to install - you will simply run it from the command line | |
| 31 | below. | |
| 32 | ||
| 33 | Once downloaded, unzip the archive and move the =pandoc.exe= file to the same | |
| 34 | folder where your Word documents were saved above. If you prefer, you can move | |
| 35 | this file to an easier location, such as =C:\Users\youruser\Downloads=. | |
| 36 | ||
| 37 | * Convert Word to Markdown | |
| 38 | ||
| 39 | In this example, I will be converting the Word documents to Markdown, but Pandoc | |
| 40 | supports [[https://github.com/jgm/pandoc?tab=readme-ov-file#the-universal-markup-converter][a ton of different formats for conversion]]. Choose the format you prefer | |
| 41 | and then modify the following commands as needed. | |
| 42 | ||
| 43 | To perform the conversion, open the Command Prompt. If you can't find it, open | |
| 44 | the start menu and search for it. | |
| 45 | ||
| 46 | Within the command prompt, navigate to the directory where you stored the | |
| 47 | =pandoc.exe= file and the Word documents. | |
| 48 | ||
| 49 | #+begin_src cli | |
| 50 | cd "C:\Users\yourusername\Downloads" | |
| 51 | #+end_src | |
| 52 | ||
| 53 | You can verify that you're in the correct directory with the =dir= command. | |
| 54 | ||
| 55 | #+begin_src cli | |
| 56 | dir | |
| 57 | #+end_src | |
| 58 | ||
| 59 | Once you have verified that you have the command prompt open in the correct | |
| 60 | directory with the =pandoc.exe= and the Word documents, you can run the | |
| 61 | following loop to convert all Word documents to Markdown. | |
| 62 | ||
| 63 | #+begin_src cli | |
| 64 | for %f in (*.docx) do (pandoc.exe --extract-media=. --wrap=preserve "%f" "%f.md") | |
| 65 | #+end_src | |
| 66 | ||
| 67 | This loop will perform the following actions: | |
| 68 | ||
| 69 | 1. Find all documents matching the pattern =*.docx=, which means all Word | |
| 70 | documents ending with that file extension. | |
| 71 | 2. Iterate through all files found in step 1. | |
| 72 | 3. For each file, perform the pandoc command. | |
| 73 | 4. Within the pandoc command, =--extract-media= saves all media found in the | |
| 74 | files to the current folder, with pandoc automatically creating a =media= | |
| 75 | subfolder to hold all images. | |
| 76 | 5. Within the pandoc command, =--wrap=preserve= will attempt to prseerve the | |
| 77 | wrapping from the source document. | |
| 78 | 6. Within the pandoc command, the final step is to specify the output path with | |
| 79 | =-o=. This option adds the =.md= file extension to recognize the output files | |
| 80 | as Markdown files. | |
publish.el +2 −2
| @@ -8,12 +8,12 @@ | ||
| 8 | 8 | ;; defaults to http://localhost:8000 |
| 9 | 9 | ;; ENV=prod emacs --script publish.el |
| 10 | 10 | (if (string= (getenv "ENV") "prod") |
| 11 | (setq weblorg-default-url "https://cleberg.net")) | |
| 11 | (setq weblorg-default-url "https://cleberg.net")) | |
| 12 | 12 | |
| 13 | 13 | (weblorg-site |
| 14 | 14 | :theme nil |
| 15 | 15 | :template-vars '(("site_name" . "cleberg.net") |
| 16 | ("site_owner" . "hello@cleberg.net") | |
| 16 | ("site_owner" . "Christian Cleberg <hello@cleberg.net>") | |
| 17 | 17 | ("site_description" . "Just a blip of ones and zeroes."))) |
| 18 | 18 | |
| 19 | 19 | ;; route for rendering the index page of the website |