Texy\HtmlElement::parseLine PHP Méthode

parseLine() final public méthode

Parses text as single line.
final public parseLine ( Texy $texy, $s ) : void
$texy Texy
Résultat void
    public final function parseLine(Texy $texy, $s)
    {
        $parser = new LineParser($texy, $this);
        $parser->parse($s);
        return $parser;
    }

Usage Example

Exemple #1
0
 /**
  * Finish invocation.
  * @return Texy\HtmlElement|FALSE
  */
 public function solve(Texy\HandlerInvocation $invocation, $content, Texy\Modifier $mod = NULL)
 {
     $texy = $this->texy;
     // find hard linebreaks
     if ($texy->mergeLines) {
         // ....
         // ... => \r means break line
         $content = Regexp::replace($content, '#\\n +(?=\\S)#', "\r");
     } else {
         $content = Regexp::replace($content, '#\\n#', "\r");
     }
     $el = new Texy\HtmlElement('p');
     $el->parseLine($texy, $content);
     $content = $el->getText();
     // string
     // check content type
     // block contains block tag
     if (strpos($content, $texy::CONTENT_BLOCK) !== FALSE) {
         $el->setName(NULL);
         // ignores modifier!
         // block contains text (protected)
     } elseif (strpos($content, $texy::CONTENT_TEXTUAL) !== FALSE) {
         // leave element p
         // block contains text
     } elseif (preg_match('#[^\\s' . Texy\Patterns::MARK . ']#u', $content)) {
         // leave element p
         // block contains only replaced element
     } elseif (strpos($content, $texy::CONTENT_REPLACED) !== FALSE) {
         $el->setName($texy->nontextParagraph);
         // block contains only markup tags or spaces or nothing
     } else {
         // if {ignoreEmptyStuff} return FALSE;
         if (!$mod) {
             $el->setName(NULL);
         }
     }
     if ($el->getName()) {
         // apply modifier
         if ($mod) {
             $mod->decorate($texy, $el);
         }
         // add <br />
         if (strpos($content, "\r") !== FALSE) {
             $key = $texy->protect('<br />', $texy::CONTENT_REPLACED);
             $content = str_replace("\r", $key, $content);
         }
     }
     $content = strtr($content, "\r\n", '  ');
     $el->setText($content);
     return $el;
 }
All Usage Examples Of Texy\HtmlElement::parseLine