Class: Translatomatic::ResourceFile::Markdown
- Defined in:
- lib/translatomatic/resource_file/markdown.rb
Overview
Markdown resource file
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.extensions ⇒ Array<String>
File extensions supported by this resource file.
Instance Method Summary collapse
-
#save(target = path, options = {}) ⇒ void
Save the resource file.
Methods inherited from HTML
Methods inherited from XML
Methods inherited from Base
#create_variable, #format, #get, #initialize, #locale_path, #sentences, #set, #supports_variable_interpolation?, #to_s, #valid?, #variable_regex
Constructor Details
This class inherits a constructor from Translatomatic::ResourceFile::XML
Class Method Details
.extensions ⇒ Array<String>
Returns File extensions supported by this resource file.
9 10 11 |
# File 'lib/translatomatic/resource_file/markdown.rb', line 9 def self.extensions %w{md} end |
Instance Method Details
#save(target = path, options = {}) ⇒ void
This method returns an undefined value.
Save the resource file.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/translatomatic/resource_file/markdown.rb', line 14 def save(target = path, = {}) if @doc begin add_created_by unless [:no_created_by] html = @doc.to_html # convert html back to markdown markdown = ReverseMarkdown.convert(html, unknown_tags: :bypass) target.write(markdown.chomp) rescue Exception => e log.error t("resource.error", message: e.) end end end |