19

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 ?

Shekhar
  • 5,139

4 Answers4

3

NoteNighlight!

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'.

AzadA
  • 304
2

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.

2

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.

NDC
  • 126
1

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-strict is the type of Markdown. Other variants exist in the Pandoc documentation
  • --wrap=none ensures that text in the new .md files doesn't get wrapped to new lines after 80 characters
  • --atx-headers makes headers in the new .md files appear as # h1, ## h2 and so on

Or use scripts from github...

Hastur
  • 19,483
  • 9
  • 55
  • 99