Implemented simple tables

SVN revision: 1801
This commit is contained in:
2007-02-28 19:57:43 +00:00
parent 5979d3c9b5
commit f99410d04f
3 changed files with 68 additions and 2 deletions
+40
View File
@@ -252,6 +252,46 @@ to produce<p>
Other possibilities are <b>[list=A]</b> for capital letters and <b>[list=I]</b> for Roman numbering.<p>
<tr><td bgcolor=#486090><h2>Tables</h2></td></tr>
<tr><td bgcolor=#FFFFFF><br>Tables can be created with the tags <b>[table][/table]</b> like<p>
<b>[table border="1"]</b><br>
One<b>|</b>Two<br>
<b>|-</b><br>
Three<b>|</b>Four<br>
<b>[/table]</b>
<p>
to produce<p>
<table border="1">
<tr><td>One</td><td>Two</td></tr>
<tr><td>Three</td><td>Four</td></tr>
</table>
<p>
The parameters after <b>[table ...]</b> are directly used in the HTML &lt;table&gt;
tag. To increase the cell padding, on can add for example<p>
<b>[table border="1" cellpadding="20"]</b><br>
One<b>|</b>Two<br>
<b>|-</b><br>
Three<b>|</b>Four<br>
<b>[/table]</b>
<p>
to produce<p>
<table border="1" cellpadding="20">
<tr><td>One</td><td>Two</td></tr>
<tr><td>Three</td><td>Four</td></tr>
</table>
<p>
Table headings are not supported, but can be simulated by embedding the cell
contents with a <b>[B]...[/B]</b> tag.<p>
<tr><td bgcolor=#486090><h2>Creating links</h2></td></tr>
<tr><td bgcolor=#FFFFFF><br>Hyperlinks or Uniform Resouce Locators (URLs) can be created in various ways:<p>
+2
View File
@@ -57,6 +57,8 @@ function elcode1(text, tag, value, selection)
str = selection + value;
else if (tag == 'LIST')
str = '[LIST]\r\n[*] ' + selection + '\r\n[/LIST]';
else if (tag == 'TABLE')
str = '[TABLE border="1"]\r\nA|B\r\n|-\r\nC|D\r\n[/TABLE]';
else if (value == '')
str = '['+tag+']' + selection + '[/'+tag+']';
else
+26 -2
View File
@@ -5706,6 +5706,13 @@ PATTERN_LIST pattern_list[] = {
{"[/quote]\r", "</td></tr></table><br />\r\n"},
{"[/quote]", "</td></tr></table>\r\n"},
/* table */
{"[table]", "<table><tr><td>"},
{"[table ", "<table %s><tr><td>"},
{"|-", "</td></tr><tr><td>"},
{"|", "</td><td>"},
{"[/table]", "</td></tr></table>"},
{"", ""}
};
@@ -5714,7 +5721,8 @@ char *email_quote_table =
void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str)
{
int i, j, k, l, m, elcode_disabled, elcode_disabled1, escape_char, ordered_list, substituted;
int i, j, k, l, m, elcode_disabled, elcode_disabled1, escape_char, ordered_list, substituted,
inside_table;
char *p, *pd, link[1000], link_text[1000], tmp[1000], attrib[1000], hattrib[1000],
value[1000], subst[1000], base_url[256], param[256], *lstr;
@@ -5728,6 +5736,7 @@ void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str)
elcode_disabled1 = FALSE;
ordered_list = FALSE;
escape_char = FALSE;
inside_table = 0;
j = strlen_retbuf;
m = 0;
@@ -5874,6 +5883,11 @@ void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str)
if (stristr(pattern_list[l].pattern, "[list="))
ordered_list = TRUE;
if (stristr(pattern_list[l].pattern, "[table"))
inside_table++;
if (stristr(pattern_list[l].pattern, "[/table]"))
inside_table--;
if (stristr(pattern_list[l].pattern, "[quote")) {
if (pattern_list[l].pattern[strlen(pattern_list[l].pattern) - 1] == '=') {
i += strlen(pattern_list[l].pattern);
@@ -5997,6 +6011,15 @@ void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str)
sprintf(return_buffer + j, pattern_list[l].subst, attrib);
j += strlen(return_buffer + j);
} else if (pattern_list[l].pattern[strlen(pattern_list[l].pattern) - 1] == ' ') {
/* extract sting after ' ' and put it into '%s' of subst */
i += strlen(pattern_list[l].pattern);
strextract(str + i, ']', attrib, sizeof(attrib));
i += strlen(attrib);
sprintf(return_buffer + j, pattern_list[l].subst, attrib);
j += strlen(return_buffer + j);
} else if (strncmp(pattern_list[l].pattern, "[/list]", 7) == 0) {
if (ordered_list)
@@ -6067,7 +6090,7 @@ void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str)
} else
switch (str[i]) {
case '\r':
if (!elcode_disabled && !elcode_disabled1) {
if (!elcode_disabled && !elcode_disabled1 && !inside_table) {
strcat(return_buffer, "<br />\r\n");
j += 8;
} else {
@@ -9840,6 +9863,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf(" ");
ricon("quote", loc("insert quote"), "elcode(document.form1.Text, 'QUOTE','')");
ricon("list", loc("insert list"), "elcode(document.form1.Text, 'LIST','')");
ricon("table", loc("insert table"), "elcode(document.form1.Text, 'TABLE','')");
ricon("heading", loc("insert heading"), "queryHeading(document.form1.Text)");
rsprintf(" ");