2 // Convert text/plain to text/html
4 // Copyright (c) 2017-2022 by the citadel.org team
6 // This program is open source software. Use, duplication, or
7 // disclosure are subject to the GNU General Public License v3.
12 // Convert a text/plain message to text/html
13 StrBuf *text2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source) {
21 StrBufAppendPrintf(sj, "<pre>");
22 StrEscAppend(sj, Source, NULL, 0, 0); // FIXME - add code here to activate links
23 StrBufAppendPrintf(sj, "</pre>\n");
29 // Convert a text/x-citadel-variformat message to text/html
30 StrBuf *variformat2html(StrBuf * Source) {
31 StrBuf *Target = NULL;
38 const char *ptr, *pte;
39 const char *BufPtr = NULL;
40 StrBuf *Line = NewStrBufPlain(NULL, SIZ);
41 StrBuf *Line1 = NewStrBufPlain(NULL, SIZ);
42 StrBuf *Line2 = NewStrBufPlain(NULL, SIZ);
49 if (StrLength(Source) > 0)
51 StrBufSipLine(Line, Source, &BufPtr);
55 len = StrLength(Line);
58 if ((intext == 1) && (isspace(*ptr))) {
59 StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
63 while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
72 // Quoted text should be displayed in italics and in a
73 // different colour. This code understands Citadel-style
74 // " >" quotes and will convert to <BLOCKQUOTE> tags.
76 StrBufCutLeft(Line, i);
78 for (i = bn; i < bq; i++) {
79 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
81 for (i = bq; i < bn; i++) {
82 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
86 if (StrLength(Line) == 0)
89 // Activate embedded URL's
90 UrlizeText(Line1, Line, Line2);
91 StrEscAppend(Target, Line1, NULL, 0, 0);
92 StrBufAppendBufPlain(Target, HKEY("\n"), 0);
94 while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL));
96 for (i = 0; i < bn; i++) {
97 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
99 StrBufAppendBufPlain(Target, HKEY("<br>\n"), 0);