This gem provides a simple, centralized interface for translation of markup from one format to another. It comes with a bunch of processors, and handles requirement of optional dependencies as configured needed.
There are several defaults that can set for the library:
- from
-
Default format from which to translate the source.
Default:
:plain_textPossible Values:
:plain_text,:html - to
-
Default format to which to translate the source.
Default:
:htmlPossible Values:
:plain_text,:html - prefix
-
Default string to prepend to the name of the source field to come up with the name of the target field. This can be used in conjunction with the
:suffixoption, but is disregarded if the:targetoption is used. Usefalseto disable.Default:
falsePossible Values:
"_rendered","_html",false - suffix
-
Default string to append to the name of the source field to come up with the name of the target field. This can be used in conjunction with the
:prefixoption, but is disregarded if the:targetoption is used. Usefalseto disable.Default:
"_rendered"Possible Values:
"_rendered","_html",false
The configuration block can be added to your initialization scripts. For Rails applications, this can be added to an initializer.
Markup.configuration do |config| config.from :plain_text config.to :html end
Markup.translate(text) Markup.translate(text, :from => :markdown, :to => :html)
Support for Rails in available in the markup-rails gem.
Copyright © 2011 Kristina Lim. Licensed under the MIT License. See LICENSE.txt for further details.