Class: Decidim::Proposals::OdtToMarkdown

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/proposals/odt_to_markdown.rb

Overview

This class parses a participatory text document in markdown and produces Proposals in the form of sections and articles.

This implementation uses Redcarpet Base renderer. Redcarpet::Render::Base performs a callback for every block it finds, what MarkdownToProposals does is to implement callbacks for the blocks which it is interested in performing some actions.

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ OdtToMarkdown

Public: Initializes the serializer with a proposal.



17
18
19
# File 'lib/decidim/proposals/odt_to_markdown.rb', line 17

def initialize(doc)
  @doc = doc
end

Instance Method Details

#to_mdObject



21
22
23
24
25
# File 'lib/decidim/proposals/odt_to_markdown.rb', line 21

def to_md
  doc_file = doc_to_tmp_file
  md_file = transform_to_md_file(doc_file)
  md_file.read
end