2 // Convert text/plain to text/html
4 // Copyright (c) 2017-2018 by the citadel.org team
6 // This program is open source software. It runs great on the
7 // Linux operating system (and probably elsewhere). You can use,
8 // copy, and run it under the terms of the GNU General Public
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
19 // Convert a text/plain message to text/html
20 StrBuf *text2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf * Source) {
28 StrBufAppendPrintf(sj, "<pre>");
29 StrEscAppend(sj, Source, NULL, 0, 0); // FIXME - add code here to activate links
30 StrBufAppendPrintf(sj, "</pre>\n");
36 // Convert a text/x-citadel-variformat message to text/html
37 StrBuf *variformat2html(StrBuf * Source) {
38 StrBuf *Target = NULL;
45 const char *ptr, *pte;
46 const char *BufPtr = NULL;
47 StrBuf *Line = NewStrBufPlain(NULL, SIZ);
48 StrBuf *Line1 = NewStrBufPlain(NULL, SIZ);
49 StrBuf *Line2 = NewStrBufPlain(NULL, SIZ);
56 if (StrLength(Source) > 0)
58 StrBufSipLine(Line, Source, &BufPtr);
62 len = StrLength(Line);
65 if ((intext == 1) && (isspace(*ptr))) {
66 StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
70 while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
79 // Quoted text should be displayed in italics and in a
80 // different colour. This code understands Citadel-style
81 // " >" quotes and will convert to <BLOCKQUOTE> tags.
83 StrBufCutLeft(Line, i);
85 for (i = bn; i < bq; i++)
86 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
87 for (i = bq; i < bn; i++)
88 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
91 if (StrLength(Line) == 0)
94 // Activate embedded URL's
95 UrlizeText(Line1, Line, Line2);
97 StrEscAppend(Target, Line1, NULL, 0, 0);
99 StrBufAppendBufPlain(Target, HKEY("\n"), 0);
101 while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL));
103 for (i = 0; i < bn; i++) {
104 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
106 StrBufAppendBufPlain(Target, HKEY("<br>\n"), 0);