SF.net SVN: geany: [1814] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed Aug 22 18:04:37 UTC 2007


Revision: 1814
          http://geany.svn.sourceforge.net/geany/?rev=1814&view=rev
Author:   eht16
Date:     2007-08-22 11:04:37 -0700 (Wed, 22 Aug 2007)

Log Message:
-----------
Fix some minor LaTeX code errors.
Add generation date to HTML header and as comment in the generated LaTeX code.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/plugins/export.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-08-21 17:43:42 UTC (rev 1813)
+++ trunk/ChangeLog	2007-08-22 18:04:37 UTC (rev 1814)
@@ -1,3 +1,11 @@
+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.

Modified: trunk/plugins/export.c
===================================================================
--- trunk/plugins/export.c	2007-08-21 17:43:42 UTC (rev 1813)
+++ trunk/plugins/export.c	2007-08-22 18:04:37 UTC (rev 1814)
@@ -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 @@
 	<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 @@
 </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 @@
 	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 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 @@
 			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 @@
 			}
 			case '\\':
 			{
-				g_string_append(body, "\\textbackslash");
+				g_string_append(body, "\\symbol{92}");
 				break;
 			}
 			case '~':
@@ -404,15 +443,46 @@
 			}
 			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);
 		}
 		column++;
@@ -459,7 +529,7 @@
 	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 @@
 
 	// 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)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list