RedCloth: Adding custom verbatim tag

Hi there,

I’m using RedCloth for writing texts, it however doesn’t know anything
about syntax highlighting. So I came up with the idea of combining it
with CodeRay by means of adding a new tag. This is my code so far:

···

======================================================================
require "redcloth"
require "coderay"

module RedCloth::CodeRayHighlighting

  def coderay(opts)
    CodeRay.scan(opts[:text], :ruby).html(line_numbers: :table, wrap:
:div)
  end

end

RedCloth::Formatters::HTML.send(:include, RedCloth::CodeRayHighlighting)

text=<<EOF
Foo bar.

coderay. puts "Hi!"
puts 3

Foo bar.
EOF

puts RedCloth.new(text).to_html

But sadly, it’s doing bad things to the code. Here’s the relevant part
of the generated HTML:

======================================================================
<td class="code"><pre>puts &amp;<span
class="comment">#8216;Hi!&amp;#8217;&lt;br /&gt;</span>
puts <span class="integer">3</span></pre></td>

RedCloth obviously converted the quotes into &#8216; and &#8217;.
CodeRay interpreted the # as the start of a comment and as a result
the syntax highlighting is completely broken.

How to tell RedCloth that my custom tag wants verbatim text rather
than formatted?

Vale,
Marvin

Post this up on RecCloth's issues board:

http://jgarber.lighthouseapp.com/projects/13054-redcloth/overview

I always thought that was only a bug tracker and general questions
should go to the redcloth-upwards ML. This one however is quite quiet
and therefore doesn’t seem the correct place to post something.

Here’s the ticket I created:
http://jgarber.lighthouseapp.com/projects/13054/tickets/240-creating-a-custom-verbatim-tag

Valete,
Marvin

···

On 06.12.2011 16:36, Intransition wrote:

Post this up on RecCloth's issues board:

Lighthouse - Beautifully Simple Issue Tracking