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


PHP TexyHtml類代碼示例

本文整理匯總了PHP中TexyHtml的典型用法代碼示例。如果您正苦於以下問題:PHP TexyHtml類的具體用法?PHP TexyHtml怎麽用?PHP TexyHtml使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TexyHtml類的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: 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

示例9: 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

示例10: 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

示例11: 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

示例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
 */
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

示例13: solve

 /**
  * Finish invocation.
  *
  * @param  TexyHandlerInvocation  handler invocation
  * @param  TexyLink
  * @param  TexyHtml|string
  * @return TexyHtml|string
  */
 public function solve($invocation, $link, $content = NULL)
 {
     if ($link->URL == NULL) {
         return $content;
     }
     $tx = $this->texy;
     $el = TexyHtml::el('a');
     if (empty($link->modifier)) {
         $nofollow = $popup = FALSE;
     } else {
         $nofollow = isset($link->modifier->classes['nofollow']);
         $popup = isset($link->modifier->classes['popup']);
         unset($link->modifier->classes['nofollow'], $link->modifier->classes['popup']);
         $el->attrs['href'] = NULL;
         // trick - move to front
         $link->modifier->decorate($tx, $el);
     }
     if ($link->type === TexyLink::IMAGE) {
         // image
         $el->attrs['href'] = Texy::prependRoot($link->URL, $tx->imageModule->linkedRoot);
         if ($this->imageClass) {
             $el->attrs['class'][] = $this->imageClass;
         } else {
             $el->attrs['onclick'] = $this->imageOnClick;
         }
     } else {
         $el->attrs['href'] = Texy::prependRoot($link->URL, $this->root);
         // rel="nofollow"
         if ($nofollow || $this->forceNoFollow && strpos($el->attrs['href'], '//') !== FALSE) {
             $el->attrs['rel'] = 'nofollow';
         }
     }
     // popup on click
     if ($popup) {
         $el->attrs['onclick'] = $this->popupOnClick;
     }
     if ($content !== NULL) {
         $el->add($content);
     }
     $tx->summary['links'][] = $el->attrs['href'];
     return $el;
 }
開發者ID:eduardobenito10,項目名稱:jenkins-php-quickstart,代碼行數:50,代碼來源:TexyLinkModule.php

示例14: patternItem

 /**
  * Callback for single list item.
  *
  * @param  TexyBlockParser
  * @param  string  bullet type
  * @param  string  left space
  * @param  string  html tag
  * @return TexyHtml|FALSE
  */
 public function patternItem($parser, $bullet, $indented, $tag)
 {
     $tx = $this->texy;
     $spacesBase = $indented ? '\\ {1,}' : '';
     $patternItem = "#^\n?({$spacesBase}){$bullet}\\ *(\\S.*)?" . TEXY_MODIFIER_H . "?()\$#mAUu";
     // first line with bullet
     $matches = NULL;
     if (!$parser->next($patternItem, $matches)) {
         return FALSE;
     }
     list(, $mIndent, $mContent, $mMod) = $matches;
     //    [1] => indent
     //    [2] => ...
     //    [3] => .(title)[class]{style}<>
     $elItem = TexyHtml::el($tag);
     $mod = new TexyModifier($mMod);
     $mod->decorate($tx, $elItem);
     // next lines
     $spaces = '';
     $content = ' ' . $mContent;
     // trick
     while ($parser->next('#^(\\n*)' . $mIndent . '(\\ {1,' . $spaces . '})(.*)()$#Am', $matches)) {
         list(, $mBlank, $mSpaces, $mContent) = $matches;
         //    [1] => blank line?
         //    [2] => spaces
         //    [3] => ...
         if ($spaces === '') {
             $spaces = strlen($mSpaces);
         }
         $content .= "\n" . $mBlank . $mContent;
     }
     // parse content
     $elItem->parseBlock($tx, $content, TRUE);
     if (isset($elItem[0]) && $elItem[0] instanceof TexyHtml) {
         $elItem[0]->setName(NULL);
     }
     return $elItem;
 }
開發者ID:vanessaforney,項目名稱:VanessasDogSitting,代碼行數:47,代碼來源:TexyListModule.php

示例15: texyBlockHandler

 static function texyBlockHandler($invocation, $blocktype, $content, $lang, $modifier)
 {
     if ($blocktype !== 'block/code') {
         return $invocation->proceed();
     }
     $texy = $invocation->getTexy();
     if ($lang == 'html') {
         $lang = 'html4strict';
     } elseif ($lang == 'yaml') {
         $lang = 'python';
     }
     $content = Texy::outdent($content);
     $geshi = new GeSHi($content, $lang);
     // 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->enable_keyword_links(false);
     $geshi->set_overall_style('');
     $geshi->set_overall_class('code');
     // save generated 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:xtgss,項目名稱:qeephp2_x,代碼行數:34,代碼來源:abstract.php


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