Class: Yuzu::Translators::MarkdownTranslator

Inherits:
Translator show all
Defined in:
lib/yuzu/translators/markdown.rb

Instance Method Summary collapse

Methods inherited from Translator

can_translate?, filetypes, identify_filetype, registry, translate, #translates?, translators

Instance Method Details

#extensionsObject



7
8
9
# File 'lib/yuzu/translators/markdown.rb', line 7

def extensions
  %w(.md .mdown .mkd .markdown .markd)
end

#translate(contents) ⇒ Object



11
12
13
14
15
# File 'lib/yuzu/translators/markdown.rb', line 11

def translate(contents)
  rendered = Kramdown::Document.new(contents).to_html
  rendered = rendered.gsub("<p><noscript></p>", "<noscript>").gsub("<p></noscript></p>", "</noscript>")
  rendered.gsub(/\n\s*<\/code>/, "</code>").gsub(/<code>(?!\s)/, "<code>  ")
end