1 // Convert text/plain to text/html
3 // Copyright (c) 2017-2022 by the citadel.org team
5 // This program is open source software. Use, duplication, or
6 // disclosure are subject to the GNU General Public License v3.
11 // Convert a text/plain message to text/html
12 StrBuf *text2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source) {
20 StrBufAppendPrintf(sj, "<pre>");
21 StrEscAppend(sj, Source, NULL, 0, 0); // FIXME - add code here to activate links
22 StrBufAppendPrintf(sj, "</pre>\n");
28 // Convert a text/x-citadel-variformat message to text/html
29 StrBuf *variformat2html(StrBuf * Source) {
30 StrBuf *Target = NULL;
37 const char *ptr, *pte;
38 const char *BufPtr = NULL;
39 StrBuf *Line = NewStrBufPlain(NULL, SIZ);
40 StrBuf *Line1 = NewStrBufPlain(NULL, SIZ);
41 StrBuf *Line2 = NewStrBufPlain(NULL, SIZ);
48 if (StrLength(Source) > 0)
50 StrBufSipLine(Line, Source, &BufPtr);
54 len = StrLength(Line);
57 if ((intext == 1) && (isspace(*ptr))) {
58 StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
62 while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
71 // Quoted text should be displayed in italics and in a
72 // different colour. This code understands Citadel-style
73 // " >" quotes and will convert to <BLOCKQUOTE> tags.
75 StrBufCutLeft(Line, i);
77 for (i = bn; i < bq; i++) {
78 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
80 for (i = bq; i < bn; i++) {
81 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
85 if (StrLength(Line) == 0)
88 // Activate embedded URL's
89 UrlizeText(Line1, Line, Line2);
90 StrEscAppend(Target, Line1, NULL, 0, 0);
91 StrBufAppendBufPlain(Target, HKEY("\n"), 0);
93 while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL));
95 for (i = 0; i < bn; i++) {
96 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
98 StrBufAppendBufPlain(Target, HKEY("<br>\n"), 0);