PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 31, 2022

[FIXED] How to use php-markdown from pear?

 August 31, 2022     markdown, pear, php     No comments   

Issue

I know how to use php-markdown by loading it manually, but decided to install it through pear. Installed with the following commands:

pear channel-discover pear.michelf.com
pear install michelf/MarkdownExtra

>> install ok: channel://pear.michelf.com/MarkdownExtra-1.2.5

The problem is that I have no idea on how to use it when installed from pear and the documentation does not informs anything about it, so I think it might be a pretty dumb question.

Here is how I tried to use it:

if(class_exists('MarkdownExtra_Parser')){
    $m = MarkdownExtra_Parser();
    $html = $m->transform($string);
}

and:

$html = Markdown($string);

anyone?


Solution

When it's installed OK, it gets installed into the base PEAR directory - which should be in the include path.

<?php
require_once 'markdown.php'
$mdtext= "... markdown text ...";
echo  Markdown($mdtext)

$parser = new MarkdownExtra_Parser;
echo $parser->transform($mdtext);

will output the two sets of HTML based on the contents of $mdtext.

There are some instructions on http://michelf.com/projects/php-markdown/



Answered By - Alister Bulman
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing