コード例 #1
0
 public function smartypants($text)
 {
     if (!class_exists('\\Michelf\\SmartyPants', false) && class_exists('SmartyPants', true)) {
         // sneaky autoloading hack
     }
     $SmartyPants = new \Michelf\SmartyPants(\Michelf\SMARTYPANTS_ATTR_LONG_EM_DASH_SHORT_EN);
     $text = $SmartyPants->transform($text);
     if (PERCH_HTML_ENTITIES == false) {
         #$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
         #$text = PerchUtil::html($text, -1);
         $text = $this->de_entitize($text);
     }
     return $text;
 }
コード例 #2
0
ファイル: index.php プロジェクト: slick0/docs
    header("location: ./introduction");
    die;
}
// dump($request);
// dump($prefix);
if (!file_exists("./source/" . $request . ".md")) {
    header("HTTP/1.0 404 Not Found");
    echo "No proper name for a page in the docs. Bye!";
    die;
}
use Symfony\Component\Yaml\Parser;
$yaml = new Parser();
$menu = $yaml->parse(file_get_contents('menu.yml'));
$source = file_get_contents("./source/" . $request . ".md");
$source = \ParsedownExtra::instance()->text($source);
$source = Michelf\SmartyPants::defaultTransform($source);
preg_match("/<h1>(.*)<\\/h1>/i", $source, $maintitle);
$maintitle = $maintitle[1];
preg_match_all("/<h2>(.*)<\\/h2>/i", $source, $matches);
$submenu = array();
foreach ($matches[1] as $key => $title) {
    $submenu[makeSlug(strip_tags($title))] = strip_tags($title);
}
// Let's see if there's a 'q' to highlight..
/* ----- This is broken: it also replaces _inside_ image tags. Not what we want.
if (!empty($_GET['q'])) {

    $q = makeSlug($_GET['q']);

    $source = preg_replace_callback("/" . $q . "/i", function($matches) {
        $output = sprintf("<mark id='%s'>%s</mark>",
コード例 #3
0
 public function text_to_html($value)
 {
     switch (PERCH_APPS_EDITOR_MARKUP_LANGUAGE) {
         case 'textile':
             if (!class_exists('\\Netcarver\\Textile\\Parser', false) && class_exists('Textile', true)) {
                 // sneaky autoloading hack
             }
             if (PERCH_HTML5) {
                 $Textile = new \Netcarver\Textile\Parser('html5');
             } else {
                 $Textile = new \Netcarver\Textile\Parser();
             }
             if (PERCH_RWD) {
                 $value = $Textile->setDimensionlessImages(true)->textileThis($value);
             } else {
                 $value = $Textile->textileThis($value);
             }
             break;
         case 'markdown':
             // Fix markdown blockquote syntax - > gets encoded.
             $value = preg_replace('/[\\n\\r]&gt;\\s/', "\n> ", $value);
             // Fix autolink syntax
             $value = preg_replace('#&lt;(http[a-zA-Z0-9-\\.\\/:]*)&gt;#', "<\$1>", $value);
             $Markdown = new ParsedownExtra();
             $value = $Markdown->text($value);
             if (!class_exists('\\Michelf\\SmartyPants', false) && class_exists('SmartyPants', true)) {
                 // sneaky autoloading hack
             }
             $SmartyPants = new \Michelf\SmartyPants();
             $value = $SmartyPants->transform($value);
             if (PERCH_HTML_ENTITIES == false) {
                 $value = html_entity_decode($value, ENT_NOQUOTES, 'UTF-8');
             }
             break;
     }
     if (defined('PERCH_XHTML_MARKUP') && PERCH_XHTML_MARKUP == false) {
         $value = str_replace(' />', '>', $value);
     }
     return $value;
 }