Handling more than one markup language in a text area

爷,独闯天下 提交于 2019-12-11 10:39:45

问题


I'd like to now how to handle multiple markup languages (textile, markdown and bbcode) in a text area using ruby on rails 3.

The user would be able to select the markup language he/she wants to use, write in that language, and then the view would render the text using the markup language selected by the user.

I'm currently handling that storing a field for each text area, but I'm sure there are better ways and I'd love to hear your opinions and come up with a better way.


回答1:


When are you processing the markup the user enters? Are they ever going to need to re-retrieve it?

I'd do this by having three attributes on my model: original_text, markup_language (which is either textile, markdown, or bbcode), and rendered_text. When the user hit save, I'd save the text and use the value they provided for markup_language to figure out what renderer to use to store it into rendered_text.



来源:https://stackoverflow.com/questions/4620690/handling-more-than-one-markup-language-in-a-text-area

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!