Texcaller
|
The Texcaller library is a convenient C interface to the TeX command line tools. More...
Modules | |
Internals of the Texcaller C interface | |
Functions | |
void | texcaller_convert (char **result, size_t *result_size, char **info, const char *source, size_t source_size, const char *source_format, const char *result_format, int max_runs) |
Convert a TeX or LaTeX source to DVI or PDF. More... | |
char * | texcaller_escape_latex (const char *s) |
Escape a string for direct use in LaTeX. More... | |
The Texcaller library is a convenient C interface to the TeX command line tools.
The following example program demonstrates how this library is meant to be used:
Since Texcaller supports pkg-config, compiling and linking in a portable way is as simple as:
Assuming that everything is installed in default locations on your system, the following simpler command will also work. However, don't hard code that into your build system!
void texcaller_convert | ( | char ** | result, |
size_t * | result_size, | ||
char ** | info, | ||
const char * | source, | ||
size_t | source_size, | ||
const char * | source_format, | ||
const char * | result_format, | ||
int | max_runs | ||
) |
Convert a TeX or LaTeX source to DVI or PDF.
This function is reentrant. Temporary files are always cleaned up. The TeX interpreter is automatically re-run as often as necessary until the output becomes stable. The interpreter is always run in batch mode and is disconnected from stdin, stdout and stderr. That way, it won't ever get in your way even if there are issues with your input source. Instead, all important information is simply collected in the info
string.
result | will be set to a newly allocated buffer that contains the generated document, or NULL if an error occured. |
result_size | will be set to the size of result , or 0 if result is NULL . |
info | will be set to a newly allocated string that contains additional information such as an error message or TeX warnings. When out of memory, info will be set to NULL (and result will be set to NULL , too). |
source | the source to convert |
source_size | size of source |
source_format | must be one of:
|
result_format | must be one of:
|
max_runs | maximum number of TeX runs, must be ≥ 2. If the output doesn't stabilize after max_runs runs, the function will fail and result will be set to NULL . |
char * texcaller_escape_latex | ( | const char * | s | ) |
Escape a string for direct use in LaTeX.
That is, all LaTeX special characters are replaced with proper LaTeX elements. Note that all other unicode characters remain as they are, so be sure to use the inputenc
package in your LaTeX document:
For example, the following string:
Téxt → "with" $peciäl <characters>
is escaped to:
Téxt → {''}with{''} \$peciäl \textless{}characters\textgreater{}
This function is reentrant.
s | the string to escape |
NULL
when out of memory.