I''d like to extend bleucloth or redcloth to support custom tags, e.g. I want to use markup like this: [pubmed:18332676] which shall be extended to: <a href="http://www.ncbi.nlm.nih.gov/pubmed/18332676">Behav Pharmacol. 2008 Mar;19(2):121-128.</a> Does anyone know, if this is possible and has some hints how to do this?! I have not decided, wether I want to use redcloth or bluecloth, I''ll take, whatever has the better extensibility.... Cheers&thx for any help Stefan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
andrew.ohnstad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-10 14:19 UTC
Re: Extending Bluecloth/Redcloth
I realize that it might be a pain to incorporate _another_ mark up language, but your syntax is very much like BBCode, and there is a rails plugin for BBCode that allows easy customization of what tags/ replacements should be made to your text. http://agilewebdevelopment.com/plugins/bbcodeizer Quick and easy, if you don''t mind calling another function when you render. If you want it saved directly into the db as the link, then you could make a simple before_save callback that regexed the tag into html... though I don''t know how you would get the study/publisher information to include in the tag from just the ID. Good luck! On Apr 10, 9:39 am, Stefan Frank <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''d like to extend bleucloth or redcloth to support custom tags, e.g. I > want to use markup like this: > > [pubmed:18332676] > > which shall be extended to: > <a href="http://www.ncbi.nlm.nih.gov/pubmed/18332676">Behav Pharmacol. > 2008 Mar;19(2):121-128.</a> > > Does anyone know, if this is possible and has some hints how to do > this?! I have not decided, wether I want to use redcloth or bluecloth, > I''ll take, whatever has the better extensibility.... > > Cheers&thx for any help > Stefan > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This looks _almost_ like the thing I wanted: Unfortunately, the replacement is a little more complex than what bbcodeize offers: Instead of replacing the tag with a strin, I need to call a function, which queries pubmed with the given id and fetches study/publisher info. Preferably, I wanted to do this at render-time: If I place it in a before_save, I either: (a) have another field for the processed markup (b) or find a way to undo the replacement for editing. as (b) looks really ugly, I guess I will try a simple regex for extracting the [pubmed:...]-tag - and store the results of the processing in another field... thx for the help! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
andrew.ohnstad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-10 15:21 UTC
Re: Extending Bluecloth/Redcloth
I''m having fun with this one... I''m actually working on something similar for my site. This might be overly complicated, but... Assuming there is a table somewhere which links IDs to study/publisher info... Let''s say these BBCode style tags are used in "study_reviews" and that there is a "study_review.body" field in the DB that has [pubmed] tags in it... First customize BBCodeizer to regex [pubmed:.*] in to <%= link_to @pubmed.author + ". " + @pubmed.date, "www.foo.bar/" + @pubmed.id %> The goal here is to get BBCodeizer to export the ERB, not do the replacemets. In your study_review controller have the application flow go something like this... Do a regex on the study_review.body for [pubmed:(.*)] If found, regex out the ID from the tag @pubmed=Pubmed.find(regex_resutl) So when the bbcodeizer function is run during the view, it will convert to ERB, which could then be processed again by rails? Now that I am typing this out, I am doubting myself that the ERB will ever get executed after coming out of the bbcodizer. But give it a try... On Apr 10, 10:33 am, Stefan Frank <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> This looks _almost_ like the thing I wanted: Unfortunately, the > replacement is a little more complex than what bbcodeize offers: Instead > of replacing the tag with a strin, I need to call a function, which > queries pubmed with the given id and fetches study/publisher info. > Preferably, I wanted to do this at render-time: If I place it in a > before_save, I either: > (a) have another field for the processed markup > (b) or find a way to undo the replacement for editing. > > as (b) looks really ugly, I guess I will try a simple regex for > extracting the [pubmed:...]-tag - and store the results of the > processing in another field... > > thx for the help! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Stephan, I''d like to extend bleucloth or redcloth to support custom tags, e.g. I> want to use markup like this: >see: http://nubyonrails.com/articles/about-this-blog-custom-textile Google is your friend. Alain --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> see: > http://nubyonrails.com/articles/about-this-blog-custom-textileThx! Exactly, what I was looking for!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---