views:

23

answers:

2

Im using python markdown for my django project, when i have the value

#/usr/bin/env python
print "this is converted to html code block"

the output is

<pre><code>    
#/usr/bin/env python
print "this is converted to html code block"
</code><pre>

Now my question is that how can i pass class attribute and value to code elem. Sample:

#i should be using some markdown syntax below
[class="python"]
#/usr/bin/env python
print "this is converted to html code block"

and then the output here

<pre><code class="python">    
#/usr/bin/env python
print "this is converted to html code block"
</code><pre>

is that possible? and how?

A: 

You can write HTML in Markdown, but you can't add things like classes and ids.

See this question or this question for more details.

Skilldrick
your right Skilldrick, so i just have to write my code blocks manually - wrap it inside <pre class="python">code here</pre> and dont indent it by 4 spaces else it will be converted to markdown
ronbeltran
That's right. I write my blog in Markdown, so I have to do things like this all the time. It's nice that you can drop down to HTML when you need to (a bit like dropping down to assembler from C).
Skilldrick
A: 

You could pass the resulting HTML through some other filter that finds and parses the #! line and adds the Python class based on it. lxml would be a good way to do it. I'm not sure how you'd go about arranging that with Django though.

intuited