Using ob_start and ob_get_clean with wordpress shortcode

After examining the code using developer tools, I was able to figure out the problem. Code was being wrapped in the pre tags which were causing the code to break its proper structure.

Found the solution for the pre tags issue here which solved the problem.