当前位置: 首页>>代码示例>>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;未经允许,请勿转载。