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 disclosure is subject to the GNU General Public License v3.
10 // Convert a text/plain message to text/html
11 StrBuf *text2html(const char *supplied_charset, int treat_as_wiki, char *roomname, long msgnum, StrBuf *Source) {
19 StrBufAppendPrintf(sj, "<pre>");
20 StrEscAppend(sj, Source, NULL, 0, 0); // FIXME - add code here to activate links
21 StrBufAppendPrintf(sj, "</pre>\n");
27 // Convert a text/x-citadel-variformat message to text/html
28 StrBuf *variformat2html(StrBuf * Source) {
29 StrBuf *Target = NULL;
36 const char *ptr, *pte;
37 const char *BufPtr = NULL;
38 StrBuf *Line = NewStrBufPlain(NULL, SIZ);
39 StrBuf *Line1 = NewStrBufPlain(NULL, SIZ);
40 StrBuf *Line2 = NewStrBufPlain(NULL, SIZ);
47 if (StrLength(Source) > 0)
49 StrBufSipLine(Line, Source, &BufPtr);
53 len = StrLength(Line);
56 if ((intext == 1) && (isspace(*ptr))) {
57 StrBufAppendBufPlain(Target, HKEY("<br>"), 0);
61 while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
70 // Quoted text should be displayed in italics and in a
71 // different colour. This code understands Citadel-style
72 // " >" quotes and will convert to <BLOCKQUOTE> tags.
74 StrBufCutLeft(Line, i);
76 for (i = bn; i < bq; i++) {
77 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
79 for (i = bq; i < bn; i++) {
80 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
84 if (StrLength(Line) == 0)
87 // Activate embedded URL's
88 UrlizeText(Line1, Line, Line2);
89 StrEscAppend(Target, Line1, NULL, 0, 0);
90 StrBufAppendBufPlain(Target, HKEY("\n"), 0);
92 while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL));
94 for (i = 0; i < bn; i++) {
95 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
97 StrBufAppendBufPlain(Target, HKEY("<br>\n"), 0);