I have a lot of notes in markdown that I would like to import to Onenote.
Onenote does a bit of conversion but breaks when code blocks are added.
Is there a setting where I can tweak how Onenote interprets markdown ?
- 5,009
- 4
- 33
- 49
-
1How are you importing the markdown into onenote? Copy and paste? Or actual importing? In what way are code blocks breaking? – Raystafarian May 13 '14 at 18:38
-
Copy- paste, It shows code blocks as regular text and everything below it is indented one tab space to the right. with multiple code blocks it gets crazy pretty quickly – Shekhar May 17 '14 at 01:59
-
I did an export to Onenote but that exports it as image and its not editable – Shekhar May 17 '14 at 02:00
-
@GonçaloPeres龚燿禄: Why the bounty? Doesn't the answer below work for you and which version of OneNote? – harrymc Mar 05 '21 at 11:14
-
@harrymc I have stated it in the bounty section: "I am looking for a more recent add-in or for [other] alternative[s] to add mark-down code snippets to OneNote." – Gonçalo Peres Mar 05 '21 at 12:45
-
@GonçaloPeres龚燿禄: Yes, understood, but doesn't NoteNighlight work anymore? – harrymc Mar 05 '21 at 14:09
-
@harrymc Still haven't tried. As the thread of answers is already relatively old, I am wondering if there are other alternatives. If there isn't and if NiteNighlight works well, will gladly give the bounty to that answer. – Gonçalo Peres Mar 05 '21 at 20:28
-
Its last updated version is 3.6 from Apr 14, 2019. That's not too old. – harrymc Mar 05 '21 at 20:34
4 Answers
You have to turn on Markdown in the ribbon.xml config (see bottom of link), open a text editor in admin mode to edit the file, and turn the tag to 'true'.
- 306
- 1
- 4
-
1Thank you. Reading the docs always helps, but I wouldn't have stumbled upon this feature (I already had it installed) without your answer. – dgo Oct 16 '19 at 13:51
You might be able to automate something with PanDoc. It can accept MarkDown (among other things) and convert it to many other formats, including some that OneNote might understand, like HTML. It's mostly command-line, so a quick batch file might be in order.
pandoc "%~1" -o "temp.html"
pause
del "temp.html"
With PanDoc and a batch file like that, you can drag and drop a MarkDown file onto the batch file, and a temp.html file will be generated in the source folder. Open it up, copy/paste the results into OneNote.
There are a list of OneNote Command-Line Switches, but they're for OneNote 2007, and I couldn't find a similar document for 2010. /paste and /insertdoc either pasted in raw HTML or nothing at all. Opening the temporary HTML file and copying the rendered results into OneNote works for me, but it's a bit of a hassle.
Another thing about pasting into OneNote is that it has never seemed to respect new lines. I always have to go back through large pasted documents and add the newlines back so that it's not all one giant paragraph. I have yet to find a solution for this.
- 126
- 6
onenotegem
It seems to work as requested
pandoc
It converts files from one markup format into another.
The opposite
Using pandoc you can even do the opposite...
ForEach ($result in Get-ChildItem | select Name, BaseName) { pandoc.exe -f docx -t markdown_strict -i $result.Name -o "$($result.BaseName).md" --wrap=none --atx-headers }
markdown-strictis the type of Markdown. Other variants exist in the Pandoc documentation--wrap=noneensures that text in the new .md files doesn't get wrapped to new lines after 80 characters--atx-headersmakes headers in the new .md files appear as # h1, ## h2 and so on
Or use scripts from github...
- 18,764
- 9
- 52
- 95
-
just saw that onenotegem was created by James Linton. Do you happen to know if it is this [James Linton](https://en.wikipedia.org/wiki/James_Linton_(hacker))? – Gonçalo Peres Mar 09 '21 at 12:18
-
1Not really.... do you refer to [this one](https://twitter.com/SINON_REBORN?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor)? Always if it is not a _fake_ account... `;-)`. – Hastur Mar 09 '21 at 12:52
Do you have the ability to export the MD as HTML? If not, you can use something like Dillinger to do so.
If your code blocks are converted to <pre> or <code> blocks in HTML, you would be able to open the HTML page and copy it into OneNote while keeping the formatting. <pre> and <code> is dropped, however. You can use some simple CSS to style the content of the tags, which I believe will be copied as well.
- 496
- 6
- 15