Is it possible to extend Redcarpet to auto embed youtube videos from a link?

Is it possible to use the Redcarpet Markdown library to automatically embed youtube videos from youtube share links? If so anyone got any ideas on how to go about it? (I'm using Ruby/Rails 3.2)


Sure it is, you can override the method .to_html, but you probably dont need to even extend it you could instead do something like this;

# my regex is a little rusty
@html =
@html = @html.gsub(/\[youtube\s+(.*?)\]/, "....actual html you want in here with youtube id \\1 ")

That would replace any instace of [youtube YOUTUBE_ID] with your custom html.

Need Your Help

Concatenating bytes to strings

c++ arduino

I want to save two strings to the EEPROM, separating each one with a 255 (or 0) char so later I can read them knowing when each string ends.

Does Mongodb have a special value that's ignored in queries?

mongodb pymongo

My web application runs on MongoDB, using python and pyMongo. I get this scenario a lot - code that reads something like: