Load a *.md file


Hey guys, I have been looking around the web and I have not been able to find a way to open .md files when pressing cmd+o or ctrl + o.

Can someone please provide an example on how to do this?



Is this a question about Atom or Electron?


This is a question about electron.


Electron doesn’t have any way to know what to do with Markdown. It displays HTML and runs JavaScript. You have to interpret the Markdown into HTML and send that to the window, and for that you need a Markdown parser.


I know, but I want to know how to open the actual file so I can pass it to markdown.


Not with the Open dialog. Electron isn’t an editor. You need to have your JavaScript read the file into a variable and then run the conversion function.

I’m a bit concerned about your understanding of how this works. You should probably take a step back and read up on reading/writing files in programming generally and Node specifically. Art of Node is a pretty good resource.


I am aware Electron isn’t a text editor. Thanks for sharing the art of node btw.

What I meant was that I want to know how to use electron to get the text of a .md file. That way I can take the content and parse it with marked and then output it onto the screen.



Electron provides the full set of NodeJS APIs, you can read/write to the file system with Node’s fs module.


In addition to @enlight’s comment, you also might want to check out dialog.showOpenDialog for getting the file path.


Yea, thanks. I found it on a stack overflow post.