erusev / parsedown

Better Markdown Parser in PHP

Home Page:https://parsedown.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I want to disable links - is the only way to do that by editing the $InlineTypes array

xxxmicrobexxx opened this issue · comments

The subject says it all really.

I have a form (a petition) that is editable by users before the content is sent to a 3rd party. I want users to be able to use markdown, but don't want them to be able to include malicious links. URL's that are visible are fine, but not text with a hidden URL.

Apart from editing Parsedown.php, is it possible to disable parsing of links if they are formatted for markdown?

If not, perhaps a future version could extend parsedown to include an options array e.g.
options{ link=0, image=0 }

In 2.0 (not yet release) this could be done with (or something very similar to) the following:

$State = new State;
$InlineTypes = $State->get(InlineTypes::class)->removing([Url::class, Link::class, Image::class]);
$State = $State->setting($InlineTypes);

$Parsedown = new Parsedown($State);
$actualMarkup = $Parsedown->toHtml($markdown);