Kaydet (Commit) 2425b99e authored tarafından Enrico Tröger's avatar Enrico Tröger

Fix some minor LaTeX code errors.

Add generation date to HTML header and as comment in the generated LaTeX code.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1814 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst f6f44f89
2007-08-22 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* plugins/export.c:
Fix some minor LaTeX code errors.
Add generation date to HTML header and as comment in the generated
LaTeX code.
2007-08-21 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/editor.h: Remove unused struct.
......
......@@ -35,7 +35,7 @@
PluginFields *plugin_fields;
GeanyData *geany_data;
VERSION_CHECK(10)
VERSION_CHECK(12)
PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."))
#define doc_array geany_data->doc_array
......@@ -56,6 +56,7 @@ PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."))
<title>{export_filename}</title>\n\
<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n\
<meta name=\"generator\" content=\"Geany " VERSION "\" />\n\
<meta name=\"date\" content=\"{export_date}\">\n\
<style type=\"text/css\">\n\
{export_styles}\n\
</style>\n\
......@@ -69,6 +70,7 @@ PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."))
</html>\n"
#define TEMPLATE_LATEX "\
% {export_filename} (LaTeX code generated by Geany " VERSION " on {export_date})\n\
\\documentclass[a4paper]{article}\n\
\\usepackage[a4paper,margin=2cm]{geometry}\n\
\\usepackage[utf8x]{inputenc}\n\
......@@ -95,6 +97,12 @@ enum
MAX_TYPES
};
enum
{
DATE_TYPE_DEFAULT,
DATE_TYPE_HTML
};
typedef void (*ExportFunc) (gint idx, const gchar *filename, gboolean use_zoom);
typedef struct
{
......@@ -267,6 +275,34 @@ static void write_data(const gchar *filename, const gchar *data)
}
static gchar *get_date(gint type)
{
static gchar str[128];
gchar *format;
time_t t;
struct tm *tmp;
t = time(NULL);
tmp = localtime(&t);
if (tmp == NULL)
return "";
if (type == DATE_TYPE_HTML)
// needs testing
#ifdef _GNU_SOURCE
format = "%Y-%m-%dT%H:%M:%S%z";
#else
format = "%Y-%m-%dT%H:%M:%S";
#endif
else
format = "%c";
strftime(str, sizeof str, format, tmp);
return str;
}
static void on_file_save_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
{
ExportInfo *exi = user_data;
......@@ -376,7 +412,10 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
case ' ':
{
if (c_next == ' ')
{
g_string_append(body, "{\\hspace*{1em}}");
i++; // skip the next character
}
else
g_string_append_c(body, ' ');
break;
......@@ -394,7 +433,7 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
}
case '\\':
{
g_string_append(body, "\\textbackslash");
g_string_append(body, "\\symbol{92}");
break;
}
case '~':
......@@ -404,13 +443,44 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
}
case '^':
{
g_string_append(body, "\\symbol{92}");
g_string_append(body, "\\symbol{94}");
break;
}
/// TODO still don't work for "---" or "----"
case '-': // mask "--"
{
if (c_next == '-')
g_string_append(body, "-\\@-");
{
g_string_append(body, "-\\/-");
i++; // skip the next character
}
else
g_string_append_c(body, '-');
break;
}
case '<': // mask "<<"
{
if (c_next == '<')
{
g_string_append(body, "<\\/<");
i++; // skip the next character
}
else
g_string_append_c(body, '<');
break;
}
case '>': // mask ">>"
{
if (c_next == '>')
{
g_string_append(body, ">\\/>");
i++; // skip the next character
}
else
g_string_append_c(body, '>');
break;
}
default: g_string_append_c(body, c);
......@@ -459,7 +529,7 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
latex = g_strdup(TEMPLATE_LATEX);
latex = utils->str_replace(latex, "{export_content}", body->str);
latex = utils->str_replace(latex, "{export_styles}", cmds->str);
// {export_filename} is currently unused but maybe someone want to use it
latex = utils->str_replace(latex, "{export_date}", get_date(DATE_TYPE_DEFAULT));
if (doc_list[idx].file_name == NULL)
latex = utils->str_replace(latex, "{export_filename}", GEANY_STRING_UNTITLED);
else
......@@ -608,6 +678,7 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
// write all
html = g_strdup(TEMPLATE_HTML);
html = utils->str_replace(html, "{export_date}", get_date(DATE_TYPE_HTML));
html = utils->str_replace(html, "{export_content}", body->str);
html = utils->str_replace(html, "{export_styles}", css->str);
if (doc_list[idx].file_name == NULL)
......
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