RedCloth: Adding custom verbatim tag

-----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 &#8216;Hi!&#8217;<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-----

Post this up on RecCloth’s issues board:

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06.12.2011 16:36, Intransition wrote:

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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJO3j2VAAoJELh1XLHFkqhaC8sH/Rtc0pqcqkDcaGbtZbTWLTGy
Gso66S/IgbT4gd+3LC1b+TBnHEdJBBmfgxaulQGckQj+ZuR25hZRpd1VXp1FUzD1
lrHF7CEL9vP7ZwVguwEQWvn4U2fKOUZ9LD6EHmrYs7YSdjYH7yYKy3W5Gqpzc3UU
bCQ0QgcTQtustvsilHfz81BAwPebj0UMTPVoQNu/b/lpu7oROUDioaW/JRkl760G
MXrs5LtfvxGPS8k2Vj1oxqbMFGj+xXP0rTiY/mV66VYa8U9mkEi7JsFDBlR5xuPz
HLsSBfXL3Qo443xContMrufJSxPOH5KOnfNuFMlIZPv5xmjwaUbejP9VyN4CYTQ=
=z+HJ
-----END PGP SIGNATURE-----

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs