A couple of days ago, I decided to write something on my blog based on Yii. By using Markdown syntax I was able to format my tutorials. However, the code block in my tutorial could not be displayed properly. If you have the same problem as mine, here’s a solution I figured out.

  1. Make sure you have the latest Yii v1.1.7.
  2. Make sure you insert a new line before your code block.
  3. Instead of using widget with CMarkdown, use CMarkdownParser.

In protected/views/post/_view.php replace the code:

    $this->beginWidget('CMarkdown', array('purifyOutput'=>false));
    echo $data->content;


    $markdownParser = new CMarkdownParser;  
    echo $markdownParser->safeTransform($data->content);

Here’s an example html code block that works for me:


Hope that helps.