Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
584 views
in Plugins by
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

1 Answer

+2 votes
by
edited by

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
);
by
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.
Look for the read_post function.

As soon as the user hits Submit to their post, the HTML immediately gets destroyed.
by
Added this feature to TinymceWrapper plugin admin options:
Disable/strip HTML in Markdown at [x] Viewer or [x] Editor level
...