# Markdown Running HTML

+1 vote
321 views
in Plugins
Hello sir! i am using Markdown Editor to save question on my website..but when it showing then it is running code suppose user write code

<font color="red">I am Red</font>

It is showing "i am Red" in red color

i hope you will understand

edited

Do you mean that you DO NOT want Q2A to SHOW HTML in the 'frontend'  if user entered the HTML in Markdown Editor?

You need to edit the plugin's viewer file that is passing your content through the Markdown PHP Parser. It is this viewer file that is "SHOWING" or technically "VIEWING" that Markdown HTML.

In the example-viewer.php file, add some basic PHP code to strip all HTML tags just before passing content to Parser.

I don't know the editor you are using but if you use my new TinymceWrapper editor, this feature will be toggleable from Admin plugin options.

^^ I prefer the above option ^^

But if you prefer to nuke the HTML from the editor input, use this:

In qa-examplePlugin.php
Find  public function read_post($fieldname) The result: <font color="red">I am Red</font> = I am Red (no red color) $stripTags = 1;
if (!empty($stripTags)) { // Markdown links, that looks like tag$input = preg_replace('#<(.*?(://|@).*?)>#', '&lt;$1&gt;', qa_post_text($fieldname));
// Strip tags
if (is_numeric($stripTags)) {$stripTags = '';
} else {
$tmp = explode(',',$stripTags);
$tmp2 = array(); foreach ($tmp as $v) {$tmp2[] = '<' . trim($v, '<> ') . '>'; }$stripTags = implode($tmp2); }$input = strip_tags($input,$stripTags);
}
return array(
'format' => $format, 'content' =>$input  // destroys all HTML tags upon submit
);
But, if you want to kill the HTML code completely so that it is not even in your database, you have to strip the HTML in the qa-example.php file of your plugin.