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, enabled?, #format, #get, #initialize, is_key_value?, #locale_path, #sentences, #set, supports_variable_interpolation?, #to_s, #type, #variable_regex
Constructor Details
This class inherits a constructor from Translatomatic::ResourceFile::Base
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 |
# File 'lib/translatomatic/resource_file/markdown.rb', line 14 def save(target = path, = {}) if @doc 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) end end |