Clean up post formatting

Deleted the old post rendering code and added new formatting functions with unit tests.