middleman / middleman-syntax

Code syntax highlighting plugin via Rouge for Middleman
https://middlemanapp.com
MIT License
179 stars 57 forks source link

In Kramdown, fenced code blocks no longer accept inline attribute lists #61

Closed dannguyen closed 8 years ago

dannguyen commented 8 years ago

In Kramdown, Inline Attribute Lists allow for this:

  ~~~ruby
  puts("hello world")
  ~~~
  {: data-title="Some ruby"}

Which results in the code block adopting those attributes. Here's the result using the standard syntax highlighter option and setting it to CodeRay, and not activating middleman-syntax:

  <div data-title="Some ruby" class="highlighter-coderay"><div class="CodeRay">
    <div class="code"><pre>puts(...)
  </pre></div>
  </div>
  </div>

Currently using Middleman 4.0...don't know if that would make any difference

bhollis commented 8 years ago

Did this ever work for you with middleman-syntax? That is, is this a regression? I don't see how we could support this given that Rouge doesn't allow specifying extra attributes for their pre tag. See https://github.com/jneen/rouge/blob/master/lib/rouge/formatters/html.rb#L48 for the relevant code.

FWIW, as maintainer of Maruku (which Kramdown inherited the inline attribute syntax from), I feel that once you start resorting to inline attributes you really want something closer to HTML, not Markdown. Markdown is meant for simple, readable-as-text formatting.

dannguyen commented 8 years ago

That's a good point. I honestly don't know. My intention was to use data attributes to specify line-by-line highlighting, as it's possible in Sphinx and as postulated here: http://zpao.com/posts/adding-line-highlights-to-markdown-code-fences/

That way, i could write a javascript helper to do the client-side highlighting, as it's out of the scope of middleman-syntax (and Rouge). I wasn't aware of the internals of how Rouge worked but it makes sense that it wouldn't necessarily inherit from Kramdown's superset. Thanks for the reply!