本文整理汇总了PHP中SmartyPants函数的典型用法代码示例。如果您正苦于以下问题:PHP SmartyPants函数的具体用法?PHP SmartyPants怎么用?PHP SmartyPants使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SmartyPants函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
function apply($text)
{
require_once 'classMarkdown.php';
$markdown = new MarkdownExtra_Parser();
$text = $markdown->transform($text);
return SmartyPants($text);
}
示例2: filter
public function filter($text)
{
if (Options::get('typogrify__do_amp')) {
$text = amp($text);
}
if (Options::get('typogrify__do_widont')) {
$text = widont($text);
}
if (Options::get('typogrify__do_smartypants')) {
// Standard options plus convert_quot ('w') to
// convert " entities, that Habari might
// already have converted '"' characters into.
$text = SmartyPants($text, "qbdew");
}
if (Options::get('typogrify__do_caps')) {
$text = caps($text);
}
if (Options::get('typogrify__do_initial_quotes')) {
$text = initial_quotes($text);
}
if (Options::get('typogrify__do_guillemets')) {
$text = initial_quotes($text, true);
}
if (Options::get('typogrify__do_dash')) {
$text = dash($text);
}
return $text;
}
示例3: TextToHTML
function TextToHTML($string, $stringLanguage = false)
{
global $_JAM;
// Look for Markdown preference
if ($_JAM->projectConfig['useMarkdown']) {
require_once 'engine/libraries/smartypants.php';
require_once 'engine/libraries/markdown.php';
return SmartyPants(Markdown($string));
}
// First find backticked portions and store them for later use
$backtickmatch = '{`([^`]*)`}u';
preg_match_all($backtickmatch, $string, $metaFillOutArray, PREG_PATTERN_ORDER);
// Only index 1 is suitable for use
$fillOutArray = $metaFillOutArray[1];
// Replace matches with placeholders
$string = preg_replace($backtickmatch, '%PLACEHOLDER', $string);
$match = array('{\\r}u', '{^([^\\n]+)$}mu', '{<p>-(=)+-</p>}u', '{<p>([^\\n]+)</p>[\\n\\s]*<p>-*</p>}u', '{<p>[-·•]\\s?([^\\n]+)</p>(\\n{1}|$)}u', '{</ul>\\n<ul>}u', '{<p>(\\d)\\. ([^\\n]+)</p>(\\n{1}|$)}u', '{</ol>\\n<ol type="1" start="\\d">}u', '{</p>\\n<p>([^\\t])}u', "{(/?)>\\[([^\\s=>\\]]*)=([^\\s>\\]]*)\\]}u", '{<p>%PLACEHOLDER</p>}u');
$replace = array('', e('p', '$1'), e('hr'), e('h2', '$1'), e('ul', e('li', '$1')) . "\n", "\n", e('ol', array('type' => 1, 'start' => '$1'), e('li', '$2')) . "\n", "\n", e('br') . "\n\$1", ' $2="$3"$1>', '%PLACEHOLDER');
$smartizedString = TextRenderer::SmartizeText($string, $language);
$HTMLString = preg_replace($match, $replace, $smartizedString);
// Reinsert backticked portions
while ($fillout = array_shift($fillOutArray)) {
$HTMLString = preg_replace('{%PLACEHOLDER}u', $fillout, $HTMLString, 1);
}
return $HTMLString;
}
示例4: execute_smartypants
function execute_smartypants($data)
{
static $smartypants;
if (!$smartypants) {
require IXG_PATH_PREFIX . "pipes/engines/smartypants/smartypants.php";
$smartypants = true;
}
return SmartyPants($data);
}
示例5: TextileThis
function TextileThis($text, $lite = '', $encode = '')
{
if ($lite == '' && $encode == '') {
$text = Markdown($text);
}
if (function_exists('SmartyPants')) {
$text = SmartyPants($text);
}
return $text;
}
示例6: run
function run($string)
{
if (!function_exists('Markdown')) {
include_once EXTENSIONS . '/markdown/lib/markdown_extra.php';
}
if (!function_exists('SmartyPants')) {
include_once EXTENSIONS . '/markdown/lib/smartypants.php';
}
$result = stripslashes(Markdown($string));
return SmartyPants($result);
}
示例7: run
function run($string)
{
if (!self::$_parser) {
include_once EXTENSIONS . '/markdown/lib/markdown.php';
self::$_parser = new MarkdownExtra_Parser();
}
if (!function_exists('SmartyPants')) {
include_once EXTENSIONS . '/markdown/lib/smartypants.php';
}
return SmartyPants(stripslashes(self::$_parser->transform($string)));
}
示例8: htmlFormatted
function htmlFormatted($text, $media = false, $model = null, $media_link_attributes = null)
{
$text = $this->sanitiseText($text, false);
$text = SmartyPants(Markdown($text));
if ($media && count($media)) {
$text = $this->_formatTextFragments($text, $media, $model, $media_link_attributes);
} else {
$text = $this->_stripTextFragments($text);
}
return $text;
}
示例9: event_hook
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
$hooks =& $bag->get('event_hooks');
if (isset($hooks[$event])) {
switch ($event) {
case 'frontend_display':
if ($this->get_config('SMARTYPANTS_INSTEAD', false)) {
include_once dirname(__FILE__) . '/smartypants.php';
foreach ($this->markup_elements as $temp) {
if (serendipity_db_bool($this->get_config($temp['name'], true)) && !empty($eventData[$temp['element']]) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
$element = $temp['element'];
$eventData[$element] = SmartyPants($eventData[$element]);
}
}
} else {
foreach ($this->markup_elements as $temp) {
if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
$element = $temp['element'];
# First find all the tags... We want to keep straight quotes in them.
# So we remember all the tags, and replace them temporarily
preg_match_all("/<[^>]*>/", $eventData[$element], $matches);
$count = count($matches[0]);
for ($i = 0; $i < $count; $i++) {
$temp = $matches[0][$i];
$new = "<!-- tag number {$i} -->";
$eventData[$element] = str_replace($temp, $new, $eventData[$element]);
}
# Now we perform our replacements... All sets of quotes turned smart, then single quotes are dealt with...
$eventData[$element] = preg_replace("/\"(.*?)\"/", "“\\1”", $eventData[$element]);
$eventData[$element] = preg_replace("/"(.*?)"/", "“\\1”", $eventData[$element]);
$eventData[$element] = preg_replace("/(?<! )' /", "’ ", $eventData[$element]);
$eventData[$element] = preg_replace("/(?<! )'(?! )/", "’", $eventData[$element]);
$eventData[$element] = preg_replace("/ '(?! )/", " ‘", $eventData[$element]);
#Finally we add the tags back into the body of our entry.
for ($i = 0; $i < $count; $i++) {
$tag_body = $matches[0][$i];
$old = "<!-- tag number {$i} -->";
$eventData[$element] = str_replace($old, $tag_body, $eventData[$element]);
}
}
}
}
return true;
break;
default:
return false;
}
} else {
return false;
}
}
示例10: run
public function run($string)
{
if (!self::$_parser) {
include_once EXTENSIONS . '/markdown/lib/php-markdown-extra-1.2.4/markdown.php';
self::$_parser = new Markdown_Parser();
}
// Markdown transformation
$result = stripslashes(self::$_parser->transform($string));
if (!function_exists('SmartyPants')) {
include_once EXTENSIONS . '/markdown/lib/php-smartypants-1.5.1e/smartypants.php';
}
// Apply "Smarty Pants" formatting
$result = SmartyPants(stripslashes(self::$_parser->transform($string)));
return $result;
}
示例11: tc_post_process
function tc_post_process($text, $do_text = '', $do_char = '')
{
if ($do_text == 'textile2') {
require_once 'text-control/textile2.php';
$t = new Textile();
$text = $t->process($text);
} else {
if ($do_text == 'textile1') {
require_once 'text-control/textile1.php';
$text = textile($text);
} else {
if ($do_text == 'markdown') {
require_once 'text-control/markdown.php';
$text = Markdown($text);
} else {
if ($do_text == 'wpautop') {
$text = wpautop($text);
} else {
if ($do_text == 'nl2br') {
$text = nl2br($text);
} else {
if ($do_text == 'none') {
$text = $text;
} else {
$text = wpautop($text);
}
}
}
}
}
}
if ($do_char == 'smartypants') {
require_once 'text-control/smartypants.php';
$text = SmartyPants($text);
} else {
if ($do_char == 'wptexturize') {
$text = wptexturize($text);
} else {
if ($do_char == 'none') {
$text = $text;
} else {
$text = wptexturize($text);
}
}
}
return $text;
}
示例12: transform
public static function transform($string)
{
$path = dirname(__FILE__) . '/../vendor/' . sfConfig::get('app_majaxMarkdown_style', 'markdown_extra') . '/markdown.php';
require_once $path;
$string = Markdown($string);
if (sfConfig::get('app_majaxMarkdown_smartypants_enabled', true)) {
$style = sfConfig::get('app_majaxMarkdown_smartypants_style', 'smartypants_typographer');
$path = dirname(__FILE__) . '/../vendor/' . $style . '/smartypants.php';
require_once $path;
$string = SmartyPants($string, sfConfig::get('app_majaxMarkdown_smartypants_options', 1));
}
if (sfConfig::get('app_majaxMarkdown_post_render', false)) {
$render = sfConfig::get('app_majaxMarkdown_post_render');
$string = call_user_func($render, $string);
}
return $string;
}
示例13: google_docs_markdown_parse
function google_docs_markdown_parse($url)
{
include_once 'markdown.php';
include_once 'smartypants.php';
$doc = curl_get_contents($url);
$start_of_div = strpos($doc, '<div id="doc-contents">');
$end_of_div = strpos($doc, '<div id="google-view-footer">');
if ($start_of_div === false) {
return 'Sorry, cannot retrieve content at this time.';
}
// get just the content div
$content = substr($doc, $start_of_div, $end_of_div - $start_of_div);
// strip new lines, replace div's with new lines
// strip remaining tags, trim the ends
$content = trim(strip_tags(str_replace(array("\n", '<div>'), array('', "\n"), $content)));
// format with Markdown and return
return SmartyPants(Markdown($content));
}
示例14: htmlFormatted
function htmlFormatted($text, $media = false, $model = null, $media_link_attributes = null)
{
$text = $this->sanitiseText($text, false);
if (!preg_match('/{\\[markdown\\]}/', $text)) {
$txtl = new Textile();
$text = SmartyPants($txtl->TextileThis($text), 1);
$text = $txtl->TextileThis($text);
} else {
$text = str_replace('{[markdown]}', '', $text);
$text = SmartyPants(Markdown($text), 1);
}
if ($media && count($media)) {
$text = $this->_formatTextFragments($text, $media, $model, $media_link_attributes);
} else {
$text = $this->_stripTextFragments($text);
}
return $text;
}
示例15: input
/**
* Handle $data, and return the results.
*
* @param string data The data to handle.
* @return string
* @access public
*/
public function input($data, $options = array())
{
include_once CURATOR_APP_DIR . DS . 'Vendors' . DS . 'php-markdown' . DS . 'dist' . DS . 'markdown.php';
include_once CURATOR_APP_DIR . DS . 'Vendors' . DS . 'php-smartypants' . DS . 'dist' . DS . 'smartypants.php';
$result = null;
try {
if (strpos($data, NL) === false && is_file($data)) {
$data = file_get_contents($data);
if ($data === false) {
throw new \Exception('Could not load file: ' . $data);
}
}
$result = \SmartyPants(\Markdown($data));
} catch (\Exception $e) {
\Curator\Console::stderr('** Could not handle Mardkwon data:');
\Curator\Console::stderr(' ' . $e->getMessage());
}
return $result;
}