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.
20 * Convert a text/plain message to text/html
22 StrBuf *text2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf * Source)
31 StrBufAppendPrintf(sj, "<pre>");
32 StrEscAppend(sj, Source, NULL, 0, 0); // FIXME - add code here to activate links
33 StrBufAppendPrintf(sj, "</pre>\n");
40 * Convert a text/x-citadel-variformat message to text/html
42 StrBuf *variformat2html(StrBuf * Source)
44 StrBuf *Target = NULL;
51 const char *ptr, *pte;
52 const char *BufPtr = NULL;
53 StrBuf *Line = NewStrBufPlain(NULL, SIZ);
54 StrBuf *Line1 = NewStrBufPlain(NULL, SIZ);
55 StrBuf *Line2 = NewStrBufPlain(NULL, SIZ);
62 if (StrLength(Source) > 0)
64 StrBufSipLine(Line, Source, &BufPtr);
68 len = StrLength(Line);
71 if ((intext == 1) && (isspace(*ptr))) {
72 StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
76 while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
86 * Quoted text should be displayed in italics and in a
87 * different colour. This code understands Citadel-style
88 * " >" quotes and will convert to <BLOCKQUOTE> tags.
91 StrBufCutLeft(Line, i);
93 for (i = bn; i < bq; i++)
94 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
95 for (i = bq; i < bn; i++)
96 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
99 if (StrLength(Line) == 0)
102 /* Activate embedded URL's */
103 UrlizeText(Line1, Line, Line2);
105 StrEscAppend(Target, Line1, NULL, 0, 0);
107 StrBufAppendBufPlain(Target, HKEY("\n"), 0);
109 while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL));
111 for (i = 0; i < bn; i++) {
112 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
114 StrBufAppendBufPlain(Target, HKEY("<br>\n"), 0);