Revision: 1889 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1889&view=re... Author: frlan Date: 2011-01-29 16:40:17 +0000 (Sat, 29 Jan 2011)
Log Message: ----------- Tableconvert: Check for file type whether we have HTML
This is done in preparation for adding support for other file types.
Modified Paths: -------------- trunk/geany-plugins/tableconvert/src/tableconvert.c
Modified: trunk/geany-plugins/tableconvert/src/tableconvert.c =================================================================== --- trunk/geany-plugins/tableconvert/src/tableconvert.c 2011-01-29 14:19:47 UTC (rev 1888) +++ trunk/geany-plugins/tableconvert/src/tableconvert.c 2011-01-29 16:40:17 UTC (rev 1889) @@ -64,50 +64,52 @@ guint i; guint j;
- /* Adding header to replacement */ - replacement_str = g_string_new("<table>\n"); - - /* Adding <thead> if requested */ - if (header == TRUE) + if (doc->file_type->id == GEANY_FILETYPES_HTML) { - g_string_append(replacement_str, "<thead>\n"); - } + /* Adding header to replacement */ + replacement_str = g_string_new("<table>\n");
- /* Iteration onto rows and building up lines of table for - * replacement */ - - for (i = 0; rows[i] != NULL ; i++) - { - gchar **columns = NULL; - columns = g_strsplit_set(rows[i], "\t", -1); - - /* Adding <tbody> after first line if header and body - * is requested */ - if (i == 1 && - header == TRUE) + /* Adding <thead> if requested */ + if (header == TRUE) { - g_string_append(replacement_str, "<tbody>\n"); + g_string_append(replacement_str, "<thead>\n"); }
- g_string_append(replacement_str, "\t<tr>\n"); - for (j = 0; columns[j] != NULL; j++) + /* Iteration onto rows and building up lines of table for + * replacement */ + + for (i = 0; rows[i] != NULL ; i++) { - g_string_append(replacement_str, "\t\t<td>"); - g_string_append(replacement_str, columns[j]); - g_string_append(replacement_str, "</td>\n"); - } + gchar **columns = NULL; + columns = g_strsplit_set(rows[i], "\t", -1);
- g_string_append(replacement_str, "\t</tr>\n"); + /* Adding <tbody> after first line if header and body + * is requested */ + if (i == 1 && + header == TRUE) + { + g_string_append(replacement_str, "<tbody>\n"); + }
- /* Adding closing </thead> after first row if header - * is requested */ - if (i == 0 && - header == TRUE) - { - g_string_append(replacement_str, "</thead>\n"); + g_string_append(replacement_str, "\t<tr>\n"); + for (j = 0; columns[j] != NULL; j++) + { + g_string_append(replacement_str, "\t\t<td>"); + g_string_append(replacement_str, columns[j]); + g_string_append(replacement_str, "</td>\n"); + } + + g_string_append(replacement_str, "\t</tr>\n"); + + /* Adding closing </thead> after first row if header + * is requested */ + if (i == 0 && + header == TRUE) + { + g_string_append(replacement_str, "</thead>\n"); + } + g_free(columns); } - - g_free(columns); } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.