Commit 94ace1f424

94ace1f4243bbcb45e335e707e824d3b15e9f1eb

parent: 632c33f662

Unsigned

cmc <hello@cleberg.net> · 2024-04-08 03:32 UTC

add onenote to markdown post

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
7If you're looking to convert your OneNote content to another format, such as
8Markdown or Org-Mode, you're in luck. I use a solution that doesn't require
9other programs, such as Evernote or Notion. Personally, I used this solution on
10a managed corporate laptop that doesn't allow installation of other programs
11like these.
12
13This solution uses OneNote and Pandoc on Windows 10.
14
15* Export OneNote Content to Word
16
17To start, export any pages or tabs from OneNote to the Word format (=.docx=):
18
191. Open OneNote desktop.
202. Select =File= and then =Export=.
213. Select the scope of content to export, such as =Tab= or =Page=.
224. Name and save the file in an easy to remember location. I recommend your
23 Downloads or Desktop folder.
24
25* Download Pandoc
26
27Start 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 =
29pandoc-3.1.12.3-windows-x86_64.zip= file, which contains a simple =.exe= file
30that you do not need to install - you will simply run it from the command line
31below.
32
33Once downloaded, unzip the archive and move the =pandoc.exe= file to the same
34folder where your Word documents were saved above. If you prefer, you can move
35this file to an easier location, such as =C:\Users\youruser\Downloads=.
36
37* Convert Word to Markdown
38
39In this example, I will be converting the Word documents to Markdown, but Pandoc
40supports [[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
41and then modify the following commands as needed.
42
43To perform the conversion, open the Command Prompt. If you can't find it, open
44the start menu and search for it.
45
46Within the command prompt, navigate to the directory where you stored the
47=pandoc.exe= file and the Word documents.
48
49#+begin_src cli
50cd "C:\Users\yourusername\Downloads"
51#+end_src
52
53You can verify that you're in the correct directory with the =dir= command.
54
55#+begin_src cli
56dir
57#+end_src
58
59Once you have verified that you have the command prompt open in the correct
60directory with the =pandoc.exe= and the Word documents, you can run the
61following loop to convert all Word documents to Markdown.
62
63#+begin_src cli
64for %f in (*.docx) do (pandoc.exe --extract-media=. --wrap=preserve "%f" "%f.md")
65#+end_src
66
67This loop will perform the following actions:
68
691. Find all documents matching the pattern =*.docx=, which means all Word
70 documents ending with that file extension.
712. Iterate through all files found in step 1.
723. For each file, perform the pandoc command.
734. 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.
765. Within the pandoc command, =--wrap=preserve= will attempt to prseerve the
77 wrapping from the source document.
786. 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;; defaults to http://localhost:8000 8;; defaults to http://localhost:8000
9;; ENV=prod emacs --script publish.el 9;; ENV=prod emacs --script publish.el
10(if (string= (getenv "ENV") "prod") 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(weblorg-site 13(weblorg-site
14 :theme nil 14 :theme nil
15 :template-vars '(("site_name" . "cleberg.net") 15 :template-vars '(("site_name" . "cleberg.net")
16 ("site_owner" . "hello@cleberg.net") 16 ("site_owner" . "Christian Cleberg <hello@cleberg.net>")
17 ("site_description" . "Just a blip of ones and zeroes."))) 17 ("site_description" . "Just a blip of ones and zeroes.")))
18 18
19;; route for rendering the index page of the website 19;; route for rendering the index page of the website