# HG changeset patch # User Josef 'Jeff' Sipek # Date 1596933868 14400 # Node ID bd0e1b140566af96d420b8763749c8016e4cb0ed # Parent 9ec759a836936f37d7a77b396349bb99c6d165fd post fmt 2: reintroduce raw html format support This time, however, the implementation is much simpler and the post files use the .html file extension. Signed-off-by: Josef 'Jeff' Sipek diff -r 9ec759a83693 -r bd0e1b140566 docs/lisp-metadata.txt --- a/docs/lisp-metadata.txt Fri Aug 21 08:59:58 2020 -0400 +++ b/docs/lisp-metadata.txt Sat Aug 08 20:44:28 2020 -0400 @@ -29,6 +29,7 @@ The supported formats are: + 2: raw HTML 3: pseudo-LaTeX tags: list of tags associated with this post diff -r 9ec759a83693 -r bd0e1b140566 post.c --- a/post.c Fri Aug 21 08:59:58 2020 -0400 +++ b/post.c Sat Aug 08 20:44:28 2020 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2019 Josef 'Jeff' Sipek + * Copyright (c) 2009-2020 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -233,6 +233,15 @@ val_putref(list); } +static int __do_load_post_body_fmt2(struct post *post, struct str *html) +{ + str_putref(post->body); /* free the previous */ + post->body = str_getref(html); + ASSERT(post->body); + + return 0; +} + static int __do_load_post_body_fmt3(struct post *post, const struct str *input) { struct parser_output x; @@ -296,6 +305,7 @@ static int __load_post_body(struct post *post) { static const char *exts[4] = { + [2] = "html", [3] = "tex", }; @@ -303,7 +313,8 @@ struct str *raw; int ret; - ASSERT3U(post->fmt, ==, 3); + ASSERT3U(post->fmt, >=, 2); + ASSERT3U(post->fmt, <=, 3); snprintf(path, FILENAME_MAX, "%s/posts/%d/post.%s", str_cstr(config.data_dir), post->id, exts[post->fmt]); @@ -312,7 +323,14 @@ if (IS_ERR(raw)) return PTR_ERR(raw); - ret = __do_load_post_body_fmt3(post, raw); + switch (post->fmt) { + case 2: + ret = __do_load_post_body_fmt2(post, raw); + break; + case 3: + ret = __do_load_post_body_fmt3(post, raw); + break; + } str_putref(raw);