當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sequence::setRawHTML方法代碼示例

本文整理匯總了PHP中Sequence::setRawHTML方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sequence::setRawHTML方法的具體用法?PHP Sequence::setRawHTML怎麽用?PHP Sequence::setRawHTML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sequence的用法示例。


在下文中一共展示了Sequence::setRawHTML方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parse

 public function parse(\DOMNode $node)
 {
     $this->doc = $node->ownerDocument;
     $sequence = [];
     $sequence = $this->parseHead($sequence, $node);
     $sequence = $this->parseBeginning($sequence, $node);
     // detail rows contain all the tagged stuff (be extra strict with selecting those, as they can contain
     // a lot of different markup)
     $detailsRows = $this->xpath($node, 'tr[5]/td/table/tr');
     assert(count($detailsRows) > 0, 'sequence must have at least one detail row');
     foreach ($detailsRows as $detailsRow) {
         $type = strtolower($this->text($detailsRow, 'td[2]/font', 1, true));
         $lineNodes = $this->xpath($detailsRow, 'td[3]//tt');
         $lines = [];
         foreach ($lineNodes as $lineNode) {
             $html = $this->toHTML($lineNode);
             // trim the surrounding <tt> tag
             $html = preg_replace('#^<tt>(.*?)</tt>$#', '$1', $html);
             $lines[] = ['text' => $this->toText($lineNode), 'html' => $html, 'node' => $lineNode];
         }
         // just in case we hit something that has no valid lines
         if (count($lines) > 0) {
             switch ($type) {
                 case 'offset':
                     $sequence = $this->parseOffset($sequence, $lines);
                     break;
                 case 'status':
                     $sequence = $this->parseStatus($sequence, $lines);
                     break;
                 case 'author':
                     $sequence = $this->parseAuthor($sequence, $lines);
                     break;
                 case 'keyword':
                     $sequence = $this->parseKeyword($sequence, $lines);
                     break;
                 case 'comments':
                     $sequence = $this->parseComments($sequence, $lines);
                     break;
                 case 'references':
                     $sequence = $this->parseReferences($sequence, $lines);
                     break;
                 case 'links':
                     $sequence = $this->parseLinks($sequence, $lines);
                     break;
                 case 'formula':
                     $sequence = $this->parseFormula($sequence, $lines);
                     break;
                 case 'example':
                     $sequence = $this->parseExample($sequence, $lines);
                     break;
                 case 'maple':
                     $sequence = $this->parseProgram($sequence, $lines, 'maple');
                     break;
                 case 'mathematica':
                     $sequence = $this->parseProgram($sequence, $lines, 'mathematica');
                     break;
                 case 'prog':
                     $sequence = $this->parseProgram($sequence, $lines, 'other');
                     break;
                 case 'crossrefs':
                     $sequence = $this->parseCrossrefs($sequence, $lines);
                     break;
                 case 'extensions':
                     $sequence = $this->parseExtensions($sequence, $lines);
                     break;
                 default:
                     trigger_error("Unknown {$type} found in {$sequence['identification']}[OEIS].", E_USER_WARNING);
                     $sequence['junk'][$type] = $lines;
             }
         }
     }
     $sequence = new Sequence($sequence);
     // backup, in case we improve parsing later on and want to skip crawling everything again
     $sequence->setRawHTML($this->toHTML($node));
     return $sequence;
 }
開發者ID:xrstf,項目名稱:oeis-api,代碼行數:76,代碼來源:Parser.php


注:本文中的Sequence::setRawHTML方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。