commit 48372db7f6d048e77e169c520bdb51e43f9c1702
parent 5a5f26540bf525d23b4650e0b558e0cdaedcd396
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Thu, 25 Apr 2019 19:50:47 +0200
sfeed_atom: add content too (for completeness)
Diffstat:
1 file changed, 35 insertions(+), 0 deletions(-)
diff --git a/sfeed_atom.c b/sfeed_atom.c
@@ -14,6 +14,29 @@ static char *line;
static size_t linesize;
static void
+printcontent(const char *s)
+{
+ for (; *s; ++s) {
+ switch (*s) {
+ case '<': fputs("<", stdout); break;
+ case '>': fputs(">", stdout); break;
+ case '\'': fputs("'", stdout); break;
+ case '&': fputs("&", stdout); break;
+ case '"': fputs(""", stdout); break;
+ case '\\':
+ s++;
+ switch (*s) {
+ case 'n': putchar('\n'); break;
+ case '\\': putchar('\\'); break;
+ case 't': putchar('\t'); break;
+ }
+ break;
+ default: putchar(*s);
+ }
+ }
+}
+
+static void
printfeed(FILE *fp, const char *feedname)
{
char *fields[FieldLast];
@@ -59,6 +82,18 @@ printfeed(FILE *fp, const char *feedname)
xmlencode(fields[FieldAuthor], stdout);
fputs("</name></author>\n", stdout);
}
+ if (fields[FieldContent][0]) {
+ if (!strcmp(fields[FieldContentType], "html")) {
+ fputs("\t<content type=\"html\">", stdout);
+ } else {
+ /* NOTE: an RSS/Atom viewer may or may not format
+ whitespace such as newlines.
+ Workaround: type="html" and <![CDATA[<pre></pre>]]> */
+ fputs("\t<content type=\"text\">", stdout);
+ }
+ printcontent(fields[FieldContent]);
+ fputs("</content>\n", stdout);
+ }
fputs("</entry>\n", stdout);
}
}