How make a better markdown for developer blog
I'm rebuilding my blog at http://www.elmalabarista.com/blog/. I have use in my previous version markdown and now I remember why I have almost zero code samples. Doing code samples in markdown is very fragile.
I try to put some python there I can't make markdown mark it as code!. The main culprit? The syntax is markdown for code is out spaces. Despite the fact I use wmd as the edito开发者_如何学JAVAr (how that work here in SO is a mistery for me), it never be able to move rigth the text so never get as code. this is the problem:
I put something simple:
:::python
def hello():
pass
But the problem is that something I have:
:::python def hello(): pass
or
:::python def hello(): pass
(yes bot was formatted but you see? not work). Any mistake -using tabs, too much, too litle spaces) is punished heavily. And if the code is long, the chance of a problem increase too.
So, exist any way to simply do:
### My article
- My list entry one
- My list entry two
:::python def x (a, b): return a * b
and get converted rigth and never bother about this small thing again???
By the way, I'm using pygments & python markdown.
Consider using reStructuredText -- it's the standard lightweight markup for Python, and is often used for docstrings and embedded documentation. It's quite easy, but also powerful -- if I remember correctly, the core Python libraries and Django both use it.
I've been using google-code-prettify, which works pretty well.
Usage:
Put code snippets in <pre class="prettyprint">...</pre> or <code class="prettyprint">...</code> and it will automatically be pretty printed.
You need to indent code more than 4 spaces (btw have you noticed on SO if you add 4 spaces it gets recognized as code), this is 4 space indented:
:::python
def hello():
pass
精彩评论