mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Added function to determine line breaks in HTML code
SVN revision: 2131
This commit is contained in:
parent
a2e4fbd773
commit
5f78eb4d21
21
src/elogd.c
21
src/elogd.c
@ -5459,6 +5459,23 @@ void strip_html(char *s)
|
|||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
int line_break(char *str, char *encoding)
|
||||||
|
{
|
||||||
|
if (strieq(encoding, "plain") || strieq(encoding, "ELCode")) {
|
||||||
|
return str[0] == '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTML encoding
|
||||||
|
if (strncmp(str, "</p>", 4) == 0 ||
|
||||||
|
strncmp(str, "<br>", 4) == 0 ||
|
||||||
|
strncmp(str, "<br />", 4) == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
void insert_breaks(char *str, int n, int size)
|
void insert_breaks(char *str, int n, int size)
|
||||||
{
|
{
|
||||||
int i, j, i_last;
|
int i, j, i_last;
|
||||||
@ -16993,7 +17010,7 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, int exp
|
|||||||
if (expand == 2) {
|
if (expand == 2) {
|
||||||
for (i = i_line = line_len = 0; i < (int) sizeof(str) - 1; i++, line_len++) {
|
for (i = i_line = line_len = 0; i < (int) sizeof(str) - 1; i++, line_len++) {
|
||||||
str[i] = text[i];
|
str[i] = text[i];
|
||||||
if (str[i] == '\n') {
|
if (line_break(text+i, encoding)) {
|
||||||
i_line++;
|
i_line++;
|
||||||
line_len = 0;
|
line_len = 0;
|
||||||
} else
|
} else
|
||||||
@ -17041,7 +17058,7 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, int exp
|
|||||||
max_line_len = n_line >= 10 ? 140 : 40;
|
max_line_len = n_line >= 10 ? 140 : 40;
|
||||||
for (i = i_line = line_len = 0; i < (int) sizeof(str) - 1; line_len++, i++) {
|
for (i = i_line = line_len = 0; i < (int) sizeof(str) - 1; line_len++, i++) {
|
||||||
str[i] = text[i];
|
str[i] = text[i];
|
||||||
if (str[i] == '\n') {
|
if (line_break(text+i, encoding)) {
|
||||||
i_line++;
|
i_line++;
|
||||||
line_len = 0;
|
line_len = 0;
|
||||||
} else
|
} else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user