[Patch] Adds simple table support
Paul de Bruin <[email protected]> Sun, 1 Feb 2004 12:02:15 +0100
| Newsgroups | gmane.comp.web.wiki.awkiawki.user |
|---|---|
| Message-ID | <[email protected]> |
Hello, Here is a small patch for parser.awk that adds simple table support to awkiawki. Patch is made using latest CVS. <-snip-> Documentation: Tables can be created using the following syntax: | cell | or | cell | cell | or | cell | cell | | cell | cell | or | cell | cell | | cell | | cell | cell | cell | A table is created if there are at least two "|" on a line, and the first "|" is in the first column. Note that pre, list, and table environments cannot be mixed and that the entire row of a table should be on one line. <-snip-> I would love to see this going into CVS. Any comments? Regards, Paul -- --------------------------------------------------------------- | ir. P.W. de Bruin, Delft University of Technology | | Faculty of Information Technology and Systems | | http://visualisation.tudelft.nl/~paul PGP-ID:CD36D25B | ---------------------------------------------------------------
table.diff
(text/plain, 1012 B)
Index: parser.awk
===================================================================
RCS file: /cvsroot/awkiawki/awkiawki/parser.awk,v
retrieving revision 1.6
diff -u -r1.6 parser.awk
--- parser.awk 7 Dec 2002 13:46:45 -0000 1.6
+++ parser.awk 1 Feb 2004 10:57:58 -0000
@@ -91,6 +91,9 @@
next;
}
+# tables
+/^\|.*\|/ { close_tags("table"); parse_table(); print; next; }
+
NR == 1 { print "<p>"; }
{
close_tags();
@@ -111,6 +114,7 @@
close_tags();
}
+
function close_tags(not) {
# if list is parsed this line print it
@@ -128,7 +132,14 @@
pre = 0
}
}
-
+ # close table
+ if (not !~ "table") {
+ if (table == 1) {
+ parse_table()
+ print "</table>"
+ table = 0
+ }
+ }
}
function parse_list(this, other) {
@@ -168,4 +179,15 @@
list[other] = 0
list[this] = tabcount
+}
+function parse_table() {
+ if (table != 1) {
+ print "<table>"
+ table = 1;
+ }
+ if (table == 1) {
+ gsub(/^\|/,"<tr><td>");
+ gsub(/\|[ ]*$/,"</td></tr>");
+ gsub(/\|/,"</td><td>");
+ }
}