Alex Rivera | Logout

How do I set an HTML class attribute in Markdown?

Asked 2009-06-10T12:26:27.553
57

If I have some Markdown like

## My Title

A paragraph of content here.

    code_line(1);
    // a code comment
    class MoreCode { }

and more text to follow...

How can I set a class on the <code> block that's generated in the middle there? I want to have it output

<code class=’prettyprint’>
  code_line(1);
  // a code comment
  class More Code { }
</code>

But I can't seem to set it. I do not have control over the Markdown code being run, only over the content.

Edit
Report

1 Answer

26

Though not answering the question exactly. You can use a different render too like Maruku or Kramdown:

## My Title

A paragraph of content here.
~~~
code_line(1);
// a code comment
class MoreCode { }
~~~
{: .prettyprint}

and more text to follow...

Output (tested with haml & kramdown):

<pre class="prettyprint"><code>
code_line(1);
// a code comment
class MoreCode { }
</code></pre>

Kramdown syntax: http://kramdown.rubyforge.org/quickref.html#block-attributes

answered 2012-10-24T04:07:16.083

Your Answer