Trailing "\r" in the Custom Conversion Method for LaTeX Renderer
vyvee - September 6, 2006 - 03:28
| Project: | DruTeX |
| Version: | HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | dfg |
| Status: | closed |
Jump to:
Description
The Conversion Method (Custom) in the LaTeX Renderer will not trim trailing whitespace characters. E.g., I use the following method:
cd [TMP_DIR]; TEXINPUTS="[DRUTEX_DIR]//:" latex -interaction=batchmode [HASH].tex
dvips -E [TMP_DIR]/[HASH].dvi -o [TMP_DIR]/[HASH].ps
convert -density [DPI] -trim -transparent "#FFFFFF" [TMP_DIR]/[HASH].ps [IMG_FILE]After executing the 2nd command, a file with name "[HASH].ps\r" instead of "[HASH].ps" will be generated. I think it's related to some conversion issue of the carriage return. (But I use Firefox under Linux to connect to a Linux server, I don't know why this still happens.) Besides, if any line is blank, e.g., if I just add a carriage return after the 3rd line (thus creating a blank 4th line), the LaTeX Renderer will complain it too as we pass a blank string to exec().
The problem can be solved by:
1. Adding a trailing ';' at the end of each line. Also, don't include a trailing carriage return.
2. (Probably a better way) Modify drutex_render.inc to something like:
<?php
...
/* invoke all conversion commands */
$commands = explode("\n", $cmd_convert);
foreach ($commands as $cmd) {
$cmd_trimmed = trim($cmd);
if ($cmd_trimmed != '')
exec($cmd_trimmed);
}
...
?>
#1
Thank you. I fixed that now.
#2