cebe / markdown

A super fast, highly extensible markdown parser for PHP

Home Page:http://markdown.cebe.cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

links with references are not parsed

glensc opened this issue · comments

<?php

require 'vendor/autoload.php';

$parser = new cebe\markdown\GithubMarkdown();
//$parser = new cebe\markdown\Markdown();

$text = '
here is a [linkref].
and [inline](http://google.com)

[linkref]: http://github.com
';

print_r($parser->parseParagraph($text));
here is a [linkref].
and <a href="http://google.com">inline</a>

[linkref]: <a href="http://github.com">http://github.com</a>

print_r($parser->parseParagraph($text));

references are considered as block elements and do not work in parseParagraph().

It works when you parse full markdown: http://markdown.cebe.cc/try?flavor=default&text=here+is+a+%5Blinkref%5D.%0D%0Aand+%5Binline%5D%28http%3A%2F%2Fgoogle.com%29%0D%0A%0D%0A%5Blinkref%5D%3A+http%3A%2F%2Fgithub.com

i switched $parser->parse -> $parser->parseParagraph because did not need surrounding <p>..</p>:

eventum/eventum@8837f45

i switched $parser->parse -> $parser->parseParagraph because did not need surrounding <p>..</p>:

it's not only about <p> tags, you disable all block elements with that (quotes, code-blocks, headlines, etc...). So if you need any block element you should use parse() or customize the markdown syntax.