-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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:
======================================================================
puts ‘Hi!’<br /> puts 3======================================================================
RedCloth obviously converted the quotes into ‘ and ’.
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJO23VwAAoJELh1XLHFkqhaG00H/3ZkZbOKxvrKvW8RWYpQ40II
cOggobWNYUlhMDPGrfPCEuhFeIaebk1iwawzD4HxLpooj8s2rmA1GZS3WV15nPpq
Tg0whGgiBF0GJZGGDZeoZ1yhPIZ7XzZUcZwXh4eWuhi2TIGX5E9Dz6UzJ20jtG2b
SVw861vAzPRZqExsut2rldbidjfAQGXdR8mB7I4MxOeWF5cr+65/KiIViqD4rWtu
S53Ja34rnS2Osibt0HYG6VCWDa9uXecMy3zGka//4p82kc9nPZqESfqXEAntaHe3
dGEZf2Mjp7LxQZVOt2mSnD+KRQASoBm8o+fWQwCQUuVw62Hq9Q67EzWIdlxKRX8=
=uSic
-----END PGP SIGNATURE-----