lib/kramdown/converter.rb in kramdown-1.4.2 vs lib/kramdown/converter.rb in kramdown-1.5.0

- old
+ new

@@ -5,10 +5,12 @@ # # This file is part of kramdown which is licensed under the MIT. #++ # +require 'kramdown/utils' + module Kramdown # This module contains all available converters, i.e. classes that take a root Element and convert # it to a specific output format. The result is normally a string. For example, the # Converter::Html module converts an element tree into valid HTML. @@ -22,9 +24,46 @@ autoload :Latex, 'kramdown/converter/latex' autoload :Kramdown, 'kramdown/converter/kramdown' autoload :Toc, 'kramdown/converter/toc' autoload :RemoveHtmlTags, 'kramdown/converter/remove_html_tags' autoload :Pdf, 'kramdown/converter/pdf' + + extend ::Kramdown::Utils::Configurable + + configurable(:syntax_highlighter) + + ["Coderay", "Rouge"].each do |klass_name| + kn_down = klass_name.downcase.intern + add_syntax_highlighter(kn_down) do |converter, text, lang, type, opts| + require "kramdown/converter/syntax_highlighter/#{kn_down}" + klass = ::Kramdown::Utils.deep_const_get("::Kramdown::Converter::SyntaxHighlighter::#{klass_name}") + if klass::AVAILABLE + add_syntax_highlighter(kn_down, klass) + else + add_syntax_highlighter(kn_down) {|*args| nil} + end + syntax_highlighter(kn_down).call(converter, text, lang, type, opts) + end + end + + configurable(:math_engine) + + require 'kramdown/converter/math_engine/mathjax' + add_math_engine(:mathjax, ::Kramdown::Converter::MathEngine::Mathjax) + + ["Ritex", "Itex2MML"].each do |klass_name| + kn_down = klass_name.downcase.intern + add_math_engine(kn_down) do |converter, el, opts| + require "kramdown/converter/math_engine/#{kn_down}" + klass = ::Kramdown::Utils.deep_const_get("::Kramdown::Converter::MathEngine::#{klass_name}") + if klass::AVAILABLE + add_math_engine(kn_down, klass) + else + add_math_engine(kn_down) {|*args| nil} + end + math_engine(kn_down).call(converter, el, opts) + end + end end end