Markdown Note - The best Note app around

2021-04-28

That title is obviously click bait. However, it is also true, at least for me, as I wrote Markdown Note (MDN) because I was not satisfied with any existing solution. It allows you to write notes in Markdown, with any editor you prefer, and display them in the Browser. It also has some bibliographic features.

Since you clicked on this link, I assume I don't need to convince you to use a note app, but I want to convince you to use MDN. The reasons you should use it, are the same reasons that made me write it. So let me take you on a tour through different ways to manage notes, and their respective flaws.

When I first started working scientifically, I used one big latex file to store my notes. It turned out that that wasn't my best idea. The source file became quite chaotic over time, sometimes I would have troubles compiling it, and a single PDF for all notes also isn't the best format.

I then went on to use OneNote. OneNote has some nice features, but it also has some flaws. First and foremost: availability in Linux. Sure, by now there is a browser version, but I really don't like web-apps, they either don't have nice hotkeys, or they do have them, and then those will collide with the hotkeys of my browser plugins. Additionally, and that was the biggest pain point for me: its not Vim. Text editing with Vim is, by now, deeply rooted in my muscle memory, and not having it available when writing text causes physical pain and distress (I might be overexagerating slightly here … SLIGHTLY).

I then went on to use Evernote in combination with Marxico. I really liked writing notes in Markdown, and Evernote brought some Vim emulation to the table. It wasn't sufficient though. Also by then, another problem arose. My Boss didn't like the idea of my research related notes lying around in a cloud. And actually I agree with that. Also, call it old fashioned, but I really don't like the idea of having to rely on a network connection, when there shouldn't be a need to.

I then had a short org-mode phase, but I didn't like that I had to manage the multiple files by hand and I never really warmed up with Emacs. This was the point where I started thinking about writing my own app. It should have the following features:

  • local files
  • edit in markdown
  • I want to use Vim
  • I still want images and synchronisation though

The sync part would be done by Dropbox, so I didn't have to do anything here. So far, so simple. Create a new note:

mdn new

you can now view it in a browser via

mdn show title

but most of the time I'd end up just reading the notes in the terminal with vim via

mdn edit title

you can see your notes via

 mdn ls pattern

The pattern will be treated the following way: add a wildcard between every letter, and then match all the titles. This is an extremely simple and surprisingly powerful way to find things quickly.

Additionally notes can have groups. Originally, I intended them to be like notebooks, but because I'm lazy I implemented them as simple string matches. I now have e.g. a group "Papers - RS" and "Papers - NF" and I can add one of those groups specifically to the query like:

 mdn ls -g "Papers - RS" pattern

but I can also just go for

 mdn ls -gpapers

and it will give me all titles from all groups that contain the word "paper". Additionally, there is also a tag mechanism: you can prefix any word in a note with an @ and that prefixed word will be interpreted as a tag. You can then search for tags, and also combine them via logical formulas. e.g.

mdn ls -t "@foo & -@bar"

would give you all notes that contain @foo but only if they dont also contain @bar. I never really used this feature though, and it's mainly in there because I wanted to write the parser for the tag formulas :D Also, you can search through the contents of notes with mdn fd pattern btw.

I used the tool for a year, and new features emerged. Want to share some notes, e.g. one group of notes with someone else?

mdn cat -gPapers -n | pandoc --from markdown -o papers.pdf --pdf-engine=xelatex --toc

There you go. The -n removes the yaml front matter, which would confuse pandoc. Alternatively, you can also pass a list of note ids to cat.

When writing something for which I need my notes, I would create one PDF with all the notes I needed, and scroll around in it a lot. That was a little annoying, so I created the serve command

mdn serve

will start a webserver which you can use read all notes easily:

For the longest time, I had used Zotero to manage my bibliography. While writing a paper, I would find myself adding papers to the bib file constantly, and always recreating a bib file from Zotero. This was pretty annoying. I then switched to Jabref. I would copy the doi from my notes, and add it in Jabref, still a little annoying. Then I added bib capabilities to MDN. You can create a new note via:

mdn new -d 10.1016/j.neuroimage.2020.116634

and it will create a file containing:

---
title: Knorr et al. 2020
doi: 10.1016/j.neuroimage.2020.116634
group: None
---
# A comparison of {fMRI} and behavioral models for predicting inter-temporal choices
<https://doi.org/10.1016%2Fj.neuroimage.2020.116634>

and if you have a doi defined in the front matter of a note, you can run

mdn tobib id

and it will append a bibtex entry for the doi to the first .bib file in the current directory.

Last but not least, add this to your .vimrc (if you use vim) to copy images from the clipboard into your note (requires xclip, and ofcourse you'll have to adjust the paths to match your configuration):

function! InsertImgFromCB(name)
    execute "!xclip -sel clip -t image/png -o > " . 
                    \ "/home/felix/Dropbox/mdn.d/assets/" . a:name 
    execute "norm a![](" . a:name . ")"
endf
command! -nargs=1 PasteImage call InsertImgFromCB(<f-args>)

nnoremap <localleader>ppi :PasteImage paper_imgs/
nnoremap <localleader>pi :PasteImage

" requires Vim surround
" Make a marked text into a link with a link from the clipboard
vmap <localleader>k S]%a(<esc>"*pa)<esc>

Thats all I've got so far. I hope you agree with the title now :D

You can install MDN if you have python 3.8 and git via:

pip install git+https://github.com/KnorrFG/markdown_note.git

If you like it, leave me a star at github