Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.0k views
in Plugins by

I have my Markdown plugin installed and working fine on the site, but in a page plugin when I try to load the viewer I get an error message: "[no viewer found for format: markdown]". I am using this code:

$viewer = qa_load_viewer( $content, 'html' );
$html = '<div>' . $viewer->get_html( $content, $format, $options ) . '</div>';

Here, $content is the content field from qa_posts and $format is its corresponding format field (which is 'markdown'). Did I miss something?

Q2A version: 1.5

1 Answer

0 votes
by

What happened is that you loaded the viewer for HTML content and then tried to get it to display the markdown content. You probably ust want to use qa_viewer_html(...) from qa-app-format.php, otherwise pass $format in qa_load_viewer(...) instead of 'html'.

by
OK thanks I will check it out. The problem with passing $format into qa_load_viewer is that I only do that once, then call get_html inside a loop, so the format there could be different each time. I thought the parameter to qa_load_viewer was supposed to be the final output format rather than the storage format.
by
Tested and that function works fine. Looks like basically does the same as the code above, but passing the posts's format into the viewer initialisation too.
...