diff --git a/resources/elcode_english.html b/resources/elcode_english.html index d36a0710..92ded8da 100755 --- a/resources/elcode_english.html +++ b/resources/elcode_english.html @@ -252,6 +252,46 @@ to produce

Other possibilities are [list=A] for capital letters and [list=I] for Roman numbering.

+

Tables

+ +
Tables can be created with the tags [table][/table] like

+ +[table border="1"]
+One|Two
+|-
+Three|Four
+[/table] +

+ +to produce

+ + + + +
OneTwo
ThreeFour
+

+ +The parameters after [table ...] are directly used in the HTML <table> +tag. To increase the cell padding, on can add for example

+ +[table border="1" cellpadding="20"]
+One|Two
+|-
+Three|Four
+[/table] +

+ +to produce

+ + + + +
OneTwo
ThreeFour
+

+ +Table headings are not supported, but can be simulated by embedding the cell +contents with a [B]...[/B] tag.

+

Creating links


Hyperlinks or Uniform Resouce Locators (URLs) can be created in various ways:

diff --git a/scripts/elcode.js b/scripts/elcode.js index f57cfa77..86861275 100755 --- a/scripts/elcode.js +++ b/scripts/elcode.js @@ -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 diff --git a/src/elogd.c b/src/elogd.c index 23408cc7..dc710f7e 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -5706,6 +5706,13 @@ PATTERN_LIST pattern_list[] = { {"[/quote]\r", "
\r\n"}, {"[/quote]", "\r\n"}, + /* table */ + {"[table]", "
"}, + {"[table ", "
"}, + {"|-", "
"}, + {"|", ""}, + {"[/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, "
\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(" ");