Markdown in Notepad++

I recently (recently as in about an hour ago) discovered a way to use Notepad++, my text editor of choice on Windows, to process Markdown files into html without having to jump into DOS and run do it from the command line. I’ve been trying to keep my notes in Markdown for awhile now because I like that I can easily publish them to a blog or webpage without fighting with the markup. I also like the small bit of discipline it gives to my text files and the opportunity to tinker around with scripting in the process. Since I don’t really blog that much or publish any html documents to speak of, it’s more of an affectation than a truely useful exercise. That said, I still find myself writing in Markdown with a lingering feeling that the future is all in a browser.

I also enjoy Notepad++ and, like the web, it feels more powerful and full featured that I currently use. So it keeps my attention. I also like the tabs and persistant workspace it provides while the syntax highlighting and numbered lines make some of the things I do at work (writing AutoCAD, Autolisp and AutoHotKey scripts specifically) much, much easier. I won’t go into all the details, but if you do any scripting and you are doing it in plain Notepad you really need to take a long look at what you are missing.

So, to the point! What you need to do to get this to work on your Windows machine, and I’m going to gloss over a lot of the dirty work here, is the following:

  1. Install Notepad++

  2. Install Perl – I don’t remember why, but I installed Straberry Perl and it seems to work just great.

  3. You could install thomsmits’ Markdown syntax highlighting module for Notepad++ if you want, but you don’t have to. (I’ve only been using it for a few days and I’m not sure it’s as solid as I would like, but it’s something!)

  4. Make sure you have the NppExec plugin installed in Notepad++. I think it’s a default, so not to worry.

  5. Go into Plugins > NppExec > Execute… or just hit F6 and type the following into the script box making sure to put the correct path to wherever your Markdown.pl script lives:

    perl "C:\Markdown_1.0.1\Markdown.pl" "$(FULL_CURRENT_PATH)"
    CON_SAVETO $(CURRENT_DIRECTORY)\$(NAME_PART).html
    
  6. Save and name the script in the NppExec dialog and you are good to go.

  7. To run your script, open a file using Markdown syntax and hit F6 and choose your script (if it doesn’t come up by default) and select OK. Your new file will be saved in the same directory with the same name and the .html file extension.

I really like this and it seems to be working really well. You may have to toggle “No internal messages” in the NppExec menu if you are getting messages in your html file, but I have tested it and even wrote this blog post using this method!

UPDATE 2010.02.19: Fixed the save to code.


About this entry

You’re currently reading “Markdown in Notepad++,” an entry on stimmelopolis blog.

Published:
02.16.10 / 8pm
Category:
web

« Relaxing on a Sunday morning
Home »

15 Comments

Jump to comment form | comments rss [?] | trackback uri [?]
  • Jdew

    Oh, I should have mentioned that I also added a line at the end to automatically open the html file in the default web browser.

  • ericstimmel.com Eric Stimmel

    Jdew – That’s great! Please post it in the comments – I’m always interested in seeing how different people adapt thing like this.

  • Jdew

    Hi … I had tried posting my code but disqus didn’t like it … I’ve posted it as a comment on my blot: www.greyfence.com/jrmbl/2010/keeping-notes/

  • ericstimmel.com Eric Stimmel

    hey – thanks! it’s great to read your explanation / working method. I’m going to try out the explorer plugin. I haven’t really tried very many of the plugins.Not sure about the disqus issue. I just applied an update (5 minutes ago)… maybe that fixed it. I’ll try posting your code below and if it shows up – well, it’s fixed. spacer nnecho necho $(NAMEPART) necho nechonperl u201cC:Markdown1.0.1Markdown.plu201d n u201d$(FULLCURRENTPATH)u201d nechonCONSAVETO n u201d$(CURRENTDIRECTORY)$(NAMEPART).htmxu201d ncls nperl u201cC:SmartyPants1.5.1SmartyPants.plu201d n u201d$(CURRENTDIRECTORY)$(NAMEPART).htmxu201d nCONSAVETO u201c$(CURRENTDIRECTORY)$(NAMEPART).htmlu201d ncmd /c del u201c$(CURRENTDIRECTORY)$(NAMEPART).htmxu201d ncmd /c start u201cu201d u201c$(CURRENTDIRECTORY)$(NAME_PART).htmlu201dn

  • ericstimmel.com Eric Stimmel

    looks like you just have to surround your code with the html code tag (which itself can’t be inserted here). You can see the disqus faq on it here if you are interested… apparently displaying html in comments is coming soon…nndocs.disqus.com/help/19/

  • www.google.com/profiles/josephdietrich Joseph Dietrich

    This was a great tip, and helped me a lot. However, I tried this out with the Unicode version of Notepad++, and had all kinds of problems with the output file until I figured out that CON_SAVETO saves files as UCS-2 Big Endian. These open fine in Notepad++, but other apps were having problems with them (as well as the SmartyPants perl script). I ended up doing this:cmd /c perl “C:ScriptsMarkdown.pl” “$(FULL_CURRENT_PATH)” >> “$(CURRENT_DIRECTORY)$(NAME_PART).htm”ncmd /c perl “C:ScriptsSmartyPants.pl” “$(CURRENT_DIRECTORY)$(NAME_PART).htm” > “$(CURRENT_DIRECTORY)$(NAME_PART).html”ncmd /c del “$(CURRENT_DIRECTORY)$(NAME_PART).htm”ncmd /c start “” notepad++.exe “$(CURRENT_DIRECTORY)$(NAME_PART).html”Which fixed the encoding problem. I imagine you could also echo the HTML elements and append them to the file as well, although you have remember to escape < and > symbols with a carat, like ^<.

  • ericstimmel.com Eric Stimmel

    Hi Joseph – Thanks for for sharing that! I had attempted to append some boilerplate info into each file as it was created and encountered similar problems with the encoding and could never figure out a suitable solution. I searched far and wide for a way to change the console default encoding – maybe I just needed some lateral thinking… I’ll have to revisit this and try again.

  • www.google.com/profiles/josephdietrich Joseph Dietrich

    You’re welcome. I can’t claim too much original thinking myself — I just happened to notice it that it was an encoding issue and then did some Google-fu which led me to this topic in the Notepad++ Plugins forum. I then adapted the solution mentioned there by NppExec’s author. Cheers!

  • Anonymous

    You seem pretty happy with straight Markdown, but you may find pandoc interesting as well (johnmacfarlane.net/pandoc/), which extends the markdown syntax with some extra features such as tables (like Markdown Extra, but even a bit more functional). I’ve also written an AutoHotkey script to integrate it into the Run menu of Notepad++, called clip-pandoc. It’s available at www.binaryphile.com/clip-pandoc.aspx.

  • ericstimmel.com Eric Stimmel

    Hi lilleyt – Thanks for pointing me to pandoc, it looks pretty amazing and I’m planning to try it out a little. I’ve installed it along with your clip-pandoc application, but it doesn’t seem to be working. I’ll keep trying, but I’m getting the result you mention if there are non printing characters however i’ve run the TextFX utility and still nothing. In fact going the other way, HTML to Markdown, does the same thing. I’m running it on a 64 bit machine – perhaps that’s the problem?

  • Anonymous

    Hi Eric,rnrnI’m finding pandoc to be extremely useful as a way of composingrnHTML-friendly content more every day. It even does things like insertrnjavascript to obfuscate mailto links so they can be used by users but notrnscraped by bots. Lots of little things like that.rnrnFirst, I’d consult the pandoc docs and run pandoc a few times from therncommand line to make sure it’s working.rnrnSecond, make sure pandoc is on the command path. It needs to be in order tornbe invoked from clip-pandoc.rnrnAlso verify that you can pipe some text to clip.exe and have it show up inrnthe clipboard (paste it somewhere). clip.exe is installed in the programrnfile directory with clip-pandoc, so if that is on the path as well, yournshould be able to invoke it directly.rnrnTry those and let me know how it goes. You’re the first to test on a 64-bitrnsystem, so that’s likely the culprit.rnrnTed

  • Shuusaku

    Hi. Thanks for the post. nEverything works as you described, but it seems the procedure cannot handle files with UTF-8 encodingn(the initial part of the file becomes “u2229u2557u2510″ in the html output).nAny idea on how to solve this problem? nThanksn

  • ericstimmel.com Eric Stimmel

    Itu2019s a problem with saving from the console. I think if you read through the other comments there are some suggestions that might address this. Iu2019ll try to follow up this post with a better solution sometime, but itu2019s on the back burner for now u2013 let us all know Iu2019d you have any suggestions and thanks for the feedback!

  • Strand B

    NppExec is not installed in Notepad++ by default, but can be installed with the following:nnPlugins > Plugin Manager > under the Available tab check “NppExec,” then click Install. Restart Notepad++ when prompted.nnOf course, Markdown.pl is available from Daring Fireball.nnToggling “No internal messages” can be done under the Plugins > NppExec menu.nnThanks for the walkthrough. This make my work in Windows significantly more enjoyable.

  • Pingback: Hypergogue – Markdown, Workflow and the Machines


Archives

Pages

  • about me
  • links to my work

Support


  • spacer Better yet, buy something for me!


gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.