This repository has been archived by the owner on Dec 28, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added follosing formats: rst (reStructuredText), odt (OpenOffice text…
… document).
- Loading branch information
Showing
9 changed files
with
109 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
doc | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
Pandoku | ||
======= | ||
= Pandoku | ||
|
||
Pandoku is loose Ruby interface for Pandoc, the most powerful markup processor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,53 @@ | ||
require 'tempfile' | ||
require File.dirname(File.dirname(__FILE__)) + '/format' | ||
|
||
module Pandoku::Formats | ||
# ODT (OpenOffice text document) format. | ||
class ODT | ||
include OutputFormat | ||
# | ||
# == Available Options | ||
# | ||
# <tt>:toc</tt>:: Include an automatically generated table of contents. | ||
class ODT < Pandoku::Format | ||
include Pandoku::OutputFormat | ||
|
||
def self.name | ||
:odt | ||
end | ||
|
||
def self.default_options | ||
{ :toc => false } | ||
end | ||
|
||
def cliopts | ||
@tmpfile = @tmpfile || self._tmpfile | ||
"--output=#{@tmpfile} #{super.cliopts}" | ||
@tmpfile = @tmpfile || _tmpfile | ||
super + ["--output=#{@tmpfile}"] | ||
end | ||
|
||
def compile(document) | ||
@tmpfile = self._tmpfile | ||
# Compiles the given +document+ to the format. | ||
# If a second argument +file+ is +true+, returns +File+ instead of +String+. | ||
# | ||
# *Note* that it creates a temporary file for the result. | ||
# If +file+ is +false+, the temporary file become deleted. | ||
def compile(document, file = false) | ||
@tmpfile = _tmpfile | ||
ps = IO.popen(document.command_for(self), 'w') | ||
ps.print(document.text) | ||
ps.close | ||
f = File.new(@tmpfile, 'r') | ||
return f if file | ||
result = f.read | ||
f.close | ||
File.unlink(@tmpfile) | ||
return result | ||
end | ||
|
||
private | ||
|
||
def _tmpfile | ||
Dir.tmpdir | ||
f = Tempfile.new('pandoku') | ||
path = f.path | ||
f.close(false) | ||
path | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters