/**
  * Render a Tweet
  * @param array $tweet
  */
 public function render($tweet)
 {
     $this->tag->addAttribute('id', "tweet-" . $tweet['id']);
     $this->tag->addAttribute('class', 'tweet_content');
     $content = $tweet['text'];
     //Replace links
     $content = preg_replace('%[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]%', '<a href="${0}" target="_blank">${0}</a>', $content);
     //Replace @usernames at the start of the content (indicating reply)
     //$content = preg_replace('/^@[a-zA-Z0-9]+/e',"'To <a href=\"http://www.twitter.com/'.substr('\\0',1).'\" class=\"tweet_username\" target=\"_blank\">\\0</a>: '",$content);
     //Replace @usernames with links to their profiles
     //$content = preg_replace('/ @[a-zA-Z0-9]+/e',"'<a href=\"http://www.twitter.com/'.substr('\\0',2).'\" class=\"tweet_username\" target=\"_blank\">\\0</a>'",$content);
     //Replace #hashtags with links to their searchpages
     $content = preg_Replace('/(^| )#[a-zA-Z0-9]+/e', "'<a href=\"http://www.twitter.com/#search?q=%23'.trim(str_replace('#','','\\0')).'\" class=\"tweet_hashtag\" target=\"_blank\">\\0</a>'", $content);
     $this->tag->setContent($content);
     return $this->tag->render();
 }
$out = '<?xml version="1.0" encoding="UTF-8"?>
<questestinterop xmlns="http://www.imsglobal.org/xsd/ims_qtiasiv1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/ims_qtiasiv1p2 http://www.imsglobal.org/xsd/ims_qtiasiv1p2p1.xsd">
  <assessment ident="' . $chp . '" title="' . $title . '">
    <qtimetadata>
      <qtimetadatafield>
        <fieldlabel>cc_maxattempts</fieldlabel>
        <fieldentry>1</fieldentry>
      </qtimetadatafield>
    </qtimetadata>
    <section ident="root_section">';
//$html = str_replace("\r\n","\n",$html);
//$html = str_replace("\r","\n",$html);
$html = str_replace('&nbsp;', '', $html);
$html = preg_replace('/<p[^>]*>\\s*<\\/p>/', '', $html);
$html = preg_replace('/<p[^>]*>(.*?)<\\/p>/', '$1', $html);
$html = preg_Replace('/<br\\s+\\/>/', '', $html);
phpQuery::newDocumentHTML('<div class="bigwrap">' . $html . '</div>');
$pts = pq("div.bigwrap > ol > li");
foreach ($pts as $c => $pt) {
    $top = pq($pt)->clone();
    pq($top)->find("ol")->remove();
    $prompt = pq($top)->html();
    //this will get properly nested sub-lists
    $li = pq($pt)->find("ol li");
    if (count($li) == 0) {
        //this will catch tinymce's improperly nested sub-lists
        $li = pq($pt)->next("ol")->find("li");
    }
    if (count($li) < 2) {
        continue;
    }