Commit 53ef3c90 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Rename from latex_fprintf. Don't escape quotes. Do escape braces. Properly

2000-07-25  Morten Welinder <terra@diku.dk>

	* latex.c (latex_fprintf_cell): Rename from latex_fprintf.  Don't
 	escape quotes.  Do escape braces.  Properly handle '^', '~', and
 	'\\'.  Don't return anything.
	(latex_fputs): New function extracted from latex_fprintf_cell.
	(html_write_wb_latex): Write sheet name in LaTeX style.
	(html_write_wb_latex2e): Ditto.

	[Sure looks like the following!]
parent f019b8e6
2000-07-25 Morten Welinder <terra@diku.dk>
* latex.c (latex_fprintf_cell): Rename from latex_fprintf. Don't
escape quotes. Do escape braces. Properly handle '^', '~', and
'\\'. Don't return anything.
(latex_fputs): New function extracted from latex_fprintf_cell.
(html_write_wb_latex): Write sheet name in LaTeX style.
(html_write_wb_latex2e): Ditto.
[Sure looks like the following!]
2000-07-25 Jody Goldberg <jgoldberg@home.com> 2000-07-25 Jody Goldberg <jgoldberg@home.com>
* latex.c (latex_fprint_string) : New function split from * latex.c (latex_fprint_string) : New function split from
......
...@@ -33,29 +33,31 @@ ...@@ -33,29 +33,31 @@
* escape special characters * escape special characters
*/ */
static void static void
latex_fprint_string (FILE *fp, char const *str) latex_fputs (const char *p, FILE *fp)
{ {
for (; *str ; str++) { for (; *p; p++) {
switch (*str) { switch (*p) {
case '>': case '>': case '<':
case '<': fprintf (fp, "$%c$", *p);
fprintf (fp, "$%c$", *str); break;
continue; case '^': case '~':
fprintf (fp, "\\%c{ }", *p);
case '&': break;
case '_': case '\\':
case '%': fputs ("$\\backslash$", fp);
case '"': break;
case '$': case '&': case '_': case '%': case '#':
case '#': case '{': case '}': case '$':
fputc ('\\', fp); fprintf (fp, "\\%c", *p);
break;
default : default:
fputc (*p, fp);
break;
} }
fputc ((unsigned char)*str, fp);
} }
} }
static void static void
latex_fprintf_cell (FILE *fp, const Cell *cell) latex_fprintf_cell (FILE *fp, const Cell *cell)
{ {
...@@ -64,8 +66,12 @@ latex_fprintf_cell (FILE *fp, const Cell *cell) ...@@ -64,8 +66,12 @@ latex_fprintf_cell (FILE *fp, const Cell *cell)
if (cell_is_blank (cell)) if (cell_is_blank (cell))
return; return;
/*
* FIXME: this is wrong for formulae. We should do the full math
* thing.
*/
s = cell_get_rendered_text (cell); s = cell_get_rendered_text (cell);
latex_fprint_string (fp, s); latex_fputs (s, fp);
g_free (s); g_free (s);
} }
...@@ -98,7 +104,7 @@ html_write_wb_latex (CommandContext *context, Workbook *wb, ...@@ -98,7 +104,7 @@ html_write_wb_latex (CommandContext *context, Workbook *wb,
sheet_list = workbook_sheets (wb); sheet_list = workbook_sheets (wb);
while (sheet_list) { while (sheet_list) {
sheet = sheet_list->data; sheet = sheet_list->data;
latex_fprint_string (fp, sheet->name_unquoted); latex_fputs (sheet->name_unquoted, fp);
fprintf (fp, "\n\n"); fprintf (fp, "\n\n");
fprintf (fp, "\\begin{tabular}{|"); fprintf (fp, "\\begin{tabular}{|");
for (col = 0; col <= sheet->cols.max_used; col++) { for (col = 0; col <= sheet->cols.max_used; col++) {
...@@ -167,8 +173,6 @@ html_write_wb_latex (CommandContext *context, Workbook *wb, ...@@ -167,8 +173,6 @@ html_write_wb_latex (CommandContext *context, Workbook *wb,
/* /*
* write every sheet of the workbook to a latex2e table * write every sheet of the workbook to a latex2e table
*
* FIXME: Should latex quote sheet name (and everything else)
*/ */
int int
html_write_wb_latex2e (CommandContext *context, Workbook *wb, html_write_wb_latex2e (CommandContext *context, Workbook *wb,
...@@ -199,7 +203,7 @@ html_write_wb_latex2e (CommandContext *context, Workbook *wb, ...@@ -199,7 +203,7 @@ html_write_wb_latex2e (CommandContext *context, Workbook *wb,
sheet_list = workbook_sheets (wb); sheet_list = workbook_sheets (wb);
while (sheet_list) { while (sheet_list) {
sheet = sheet_list->data; sheet = sheet_list->data;
latex_fprint_string (fp, sheet->name_unquoted); latex_fputs (sheet->name_unquoted, fp);
fprintf (fp, "\n\n"); fprintf (fp, "\n\n");
fprintf (fp, "\\begin{tabular}{|"); fprintf (fp, "\\begin{tabular}{|");
for (col = 0; col <= sheet->cols.max_used; col++) { for (col = 0; col <= sheet->cols.max_used; col++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment