src/hg/hgTables/hgTables.c 1.173
1.173 2009/03/16 05:08:48 kent
Starting to add bigBed support. So far the schema button works at least.
Index: src/hg/hgTables/hgTables.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTables/hgTables.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -b -B -U 4 -r1.172 -r1.173
--- src/hg/hgTables/hgTables.c 10 Mar 2009 01:25:24 -0000 1.172
+++ src/hg/hgTables/hgTables.c 16 Mar 2009 05:08:48 -0000 1.173
@@ -73,8 +73,70 @@
for (i=0; i<count; ++i)
hPrintf(" ");
}
+static void stripHtmlTags(char *text)
+/* remove HTML tags from text string, replacing in place by moving
+ * the text up to take their place
+ */
+{
+char *s = text;
+char *e = text;
+char c = *text;
+for ( ; c != 0 ; )
+ {
+ c = *s++;
+ if (c == 0)
+ /* input string is NULL, or it ended with '>' without any
+ * opening '>'
+ */
+ {
+ *e = 0;
+ break;
+ }
+ /* stays in the while loop for adjacent tags <TR><TD> ... etc */
+ while (c == '<' && c != 0)
+ {
+ s = strchr(s,'>');
+ if (s != NULL)
+ {
+ if (*s == '>') ++s; /* skip closing bracket > */
+ c = *s++; /* next char after the closing bracket > */
+ }
+ else
+ c = 0; /* no closing bracket > found, end of string */
+ }
+ *e++ = c; /* copies all text outside tags, including ending NULL */
+ }
+}
+
+void writeHtmlCell(char *text)
+/* Write out a cell in an HTML table, making text not too big,
+ * and stripping html tags and breaking spaces.... */
+{
+int maxLen = 128;
+if (strlen(text) > maxLen)
+ {
+ char *s = cloneStringZ(text,maxLen);
+ char *r;
+ stripHtmlTags(s);
+ eraseTrailingSpaces(s);
+ r = replaceChars(s, " ", " ");
+ hPrintf("<TD>%s ...</TD>", r);
+ freeMem(s);
+ freeMem(r);
+ }
+else
+ {
+ char *r;
+ stripHtmlTags(text);
+ eraseTrailingSpaces(text);
+ r = replaceChars(text, " ", " ");
+ hPrintf("<TD>%s</TD>", r);
+ freeMem(r);
+ }
+}
+
static void vaHtmlOpen(char *format, va_list args)
/* Start up a page that will be in html format. */
{
puts("Content-Type:text/html\n");