Skip to content

Instantly share code, notes, and snippets.

@foxweb
Created September 1, 2010 12:52
Show Gist options
  • Save foxweb/560633 to your computer and use it in GitHub Desktop.
Save foxweb/560633 to your computer and use it in GitHub Desktop.
if defined?(Object::RedCloth) and (!RedCloth.instance_methods.include?(:stock_pgl))
# RuTils выполняет перегрузку Textile Glyphs в RedCloth, перенося форматирование спецсимволов на Gilenson.
class Object::RedCloth < String #:nodoc:
# Этот метод в RedCloth при наличии Гиленсона надо отключать
alias_method :stock_htmlesc, :htmlesc
def htmlesc(text, mode=0) #:nodoc:
RuTils::overrides_enabled? ? text : stock_htmlesc(text, mode)
end
# А этот метод обрабатывает Textile Glyphs - ту самую типографицу.
# Вместо того чтобы влезать в таблицы мы просто заменим Textile Glyphs - и все будут рады.
alias_method :stock_pgl, :pgl
def pgl(text) #:nodoc:
RuTils::overrides_enabled? ? text.replace(RuTils::Gilenson::Formatter.new(text).to_html) : stock_pgl(text)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment