RDiscount custom generated html

I'm using RDiscount to convert Markdown to html in my application. Actually when I add some code in my markdown it generates code and pre tags but I want to add a class to the code tag how can I do this ? I need to parse generated HTML with Nokogiri or something like this ?


Rdiscount does not seem able to do this on its own. Parsing the result (with Nokogiri or whatever) might do the trick, but could be expensive. If you can, switch to another lib, like Redcarpet for example. This one lookes like it can be extended quite easily to fit your needs

One thing is sure, you can't tell Rdiscount to do it, it has no option for it. I looked at Rdiscount source code and this is what I end up in the file generate.c:

static void
printcode(Line *t, MMIOT *f)
    int blanks;

    Qstring("<pre><code>", f);
    for ( blanks = 0; t ; t = t->next ) {
    if ( S(t->text) > t->dle ) {
        while ( blanks ) {
        Qchar('\n', f);
        code(f, T(t->text), S(t->text));
        Qchar('\n', f);
    else blanks++;
    Qstring("</code></pre>", f);

No option to add any class to code and pre.

If you need to add a class to format the markup, maybe you can try a workaround and generate a div with a class before the

<div class="myclass">

Is it feasible for you?

Need Your Help

SQL Server Indexes - Initial slow performance after creation

sql-server-2005 performance indexing

Using SQL Server 2005. This is something I've noticed while doing some performance analysis.

how pyqt implement signal and slot in qt?

qt pyqt

pyqt is created by SIP, and SIP support signal and slot.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.