Problem with CMarkDown

I have a question about how to use CMarkdown. I looked at/used the demo/blog example and with the following code in a _view file:

	<div class="portlet-content">

	<?php $this->beginWidget('CMarkdown', array('purifyOutput'=>true));

			echo trim($data->Announcement);




and the output is:

	<div class="portlet-content">

	<p>This site is under construction. If you have any thoughts or problems, let me know.</p>


The problem is the <p></p> tags. I would like to output this information in a <li></li> set of tags.

Where is the <p> set coming from? Is it from the beginWidget()?

How do I change to <li>? Would I use beginContent()?

The docs are indicate it can be used in various ways, but is lacking in how, but I THINK I saw the possiblility of beginContent() or something else. Thank you.

It’s coming from markdown itself. Here is the syntax:

What is comming from markdown? The <p></p> tag? I don’t think I have anything that should cause it.

Yes. Markdown always wraps your paragraphs with <p>. If you don’t want any extra markup, why just not to use purifier without markdown or even just use CHtml::encode.

Does purififier evaluate the Markdown code? CHtml::encode() just does a htmlspecialentities as far as I know.

Also how would I use purifier? I’ve only seen it as an array item. a short code snippet to point me in the write direction would be greatly appreciated.


No, purifier does not evaluate markdown and yes, encode escapes all HTML and it’s enough to just output “This site is under construction. If you have any thoughts or problems, let me know.” in a safe way. If there is HTML, you can use purifier like this:

$p = new CHtmlPurifier();

$text = $p->purify($text);

Thanks for the information, but I have two more questions:

1-How does CHtmlPurifier() differ from CHtml::encode?

2-How can I clean CMarkDown() encoded text for use in some tag of my choice (ie <li>)?

  1. Yes, it does:

  2. You don’t have to clean it. Markdown translates to valid HTML and you can paste this HTML into li. <p> is really necessary since, for example, you can have two paragraphs.

  1. I guess I mis-typed :)

What I was getting at is in markdown Markdown equates to <i>Markdown</i>. Can I get that from HTMLPufirier?

No, you can’t. HTMLPufirier cleans up malicious code and nothing more.