1. dimag0g

    21.04.2009

    0 ↑
    0 ↓
    Hi, I'm using pandoc to convert Markdown to HTML. The issue is that it generates <pre class="cpp"><code> instead of <pre><code class="cpp">

    Changing

    w.innerHTML='<pre><code class="'+t+'">'+x+"</code></pre>";

    to

    w.innerHTML='<pre class="'+t+'"><code>'+x+"</code></pre>";

    in highlight.pack.js doesn't seem to help. Any suggestions?
  2. Иван Сагалаев

    21.04.2009

    0 ↑
    0 ↓

    It's hard to suggest anything simple short of hacking either pandoc or highlight.js because there's no standard semantics for this thing (though to me setting class on <code> seems more natural).

    In highlight.js there's a function blockLanguage that searches for known class names in a <code> class attribute. It can be somewhat easily generalized to look also into block.parentNode (which is the relevant <pre>). I'll think of doing it for the next version...

    Oh... As far as I know Markdown itself doesn't let you specify a code language. Is this some extension you're using?

  3. dimag0g

    21.04.2009

    0 ↑
    0 ↓
    > I'll think of doing it for the next version
    Well, thanks a lot then! The heuristics work fine for me most of the time, and when the new highlight.js comes out my life will be even better ;)

    > Is this some extension you're using?
    Yes, pandoc has an extended syntax compared to original Markdown. It is also supposed to do syntax highlighting all by itself, but I never managed to have this working. A CSS-based highlighter of yours is better anyway =)
  4. anonymous

    05.05.2009

    0 ↑
    0 ↓
    because there's no standard semantics for this thing (though to me setting class on <code> seems more natural)
    HTML 5 draft suggests adding a class prefixed with "language-" to the code element:
    http://dev.w3.org/html5/spec/Overview.html#the-code-element
  5. Иван Сагалаев

    05.05.2009

    0 ↑
    0 ↓

    Huh! It's great that there's at least a draft about it. I think I'll support this too along with current behaviour for backward compatibility.

Внимание! Это довольно старый топик, посты в него не попадут в новые, и их никто не увидит. Пишите пост, если хотите просто дополнить топик, а чтобы задать новый вопрос — начните новый.