Example #1
0
 /**
  * compile markdown to html and render as text
  *
  * @return Illuminate\View\View
  */
 public function previewNoEnclosingPage()
 {
     $markdown = Markdown::defaultTransform(e(Input::get('data')));
     $response = Response::make($markdown);
     $response->header('Content-Type', 'text/html');
     return $response;
 }
 public function setTemplateFilters()
 {
     //markdown
     $this->template->addFilter('md', function ($s) {
         return \Michelf\Markdown::defaultTransform($s);
     });
     //inline markdown
     $this->template->addFilter('imd', function ($s) {
         return strip_tags(Markdown::defaultTransform($s), '<a><strong><em>');
     });
 }
Example #3
0
 public function format($value)
 {
     $flag = $this->module->flag;
     if ($flag == "L") {
         return Markdown::defaultTransform(Str::limit($value, $this->listLimit));
     }
     if ($flag == "R") {
         return Markdown::defaultTransform($value);
     }
     return $value;
 }
Example #4
0
 public function toHtml(array $data)
 {
     $text = $data['text'];
     $html = '<blockquote>';
     $html .= Markdown::defaultTransform($text);
     // Add the cite if necessary
     if (isset($data['cite']) && !empty($data['cite'])) {
         // remove the indent thats added by Sir Trevor
         $cite = ltrim($data['cite'], '>');
         $html .= '<cite>' . Markdown::defaultTransform($cite) . '</cite>';
     }
     $html .= '</blockquote>';
     return $html;
 }
 public function setTemplateFilters($template)
 {
     //markdown
     $template->addFilter('md', function ($s) {
         return \Michelf\Markdown::defaultTransform($s);
     });
     //inline markdown
     $template->addFilter('imd', function ($s) {
         return strip_tags(Markdown::defaultTransform($s), '<a><strong><em>');
     });
     //stars
     $this->template->addFilter('stars', function ($s) {
         return \App\Components\ReviewForm::renderRatingStars($s);
     });
 }
Example #6
0
 function showMarkitupPreview($txtData, $type = "markitup")
 {
     $htmlData = "";
     switch ($type) {
         case 'markitup':
             require dirname(__FILE__) . "/Michelf/Markdown.inc.php";
             //require dirname(__FILE__)."/Michelf/MarkdownExtra.inc.php";
             $htmlData = Markdown::defaultTransform($txtData);
             break;
         default:
             $htmlData = $txtData;
             break;
     }
     return $htmlData;
 }
Example #7
0
 function ajaxPublishItem($server, $node, $form)
 {
     $content = $form['content'];
     $title = $form['title'];
     $geo = false;
     if (isset($form['latlonpos']) && $form['latlonpos'] != '') {
         list($lat, $lon) = explode(',', $form['latlonpos']);
         $pos = json_decode(file_get_contents('http://nominatim.openstreetmap.org/reverse?format=json&lat=' . $lat . '&lon=' . $lon . '&zoom=27&addressdetails=1'));
         $geo = array('latitude' => (string) $pos->lat, 'longitude' => (string) $pos->lon, 'altitude' => (string) $pos->alt, 'country' => (string) $pos->address->country, 'countrycode' => (string) $pos->address->country_code, 'region' => (string) $pos->address->county, 'postalcode' => (string) $pos->address->postcode, 'locality' => (string) $pos->address->city, 'street' => (string) $pos->address->path, 'building' => (string) $pos->address->building, 'text' => (string) $pos->display_name, 'uri' => '');
     }
     if ($content != '') {
         $content = Markdown::defaultTransform($content);
         $p = new PostPublish();
         $p->setFrom($this->user->getLogin())->setTo($server)->setNode($node)->setLocation($geo)->setTitle($title)->setContentHtml(rawurldecode($content))->enableComments()->request();
     }
 }
Example #8
0
function ExplainMarkdown($path)
{
    $text = file_get_contents($path);
    return Markdown::defaultTransform($text);
}
/**
 * Handler for github_wikipage shortcode.
 *
 * @param array $atts
 *
 * @return string
 */
function github_readme_wikipage($atts)
{
    $defaults = array('repo' => 'octalmage/GitHub Shortcode', 'trim' => 0, 'cache' => 60, 'page' => '');
    shortcode_atts($defaults, $atts, 'github_wikipage');
    $repo = empty($atts['repo']) ? $defaults['repo'] : $atts['repo'];
    $trim = empty($atts['trim']) ? $defaults['trim'] : abs((int) $atts['trim']);
    $cache = empty($atts['cache']) ? $defaults['cache'] : abs((int) $atts['cache']);
    $page = empty($atts['page']) ? $defaults['page'] : $atts['page'];
    $transient = github_readme_transient_name('github_wikipage_' . $repo . '_' . $page . '_' . $trim . '_' . $cache);
    $html = get_transient($transient);
    if (false === $html) {
        $url = 'https://raw.githubusercontent.com/wiki/' . $repo . '/' . $page . '.md';
        $markdown = github_readme_get_url($url);
        $markdown = github_readme_trim_markdown($markdown, $trim);
        $html = Markdown::defaultTransform($markdown);
        set_transient($transient, $html, $cache);
    }
    return $html;
}
Example #10
0
 /**
  * saves user homepage and shows saved homepage page
  *
  * @return Illuminate\View\View
  */
 public function saveHomepage()
 {
     $profile_markdown = Input::get('data', '');
     $profile_data = Markdown::defaultTransform(e($profile_markdown));
     $profile_css = Input::get('css', '');
     $this->user->saveHomepage(Auth::id(), ['profile_data' => $profile_data, 'profile_markdown' => $profile_markdown, 'profile_css' => $profile_css]);
     $sections = $this->section->get();
     $section = $this->section->sectionFromEmptySection();
     return View::make('page.user.prefs.savedhomepage', ['sections' => $sections, 'section' => $section]);
 }
Example #11
0
 public function amend($comment_id, $content)
 {
     $block = new SuccessBlock();
     if ($block->success) {
         if (Auth::user()->points < 1) {
             $block->success = false;
             $block->errors[] = 'You need at least one point to edit a comment';
         }
     }
     if ($block->success) {
         $comment = $this->findOrFail($comment_id);
         if ($comment->user_id != Auth::user()->id) {
             $block->success = true;
             $block->errors[] = 'This comment does not have the same user id as you';
         }
     }
     if ($block->success) {
         $data['user_id'] = Auth::user()->id;
         $data['data'] = Markdown::defaultTransform(e($content));
         $data['markdown'] = $content;
         $rules = array('user_id' => 'required|numeric', 'markdown' => 'required|max:' . Constant::COMMENT_MAX_MARKDOWN_LENGTH);
         $validate = Validator::make($data, $rules);
         if ($validate->fails()) {
             $block->success = false;
             foreach ($validate->messages()->all() as $v) {
                 $block->errors[] = $v;
             }
         }
     }
     if ($block->success) {
         $history = new History();
         $history->data = $comment->data;
         $history->markdown = $comment->markdown;
         $history->user_id = Auth::user()->id;
         $history->type = Constant::COMMENT_TYPE;
         $history->type_id = $comment->id;
         $history->save();
         Cache::forget(Constant::COMMENT_CACHE_NEWLIST_NAME . $comment->post_id);
         $comment->markdown = $data['markdown'];
         $comment->data = $data['data'];
         $comment->save();
     }
     return $block;
 }
Example #12
0
 public function prepareData($data)
 {
     if (empty($data['data']) && empty($data['url'])) {
         $data['type'] = 1;
     } else {
         if (!empty($data['data']) && !empty($data['url'])) {
             $data['type'] = 0;
         } else {
             if (!empty($data['data'])) {
                 $data['type'] = 1;
             } else {
                 if (!empty($data['url'])) {
                     $data['type'] = 0;
                 }
             }
         }
     }
     $data['title'] = e($data['title']);
     $data['url'] = e($data['url']);
     $data['markdown'] = $data['data'];
     $data['data'] = Markdown::defaultTransform(e($data['markdown']));
     return $data;
 }
Example #13
0
 public function toHtml(array $data)
 {
     return Markdown::defaultTransform('## ' . $data['text']);
 }
Example #14
0
function markdown_mk2html(&$post)
{
    $post->Content = Markdown::defaultTransform($post->Content);
    $post->Intro = Markdown::defaultTransform($post->Intro);
}
Example #15
0
 public static function markdown($text)
 {
     if (!class_exists('Markdown')) {
         require Kohana::find_file('vendor', 'markdown/Markdown');
     }
     return Markdown::defaultTransform($text);
 }
Example #16
0
/**
 * [h description]
 * @param  [type] $string [description]
 * @return [type]         [description]
 *
 * [video]j61nv9faa4c[/video]
 * 
 */
function h($string)
{
    $CI =& get_instance();
    $key = array_keys($CI->config->item("emotion_yahoo"));
    $value = array_values($CI->config->item("emotion_yahoo"));
    $string = str_replace($key, $value, $string);
    $replace = '<p class="text-center"><iframe width="420" height="315" src="https://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe></p>';
    $string = preg_replace("/\\[video\\](.+)\\[\\/video\\]/", $replace, $string);
    $string = Markdown::defaultTransform($string);
    $string = preg_replace("/\\(\\#(\\w+)\\)/i", "<a href='/homepage/tags/\$1'>#\$1</a>", $string);
    return $string;
}
Example #17
0
 public function toHtml(array $data)
 {
     print_r($data);
     die;
     return Markdown::defaultTransform($data['text']);
 }
Example #18
0
/<?php 
echo $query->getId();
?>
/edit" style="padding-right: 7px;">edit</a>
                </div>
                <span class="model-title">
                    <i class="fa fa-file-text-o" style="margin: 0 5px 0 0;"></i>
                    <?php 
echo $query->getTitle();
?>
                </span>
            </div>

            <div class="markdown" style="padding: 15px 20px;">
                <?php 
echo Markdown::defaultTransform($query->getCompiled());
?>
            </div>

        </div>

    </div>

    <style type="text/css">
        .chart { height: 300px; }
        .chart-title { text-align: center; font-size: 13px; font-weight: bold; margin-bottom: 15px; }
        .sample { border-bottom: dashed 1px #b0b1b2; }
        /* .sample::after { content: '\0000a0 \0025C7'; vertical-align: super; font-size: 8px; } */
        #sampleBlock { width: 300px; height: 190px; }
    </style>