Reputation: 3083
Description -as\r\n [code]a = b+ 4\r\nc= a +j\r\n\r\n[/code]\r\nagain text\r\n[code]a = c + 4\r\n[/code]"
output i need is to pass the text enclosed in [code] to coderay for formatting. or you can say as similar to stackoverflow where we can see code part and text part separated . i am following Separate Code blocks form text which is working if code block is with in one line.
Upvotes: 0
Views: 108
Reputation: 89557
You can use this to avoid the newline problem:
str.gsub(/\[code\]((?>[^\[]++|\[(?!\/code]))*+)\[\/code\]/) do |match, replace|
...
The content enclosed between [code]
tags is in the first capturing group.
Upvotes: 1