Module: YARD::Redcarpet::Ext
- Defined in:
- lib/yard/redcarpet/ext.rb,
lib/yard/redcarpet/ext/version.rb
Constant Summary collapse
- CONFIG_FILE =
'.yard_redcarpet_ext'.freeze
- ENV_VAR =
'YARD_REDCARPET_EXTS'.freeze
- DEFAULT_REDCARPET_EXTS =
%w[ no_intraemphasis gh_blockcode fenced_code autolink ].freeze
- VERSION =
"0.0.2".freeze
Class Method Summary collapse
Class Method Details
.exts_from_config ⇒ Object
18 19 20 21 |
# File 'lib/yard/redcarpet/ext.rb', line 18 def self.exts_from_config return [] unless File.readable?(CONFIG_FILE) IO.read(CONFIG_FILE).split(/(?:\s*,\s*)|\n/).select { |ext| !ext.empty? } end |
.exts_from_env ⇒ Object
23 24 25 26 27 |
# File 'lib/yard/redcarpet/ext.rb', line 23 def self.exts_from_env val = ENV[ENV_VAR] return [] unless val val.split(/\s*,\s*/).select { |ext| !ext.empty? } end |
.install ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/yard/redcarpet/ext.rb', line 39 def self.install YARD::Templates::Helpers::HtmlHelper.module_eval do alias :html_markup_markdown_noredcarpet :html_markup_markdown # Converts Markdown to HTML # @param [String] text input Markdown text # @return [String] output HTML # @since 0.6.0 def html_markup_markdown(text) provider = markup_class(:markdown) if provider.to_s == 'RedcarpetCompat' redcarpet_exts = YARD::Redcarpet::Ext.redcarpet_exts provider.new(text, *redcarpet_exts).to_html else html_markup_markdown_noredcarpet(text) end end end end |
.redcarpet_exts ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/yard/redcarpet/ext.rb', line 29 def self.redcarpet_exts @redcarpet_exts ||= begin exts = [] exts += DEFAULT_REDCARPET_EXTS exts += exts_from_config exts += exts_from_env exts.uniq.map { |ext| ext.to_sym } end end |