当前位置: 首页>>代码示例>>PHP>>正文


PHP TexyHtml::el方法代码示例

本文整理汇总了PHP中TexyHtml::el方法的典型用法代码示例。如果您正苦于以下问题:PHP TexyHtml::el方法的具体用法?PHP TexyHtml::el怎么用?PHP TexyHtml::el使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TexyHtml的用法示例。


在下文中一共展示了TexyHtml::el方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: blockHandler

/**
 * User handler for code block
 *
 * @param TexyHandlerInvocation  handler invocation
 * @param string  block type
 * @param string  text to highlight
 * @param string  language
 * @param TexyModifier modifier
 * @return TexyHtml
 */
function blockHandler($invocation, $blocktype, $content, $lang, $modifier)
{
    if ($blocktype !== 'block/code') {
        return $invocation->proceed();
    }
    $lang = strtoupper($lang);
    if ($lang == 'JAVASCRIPT') {
        $lang = 'JS';
    }
    $fshl = new fshlParser('HTML_UTF8', P_TAB_INDENT);
    if (!$fshl->isLanguage($lang)) {
        return $invocation->proceed();
    }
    $texy = $invocation->getTexy();
    $content = Texy::outdent($content);
    $content = $fshl->highlightString($lang, $content);
    $content = $texy->protect($content, Texy::CONTENT_BLOCK);
    $elPre = TexyHtml::el('pre');
    if ($modifier) {
        $modifier->decorate($texy, $elPre);
    }
    $elPre->attrs['class'] = strtolower($lang);
    $elCode = $elPre->create('code', $content);
    return $elPre;
}
开发者ID:jiripudil,项目名称:texy,代码行数:35,代码来源:demo-fshl.php

示例2: solve

 /**
  * Finish invocation.
  *
  * @param  TexyHandlerInvocation  handler invocation
  * @param  string
  * @param  TexyModifier
  *
  * @return TexyHtml
  */
 public function solve($invocation, $type, $modifier)
 {
     $el = TexyHtml::el('hr');
     $modifier->decorate($invocation->texy, $el);
     $class = $this->classes[$type[0]];
     if ($class && !isset($modifier->classes[$class])) {
         $el->attrs['class'][] = $class;
     }
     return $el;
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:19,代码来源:TexyHorizLineModule.php

示例3: pattern

	/**
	 * Callback for:.
	 *
	 *   > They went in single file, running like hounds on a strong scent,
	 *   and an eager light was in their eyes. Nearly due west the broad
	 *   swath of the marching Orcs tramped its ugly slot; the sweet grass
	 *   of Rohan had been bruised and blackened as they passed.
	 *   >:http://www.mycom.com/tolkien/twotowers.html
	 *
	 * @param  TexyBlockParser
	 * @param  array      regexp matches
	 * @param  string     pattern name
	 * @return TexyHtml|string|FALSE
	 */
	public function pattern($parser, $matches)
	{
		list(, $mMod, $mPrefix, $mContent) = $matches;
		//    [1] => .(title)[class]{style}<>
		//    [2] => spaces |
		//    [3] => ... / LINK

		$tx = $this->texy;

		$el = TexyHtml::el('blockquote');
		$mod = new TexyModifier($mMod);
		$mod->decorate($tx, $el);

		$content = '';
		$spaces = '';
		do {
			if ($mPrefix === ':') {
				$mod->cite = $tx->blockQuoteModule->citeLink($mContent);
				$content .= "\n";
			} else {
				if ($spaces === '') $spaces = max(1, strlen($mPrefix));
				$content .= $mContent . "\n";
			}

			if (!$parser->next("#^>(?:|(\\ {1,$spaces}|:)(.*))()$#mA", $matches)) break;

/*
			if ($mPrefix === '>') {
				$content .= $mPrefix . $mContent . "\n";
			} elseif ($mPrefix === ':') {
				$mod->cite = $tx->blockQuoteModule->citeLink($mContent);
				$content .= "\n";
			} else {
				if ($spaces === '') $spaces = max(1, strlen($mPrefix));
				$content .= $mContent . "\n";
			}
			if (!$parser->next("#^\\>(?:(\\>|\\ {1,$spaces}|:)(.*))?()$#mA", $matches)) break;
*/

			list(, $mPrefix, $mContent) = $matches;
		} while (TRUE);

		$el->attrs['cite'] = $mod->cite;
		$el->parseBlock($tx, $content, $parser->isIndented());

		// no content?
		if (!$el->count()) return FALSE;

		// event listener
		$tx->invokeHandlers('afterBlockquote', array($parser, $el, $mod));

		return $el;
	}
开发者ID:JanTvrdik,项目名称:StaticWeb,代码行数:67,代码来源:TexyBlockQuoteModule.php

示例4: codeBlockHandler

/**
 * Pattern handler for PHP & JavaScript block syntaxes
 *
 * @param TexyBlockParser
 * @param array      regexp matches
 * @param string     pattern name
 * @return TexyHtml|string|FALSE
 */
function codeBlockHandler($parser, $matches, $name)
{
    list($content) = $matches;
    $lang = $name === 'phpBlockSyntax' ? 'PHP' : 'HTML';
    $fshl = new fshlParser('HTML_UTF8', P_TAB_INDENT);
    $texy = $parser->getTexy();
    $content = $fshl->highlightString($lang, $content);
    $content = $texy->protect($content, Texy::CONTENT_BLOCK);
    $elPre = TexyHtml::el('pre');
    $elPre->attrs['class'] = strtolower($lang);
    $elCode = $elPre->create('code', $content);
    return $elPre;
}
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:21,代码来源:demo-fshl-alt.php

示例5: solve

 /**
  * Finish invocation.
  *
  * @param  TexyHandlerInvocation  handler invocation
  * @param  string
  * @param  TexyModifier|NULL
  * @return TexyHtml|FALSE
  */
 public function solve($invocation, $content, $mod)
 {
     $tx = $this->texy;
     // find hard linebreaks
     if ($tx->mergeLines) {
         // ....
         // ... => \r means break line
         $content = TexyRegexp::replace($content, '#\\n +(?=\\S)#', "\r");
     } else {
         $content = TexyRegexp::replace($content, '#\\n#', "\r");
     }
     $el = TexyHtml::el('p');
     $el->parseLine($tx, $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' . TexyPatterns::MARK . ']#u', $content)) {
         // leave element p
         // block contains only replaced element
     } elseif (strpos($content, Texy::CONTENT_REPLACED) !== FALSE) {
         $el->setName($tx->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($tx, $el);
         }
         // add <br />
         if (strpos($content, "\r") !== FALSE) {
             $key = $tx->protect('<br />', Texy::CONTENT_REPLACED);
             $content = str_replace("\r", $key, $content);
         }
     }
     $content = strtr($content, "\r\n", '  ');
     $el->setText($content);
     return $el;
 }
开发者ID:ppwalks33,项目名称:cleansure,代码行数:59,代码来源:TexyParagraphModule.php

示例6: userBlockHandler

/**
 * Pattern handler for block syntaxes
 *
 * @param TexyBlockParser
 * @param array      regexp matches
 * @param string     pattern name (myBlockSyntax1)
 * @return TexyHtml|string|FALSE
 */
function userBlockHandler($parser, $matches, $name)
{
    list(, $mTag, $mText) = $matches;
    $texy = $parser->getTexy();
    // create element
    if ($mTag === 'perex') {
        $el = TexyHtml::el('div');
        $el->attrs['class'][] = 'perex';
    } else {
        $el = TexyHtml::el($mTag);
    }
    // create content
    $el->parseLine($texy, $mText);
    return $el;
}
开发者ID:jiripudil,项目名称:texy,代码行数:23,代码来源:demo.php

示例7: figureHandler

/**
 * @param TexyHandlerInvocation  handler invocation
 * @param TexyImage
 * @param TexyLink
 * @param string
 * @param TexyModifier
 * @return TexyHtml|string|FALSE
 */
function figureHandler($invocation, $image, $link, $content, $modifier)
{
    // finish invocation by default way
    $el = $invocation->proceed();
    // change div -> dl
    $el->setName('dl');
    // change p -> dd
    $el[1]->setName('dd');
    // wrap img into dt
    $img = $el[0];
    unset($el[0]);
    $dt = TexyHtml::el('dt');
    $dt->add($img);
    $el->insert(0, $dt);
    return $el;
}
开发者ID:ppwalks33,项目名称:cleansure,代码行数:24,代码来源:demo.php

示例8: patternTag

 /**
  * Callback for: <tag attr="...">.
  *
  * @param  TexyLineParser
  * @param  array      regexp matches
  * @param  string     pattern name
  * @return TexyHtml|string|FALSE
  */
 public function patternTag($parser, $matches)
 {
     list(, $mEnd, $mTag, $mAttr, $mEmpty) = $matches;
     //    [1] => /
     //    [2] => tag
     //    [3] => attributes
     //    [4] => /
     $tx = $this->texy;
     $isStart = $mEnd !== '/';
     $isEmpty = $mEmpty === '/';
     if (!$isEmpty && substr($mAttr, -1) === '/') {
         // uvizlo v $mAttr?
         $mAttr = substr($mAttr, 0, -1);
         $isEmpty = TRUE;
     }
     // error - can't close empty element
     if ($isEmpty && !$isStart) {
         return FALSE;
     }
     // error - end element with atttrs
     $mAttr = trim(strtr($mAttr, "\n", ' '));
     if ($mAttr && !$isStart) {
         return FALSE;
     }
     $el = TexyHtml::el($mTag);
     if ($isStart) {
         // parse attributes
         $matches2 = NULL;
         preg_match_all('#([a-z0-9:-]+)\\s*(?:=\\s*(\'[^\']*\'|"[^"]*"|[^\'"\\s]+))?()#isu', $mAttr, $matches2, PREG_SET_ORDER);
         foreach ($matches2 as $m) {
             $key = strtolower($m[1]);
             $value = $m[2];
             if ($value == NULL) {
                 $el->attrs[$key] = TRUE;
             } elseif ($value[0] === '\'' || $value[0] === '"') {
                 $el->attrs[$key] = Texy::unescapeHtml(substr($value, 1, -1));
             } else {
                 $el->attrs[$key] = Texy::unescapeHtml($value);
             }
         }
     }
     $res = $tx->invokeAroundHandlers('htmlTag', $parser, array($el, $isStart, $isEmpty));
     if ($res instanceof TexyHtml) {
         return $tx->protect($isStart ? $res->startTag() : $res->endTag(), $res->getContentType());
     }
     return $res;
 }
开发者ID:jiripudil,项目名称:texy,代码行数:55,代码来源:TexyHtmlModule.php

示例9: wiki_texy_InlineHandler

function wiki_texy_InlineHandler($parser, $matches, $name)
{
    list(, $mContent, $mMod) = $matches;
    $texy = $parser->getTexy();
    $tag = 'a';
    $el = TexyHtml::el($tag);
    $mod = new TexyModifier($mMod);
    $mod->decorate($texy, $el);
    if ($name == 'wikilink') {
        $el->attrs['href'] = '?page=' . urlencode($mContent);
    } else {
        $el->attrs['href'] = $mContent;
    }
    $el->attrs['class'] = $name;
    $el->setText($mContent);
    $parser->again = TRUE;
    return $el;
}
开发者ID:Harvie,项目名称:haiwiki,代码行数:18,代码来源:texy.mod.php

示例10: newReferenceHandler

/**
 * User handler for unknown reference
 *
 * @param TexyHandlerInvocation  handler invocation
 * @param string   [refName]
 * @return TexyHtml|string
 */
function newReferenceHandler($parser, $refName)
{
    $names = array('Me', 'Punkrats', 'Servats', 'Bonifats');
    if (!isset($names[$refName])) {
        return FALSE;
    }
    // it's not my job
    $name = $names[$refName];
    $el = TexyHtml::el('a');
    $el->attrs['href'] = '#comm-' . $refName;
    // set link destination
    $el->attrs['class'][] = 'comment';
    // set class name
    $el->attrs['rel'] = 'nofollow';
    // enable rel="nofollow"
    $el->setText("[{$refName}] {$name}:");
    // set link label (with Texy formatting)
    return $el;
}
开发者ID:ppwalks33,项目名称:cleansure,代码行数:26,代码来源:demo.php

示例11: solve

 /**
  * Finish invocation.
  *
  * @param  TexyHandlerInvocation  handler invocation
  * @param  string
  * @param  string
  * @return TexyHtml|FALSE
  */
 public function solve($invocation, $emoticon, $raw)
 {
     $tx = $this->texy;
     $file = $this->icons[$emoticon];
     $el = TexyHtml::el('img');
     $el->attrs['src'] = Texy::prependRoot($file, $this->root === NULL ? $tx->imageModule->root : $this->root);
     $el->attrs['alt'] = $raw;
     $el->attrs['class'][] = $this->class;
     // file path
     $file = rtrim($this->fileRoot === NULL ? $tx->imageModule->fileRoot : $this->fileRoot, '/\\') . '/' . $file;
     if (@is_file($file)) {
         // intentionally @
         $size = @getImageSize($file);
         // intentionally @
         if (is_array($size)) {
             $el->attrs['width'] = $size[0];
             $el->attrs['height'] = $size[1];
         }
     }
     $tx->summary['images'][] = $el->attrs['src'];
     return $el;
 }
开发者ID:anagio,项目名称:woocommerce,代码行数:30,代码来源:TexyEmoticonModule.php

示例12: blockHandler

 /**
  * User handler for code block.
  *
  * @param  TexyHandlerInvocation  handler invocation
  * @param  string  block type
  * @param  string  text to highlight
  * @param  string  language
  * @param  TexyModifier modifier
  * @return TexyHtml
  */
 public static function blockHandler($invocation, $blocktype, $content, $lang, $modifier)
 {
     if (preg_match('#^block/(php|neon|javascript|js|css|html|htmlcb|latte)$#', $blocktype)) {
         list(, $lang) = explode('/', $blocktype);
     } elseif ($blocktype !== 'block/code') {
         return $invocation->proceed();
     }
     $lang = strtolower($lang);
     if ($lang === 'htmlcb' || $lang === 'latte') {
         $lang = 'html';
     } elseif ($lang === 'javascript') {
         $lang = 'js';
     }
     if ($lang === 'html') {
         $langClass = 'FSHL\\Lexer\\LatteHtml';
     } elseif ($lang === 'js') {
         $langClass = 'FSHL\\Lexer\\LatteJavascript';
     } else {
         $langClass = 'FSHL\\Lexer\\' . ucfirst($lang);
     }
     $texy = $invocation->getTexy();
     $content = Texy::outdent($content);
     if (class_exists($langClass)) {
         $fshl = new FSHL\Highlighter(new FSHL\Output\Html(), FSHL\Highlighter::OPTION_TAB_INDENT);
         $content = $fshl->highlight($content, new $langClass());
     } else {
         $content = htmlSpecialChars($content);
     }
     $content = $texy->protect($content, Texy::CONTENT_BLOCK);
     $elPre = TexyHtml::el('pre');
     if ($modifier) {
         $modifier->decorate($texy, $elPre);
     }
     $elPre->attrs['class'] = 'src-' . strtolower($lang);
     $elCode = $elPre->create('code', $content);
     return $elPre;
 }
开发者ID:JanTvrdik,项目名称:planette,代码行数:47,代码来源:TexyFactory.php

示例13: blockHandler

/**
 * User handler for code block
 *
 * @param TexyHandlerInvocation  handler invocation
 * @param string  block type
 * @param string  text to highlight
 * @param string  language
 * @param TexyModifier modifier
 * @return TexyHtml
 */
function blockHandler($invocation, $blocktype, $content, $lang, $modifier)
{
    if ($blocktype !== 'block/code') {
        return $invocation->proceed();
    }
    $texy = $invocation->getTexy();
    global $geshiPath;
    if ($lang == 'html') {
        $lang = 'html4strict';
    }
    $content = Texy::outdent($content);
    $geshi = new GeSHi($content, $lang, $geshiPath . 'geshi/');
    // GeSHi could not find the language
    if ($geshi->error) {
        return $invocation->proceed();
    }
    // do syntax-highlighting
    $geshi->set_encoding('UTF-8');
    $geshi->set_header_type(GESHI_HEADER_PRE);
    $geshi->enable_classes();
    $geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true);
    $geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true);
    $geshi->set_code_style('color: #000020;', 'color: #000020;');
    $geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
    $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
    // save generated stylesheet
    $texy->styleSheet .= $geshi->get_stylesheet();
    $content = $geshi->parse_code();
    // check buggy GESHI, it sometimes produce not UTF-8 valid code :-((
    $content = iconv('UTF-8', 'UTF-8//IGNORE', $content);
    // protect output is in HTML
    $content = $texy->protect($content, Texy::CONTENT_BLOCK);
    $el = TexyHtml::el();
    $el->setText($content);
    return $el;
}
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:46,代码来源:demo-geshi.php

示例14: process

 /**
  * Converts document in Texy! to (X)HTML code.
  *
  * @param  string   input text
  * @param  bool     is single line?
  * @return string   output HTML code
  */
 public function process($text, $singleLine = FALSE)
 {
     if ($this->processing) {
         throw new RuntimeException('Processing is in progress yet.');
     }
     // initialization
     $this->marks = array();
     $this->processing = TRUE;
     // speed-up
     if (is_array($this->allowedClasses)) {
         $this->_classes = array_flip($this->allowedClasses);
     } else {
         $this->_classes = $this->allowedClasses;
     }
     if (is_array($this->allowedStyles)) {
         $this->_styles = array_flip($this->allowedStyles);
     } else {
         $this->_styles = $this->allowedStyles;
     }
     // convert to UTF-8 (and check source encoding)
     $text = TexyUtf::toUtf($text, $this->encoding);
     if ($this->removeSoftHyphens) {
         $text = str_replace("­", '', $text);
     }
     // standardize line endings and spaces
     $text = self::normalize($text);
     // replace tabs with spaces
     $this->tabWidth = max(1, (int) $this->tabWidth);
     while (strpos($text, "\t") !== FALSE) {
         $text = TexyRegexp::replace($text, '#^([^\\t\\n]*+)\\t#mU', array($this, 'tabCb'));
     }
     // user before handler
     $this->invokeHandlers('beforeParse', array($this, &$text, $singleLine));
     // select patterns
     $this->_linePatterns = $this->linePatterns;
     $this->_blockPatterns = $this->blockPatterns;
     foreach ($this->_linePatterns as $name => $foo) {
         if (empty($this->allowed[$name])) {
             unset($this->_linePatterns[$name]);
         }
     }
     foreach ($this->_blockPatterns as $name => $foo) {
         if (empty($this->allowed[$name])) {
             unset($this->_blockPatterns[$name]);
         }
     }
     // parse Texy! document into internal DOM structure
     $this->DOM = TexyHtml::el();
     if ($singleLine) {
         $this->DOM->parseLine($this, $text);
     } else {
         $this->DOM->parseBlock($this, $text);
     }
     // user after handler
     $this->invokeHandlers('afterParse', array($this, $this->DOM, $singleLine));
     // converts internal DOM structure to final HTML code
     $html = $this->DOM->toHtml($this);
     // created by TexyParagraphModule and then protected
     $html = str_replace("\r", "\n", $html);
     $this->processing = FALSE;
     return TexyUtf::utf2html($html, $this->encoding);
 }
开发者ID:xxdavid,项目名称:texy,代码行数:69,代码来源:Texy.php

示例15: blockHandler

 /**
  * User handler for code block
  *
  * @param TexyHandlerInvocation  handler invocation
  * @param string  block type
  * @param string  text to highlight
  * @param string  language
  * @param TexyModifier modifier
  * @return TexyHtml
  */
 public function blockHandler($invocation, $blocktype, $content, $lang, $modifier)
 {
     /** @var \Texy $texy */
     $texy = $invocation->getTexy();
     $content = \Texy::outdent($content);
     $lexerData = $this->resolveLexer($blocktype);
     $lexer = $this->getLexerInstance($lexerData['name']);
     $highlighter = $this->getHighlighter($lexerData['countLines']);
     if ($lexer !== false) {
         $content = $highlighter->highlight($content, $lexer);
     } else {
         $content = htmlspecialchars($content);
     }
     $content = $texy->protect($content, \Texy::CONTENT_BLOCK);
     $elPre = \TexyHtml::el('pre');
     if ($modifier) {
         $modifier->decorate($texy, $elPre);
     }
     $elPre->attrs['class'] = mb_strtolower($this->getLanguage($blocktype));
     $elPre->create('code', $content);
     return $elPre;
 }
开发者ID:blitzik,项目名称:CMS,代码行数:32,代码来源:TexyFactory.php


注:本文中的TexyHtml::el方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。