Class: Translatomatic::ResourceFile::Markdown
- Defined in:
- lib/translatomatic/resource_file/markdown.rb
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
#format, #get, #initialize, #locale_path, #sentences, #set, #to_s, #valid?
Methods included from Util
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.
8 9 10 |
# File 'lib/translatomatic/resource_file/markdown.rb', line 8 def self.extensions %w{md} end |
Instance Method Details
#save(target = path, options = {}) ⇒ void
This method returns an undefined value.
Save the resource file.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/translatomatic/resource_file/markdown.rb', line 13 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 puts "error: #{e.message}" end end end |