Permalink
Browse files

added option to select between pdf and dvi

  • Loading branch information...
1 parent 55d918e commit 822fee9d9b90a66eaadaa14e3770f24727ba6246 @mikolalysenko committed Jan 28, 2013
Showing with 11 additions and 6 deletions.
  1. +3 −2 README.md
  2. +4 −2 package.json
  3. +4 −2 texwrapper.js
View
@@ -32,7 +32,7 @@ Here is an example of how to use the library in one line:
"\\end{document}"
]).pipe(process.stdout)
-This will basically spit out a formatted dvi article to stdout that says "hello world". The result of calling the function is returned as a stream and can be processed using other tools. If you want to convert the result into an image or pdf, you can use [graphics magic](http://aheckmann.github.com/gm/).
+This will spit out a formatted PDF article to stdout that says "hello world". The result of calling the function is returned as a stream and can be processed using other tools. If you want to convert the result into an image or pdf, you can use [graphics magic](http://aheckmann.github.com/gm/).
`require("latex")(doc[, options])`
----------------------------------
@@ -46,8 +46,9 @@ The only exported function from `node-latex` is a function that takes as input a
In addition, you can also specify the following additional parameters via the `options` struct:
* `command`: An optional override for the latex command. By default calls `latex`.
+* `format`: Either "pdf" or "dvi". By default returns a pdf.
-The function returns a readable Stream object representing a LaTeX encoded document in [DVI format](http://en.wikipedia.org/wiki/Device_independent_file_format). If there were errors in the syntax of the document, they will be raised as errors on this Stream object.
+The function returns a readable Stream object representing a LaTeX encoded document in either PDF or [DVI format](http://en.wikipedia.org/wiki/Device_independent_file_format). If there were errors in the syntax of the document, they will be raised as errors on this Stream object.
Credits
=======
View
@@ -1,6 +1,6 @@
{
"name": "latex",
- "version": "0.0.0",
+ "version": "0.0.1",
"description": "A simple wrapper for LaTeX in node.js",
"main": "texwrapper.js",
"directories": {
@@ -27,7 +27,9 @@
"equations",
"typesetting",
"math",
- "pdflatex"
+ "pdflatex",
+ "dvi",
+ "pdf"
],
"author": "Mikola Lysenko",
"license": "MIT",
View
@@ -87,8 +87,10 @@ module.exports = function(doc, options) {
options = {};
}
+ var format = options.format || "pdf";
+
//LaTeX command
- var tex_command = options.command || "latex";
+ var tex_command = options.command || (format === "pdf" ? "pdflatex" : "latex");
//Create result
var result = through();
@@ -116,7 +118,7 @@ module.exports = function(doc, options) {
});
//Wait for LaTeX to finish its thing
tex.on("exit", function(code, signal) {
- var output_file = path.join(dirpath, "texput.dvi");
+ var output_file = path.join(dirpath, "texput." + format);
fs.exists(output_file, function(exists) {
if(exists) {
var stream = fs.createReadStream(output_file);

0 comments on commit 822fee9

Please sign in to comment.