1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129 |
- <?php
- use Codeception\Util\Fixtures;
- use Grav\Common\Grav;
- use Grav\Common\Page\Markdown\Excerpts;
- use Grav\Common\Uri;
- use Grav\Common\Config\Config;
- use Grav\Common\Page\Pages;
- use Grav\Common\Markdown\Parsedown;
- use Grav\Common\Language\Language;
- use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
- /**
- * Class ParsedownTest
- */
- class ParsedownTest extends \Codeception\TestCase\Test
- {
- /** @var Parsedown $parsedown */
- protected $parsedown;
- /** @var Grav $grav */
- protected $grav;
- /** @var Pages $pages */
- protected $pages;
- /** @var Config $config */
- protected $config;
- /** @var Uri $uri */
- protected $uri;
- /** @var Language $language */
- protected $language;
- protected $old_home;
- protected function _before(): void
- {
- $grav = Fixtures::get('grav');
- $this->grav = $grav();
- $this->pages = $this->grav['pages'];
- $this->config = $this->grav['config'];
- $this->uri = $this->grav['uri'];
- $this->language = $this->grav['language'];
- $this->old_home = $this->config->get('system.home.alias');
- $this->config->set('system.home.alias', '/item1');
- $this->config->set('system.absolute_urls', false);
- $this->config->set('system.languages.supported', []);
- unset($this->grav['language']);
- $this->grav['language'] = new Language($this->grav);
- /** @var UniformResourceLocator $locator */
- $locator = $this->grav['locator'];
- $locator->addPath('page', '', 'tests/fake/nested-site/user/pages', false);
- $this->pages->init();
- $defaults = [
- 'markdown' => [
- 'extra' => false,
- 'auto_line_breaks' => false,
- 'auto_url_links' => false,
- 'escape_markup' => false,
- 'special_chars' => ['>' => 'gt', '<' => 'lt'],
- ],
- 'images' => $this->config->get('system.images', [])
- ];
- $page = $this->pages->find('/item2/item2-2');
- $excerpts = new Excerpts($page, $defaults);
- $this->parsedown = new Parsedown($excerpts);
- }
- protected function _after(): void
- {
- $this->config->set('system.home.alias', $this->old_home);
- }
- public function testImages(): void
- {
- $this->config->set('system.languages.supported', ['fr','en']);
- unset($this->grav['language']);
- $this->grav['language'] = new Language($this->grav);
- $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
- self::assertSame(
- '<p><img alt="" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="\/images\/.*-cache-image.jpe?g\?foo=1" \/><\/p>|',
- $this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)')
- );
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><img alt="" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="\/images\/.*-cache-image.jpe?g\?foo=1" \/><\/p>|',
- $this->parsedown->text('![](cache-image.jpg?cropResize=200,200&foo)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](/home-cache-image.jpg?cache)')
- );
- self::assertSame(
- '<p><img src="/item2/item2-2/missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](missing-image.jpg)')
- );
- self::assertSame(
- '<p><img src="/home-missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](/home-missing-image.jpg)')
- );
- self::assertSame(
- '<p><img src="/home-missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](/home-missing-image.jpg)')
- );
- self::assertSame(
- '<p><img src="https://getgrav-grav.netdna-ssl.com/user/pages/media/grav-logo.svg" alt="" /></p>',
- $this->parsedown->text('![](https://getgrav-grav.netdna-ssl.com/user/pages/media/grav-logo.svg)')
- );
- }
- public function testImagesSubDir(): void
- {
- $this->config->set('system.images.cache_all', false);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertRegexp(
- '|<p><img alt="" src="\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](/home-cache-image.jpg?cache)')
- );
- self::assertSame(
- '<p><img alt="" src="/subdir/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](cache-image.jpg?cache)')
- );
- self::assertSame(
- '<p><img src="/subdir/item2/item2-2/missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](missing-image.jpg)')
- );
- self::assertSame(
- '<p><img src="/subdir/home-missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](/home-missing-image.jpg)')
- );
- }
- public function testImagesAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><img alt="" src="http://testing.dev/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="http:\/\/testing.dev\/images\/.*-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](cache-image.jpg?cache)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="http:\/\/testing.dev\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](/home-cache-image.jpg?cache)')
- );
- self::assertSame(
- '<p><img src="http://testing.dev/item2/item2-2/missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](missing-image.jpg)')
- );
- self::assertSame(
- '<p><img src="http://testing.dev/home-missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](/home-missing-image.jpg)')
- );
- }
- public function testImagesSubDirAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><img alt="" src="http://testing.dev/subdir/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="http:\/\/testing.dev\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](cache-image.jpg?cache)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="http:\/\/testing.dev\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)')
- );
- self::assertSame(
- '<p><img src="http://testing.dev/subdir/item2/item2-2/missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](missing-image.jpg)')
- );
- self::assertSame(
- '<p><img src="http://testing.dev/subdir/home-missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](/home-missing-image.jpg)')
- );
- }
- public function testImagesAttributes(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><img title="My Title" alt="" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg "My Title")')
- );
- self::assertSame(
- '<p><img alt="" class="foo" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg?classes=foo)')
- );
- self::assertSame(
- '<p><img alt="" class="foo bar" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg?classes=foo,bar)')
- );
- self::assertSame(
- '<p><img alt="" id="foo" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg?id=foo)')
- );
- self::assertSame(
- '<p><img alt="Alt Text" id="foo" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![Alt Text](sample-image.jpg?id=foo)')
- );
- self::assertSame(
- '<p><img alt="Alt Text" class="bar" id="foo" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![Alt Text](sample-image.jpg?class=bar&id=foo)')
- );
- self::assertSame(
- '<p><img title="My Title" alt="Alt Text" class="bar" id="foo" src="/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![Alt Text](sample-image.jpg?class=bar&id=foo "My Title")')
- );
- }
- public function testRootImages(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/')->init();
- $defaults = [
- 'markdown' => [
- 'extra' => false,
- 'auto_line_breaks' => false,
- 'auto_url_links' => false,
- 'escape_markup' => false,
- 'special_chars' => ['>' => 'gt', '<' => 'lt'],
- ],
- 'images' => $this->config->get('system.images', [])
- ];
- $page = $this->pages->find('/');
- $excerpts = new Excerpts($page, $defaults);
- $this->parsedown = new Parsedown($excerpts);
- self::assertSame(
- '<p><img alt="" src="/tests/fake/nested-site/user/pages/01.item1/home-sample-image.jpg" /></p>',
- $this->parsedown->text('![](home-sample-image.jpg)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](home-cache-image.jpg?cache)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="\/images\/.*-home-cache-image.jpe?g\?foo=1" \/><\/p>|',
- $this->parsedown->text('![](home-cache-image.jpg?cropResize=200,200&foo)')
- );
- self::assertSame(
- '<p><img src="/home-missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](/home-missing-image.jpg)')
- );
- $this->config->set('system.languages.supported', ['fr','en']);
- unset($this->grav['language']);
- $this->grav['language'] = new Language($this->grav);
- $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
- self::assertSame(
- '<p><img alt="" src="/tests/fake/nested-site/user/pages/01.item1/home-sample-image.jpg" /></p>',
- $this->parsedown->text('![](home-sample-image.jpg)')
- );
- }
- public function testRootImagesSubDirAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><img alt="" src="http://testing.dev/subdir/tests/fake/nested-site/user/pages/02.item2/02.item2-2/sample-image.jpg" /></p>',
- $this->parsedown->text('![](sample-image.jpg)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="http:\/\/testing.dev\/subdir\/images\/.*-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](cache-image.jpg?cache)')
- );
- self::assertRegexp(
- '|<p><img alt="" src="http:\/\/testing.dev\/subdir\/images\/.*-home-cache-image.jpe?g" \/><\/p>|',
- $this->parsedown->text('![](/home-cache-image.jpg?cropResize=200,200)')
- );
- self::assertSame(
- '<p><img src="http://testing.dev/subdir/item2/item2-2/missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](missing-image.jpg)')
- );
- self::assertSame(
- '<p><img src="http://testing.dev/subdir/home-missing-image.jpg" alt="" /></p>',
- $this->parsedown->text('![](/home-missing-image.jpg)')
- );
- }
- public function testRootAbsoluteLinks(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/')->init();
- $defaults = [
- 'markdown' => [
- 'extra' => false,
- 'auto_line_breaks' => false,
- 'auto_url_links' => false,
- 'escape_markup' => false,
- 'special_chars' => ['>' => 'gt', '<' => 'lt'],
- ],
- 'images' => $this->config->get('system.images', [])
- ];
- $page = $this->pages->find('/');
- $excerpts = new Excerpts($page, $defaults);
- $this->parsedown = new Parsedown($excerpts);
- self::assertSame(
- '<p><a href="/item1/item1-3">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](item1-3)')
- );
- self::assertSame(
- '<p><a href="/item2">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](../item2)')
- );
- self::assertSame(
- '<p><a href="/?foo=bar">With Query</a></p>',
- $this->parsedown->text('[With Query](?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/foo:bar">With Param</a></p>',
- $this->parsedown->text('[With Param](/foo:bar)')
- );
- self::assertSame(
- '<p><a href="#foo">With Anchor</a></p>',
- $this->parsedown->text('[With Anchor](#foo)')
- );
- $this->config->set('system.languages.supported', ['fr','en']);
- unset($this->grav['language']);
- $this->grav['language'] = new Language($this->grav);
- $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="/fr/item2">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](../item2)')
- );
- self::assertSame(
- '<p><a href="/fr/item1/item1-3">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](item1-3)')
- );
- self::assertSame(
- '<p><a href="/fr/?foo=bar">With Query</a></p>',
- $this->parsedown->text('[With Query](?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/fr/foo:bar">With Param</a></p>',
- $this->parsedown->text('[With Param](/foo:bar)')
- );
- self::assertSame(
- '<p><a href="#foo">With Anchor</a></p>',
- $this->parsedown->text('[With Anchor](#foo)')
- );
- }
- public function testAnchorLinksLangRelativeUrls(): void
- {
- $this->config->set('system.languages.supported', ['fr','en']);
- unset($this->grav['language']);
- $this->grav['language'] = new Language($this->grav);
- $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="#foo">Current Anchor</a></p>',
- $this->parsedown->text('[Current Anchor](#foo)')
- );
- self::assertSame(
- '<p><a href="/fr/#foo">Root Anchor</a></p>',
- $this->parsedown->text('[Root Anchor](/#foo)')
- );
- self::assertSame(
- '<p><a href="/fr/item2/item2-1#foo">Peer Anchor</a></p>',
- $this->parsedown->text('[Peer Anchor](../item2-1#foo)')
- );
- self::assertSame(
- '<p><a href="/fr/item2/item2-1#foo">Peer Anchor 2</a></p>',
- $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')
- );
- }
- public function testAnchorLinksLangAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->config->set('system.languages.supported', ['fr','en']);
- unset($this->grav['language']);
- $this->grav['language'] = new Language($this->grav);
- $this->uri->initializeWithURL('http://testing.dev/fr/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="#foo">Current Anchor</a></p>',
- $this->parsedown->text('[Current Anchor](#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/fr/item2/item2-1#foo">Peer Anchor</a></p>',
- $this->parsedown->text('[Peer Anchor](../item2-1#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/fr/item2/item2-1#foo">Peer Anchor 2</a></p>',
- $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/fr/#foo">Root Anchor</a></p>',
- $this->parsedown->text('[Root Anchor](/#foo)')
- );
- }
- public function testExternalLinks(): void
- {
- self::assertSame(
- '<p><a href="http://www.cnn.com">cnn.com</a></p>',
- $this->parsedown->text('[cnn.com](http://www.cnn.com)')
- );
- self::assertSame(
- '<p><a href="https://www.google.com">google.com</a></p>',
- $this->parsedown->text('[google.com](https://www.google.com)')
- );
- self::assertSame(
- '<p><a href="https://github.com/getgrav/grav/issues/new?title=%5Badd-resource%5D%20New%20Plugin%2FTheme&body=Hello%20%2A%2AThere%2A%2A">complex url</a></p>',
- $this->parsedown->text('[complex url](https://github.com/getgrav/grav/issues/new?title=[add-resource]%20New%20Plugin/Theme&body=Hello%20**There**)')
- );
- }
- public function testExternalLinksSubDir(): void
- {
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="http://www.cnn.com">cnn.com</a></p>',
- $this->parsedown->text('[cnn.com](http://www.cnn.com)')
- );
- self::assertSame(
- '<p><a href="https://www.google.com">google.com</a></p>',
- $this->parsedown->text('[google.com](https://www.google.com)')
- );
- }
- public function testExternalLinksSubDirAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="http://www.cnn.com">cnn.com</a></p>',
- $this->parsedown->text('[cnn.com](http://www.cnn.com)')
- );
- self::assertSame(
- '<p><a href="https://www.google.com">google.com</a></p>',
- $this->parsedown->text('[google.com](https://www.google.com)')
- );
- }
- public function testAnchorLinksRelativeUrls(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="#foo">Current Anchor</a></p>',
- $this->parsedown->text('[Current Anchor](#foo)')
- );
- self::assertSame(
- '<p><a href="/#foo">Root Anchor</a></p>',
- $this->parsedown->text('[Root Anchor](/#foo)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-1#foo">Peer Anchor</a></p>',
- $this->parsedown->text('[Peer Anchor](../item2-1#foo)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-1#foo">Peer Anchor 2</a></p>',
- $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')
- );
- }
- public function testAnchorLinksAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="#foo">Current Anchor</a></p>',
- $this->parsedown->text('[Current Anchor](#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item2/item2-1#foo">Peer Anchor</a></p>',
- $this->parsedown->text('[Peer Anchor](../item2-1#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item2/item2-1#foo">Peer Anchor 2</a></p>',
- $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/#foo">Root Anchor</a></p>',
- $this->parsedown->text('[Root Anchor](/#foo)')
- );
- }
- public function testAnchorLinksWithPortAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithURL('http://testing.dev:8080/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="http://testing.dev:8080/item2/item2-1#foo">Peer Anchor</a></p>',
- $this->parsedown->text('[Peer Anchor](../item2-1#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev:8080/item2/item2-1#foo">Peer Anchor 2</a></p>',
- $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')
- );
- self::assertSame(
- '<p><a href="#foo">Current Anchor</a></p>',
- $this->parsedown->text('[Current Anchor](#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev:8080/#foo">Root Anchor</a></p>',
- $this->parsedown->text('[Root Anchor](/#foo)')
- );
- }
- public function testAnchorLinksSubDirRelativeUrls(): void
- {
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="/subdir/item2/item2-1#foo">Peer Anchor</a></p>',
- $this->parsedown->text('[Peer Anchor](../item2-1#foo)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2/item2-1#foo">Peer Anchor 2</a></p>',
- $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')
- );
- self::assertSame(
- '<p><a href="#foo">Current Anchor</a></p>',
- $this->parsedown->text('[Current Anchor](#foo)')
- );
- self::assertSame(
- '<p><a href="/subdir/#foo">Root Anchor</a></p>',
- $this->parsedown->text('[Root Anchor](/#foo)')
- );
- }
- public function testAnchorLinksSubDirAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-1#foo">Peer Anchor</a></p>',
- $this->parsedown->text('[Peer Anchor](../item2-1#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-1#foo">Peer Anchor 2</a></p>',
- $this->parsedown->text('[Peer Anchor 2](../item2-1/#foo)')
- );
- self::assertSame(
- '<p><a href="#foo">Current Anchor</a></p>',
- $this->parsedown->text('[Current Anchor](#foo)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/#foo">Root Anchor</a></p>',
- $this->parsedown->text('[Root Anchor](/#foo)')
- );
- }
- public function testSlugRelativeLinks(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="/">Up to Root Level</a></p>',
- $this->parsedown->text('[Up to Root Level](../..)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-1">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](../item2-1)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](item2-2-1)')
- );
- self::assertSame(
- '<p><a href="/item2">Up a Level</a></p>',
- $this->parsedown->text('[Up a Level](..)')
- );
- self::assertSame(
- '<p><a href="/item3/item3-3">Up and Down</a></p>',
- $this->parsedown->text('[Up and Down](../../item3/item3-3)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
- $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/item2?foo=bar">Up a Level with Query</a></p>',
- $this->parsedown->text('[Up a Level with Query](../?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
- $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
- $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)')
- );
- self::assertSame(
- '<p><a href="/item3/item3-3#foo">Up and Down with Anchor</a></p>',
- $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)')
- );
- }
- public function testSlugRelativeLinksAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="http://testing.dev/item2/item2-1">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](../item2-1)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item2/item2-2/item2-2-1">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](item2-2-1)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item2">Up a Level</a></p>',
- $this->parsedown->text('[Up a Level](..)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/">Up to Root Level</a></p>',
- $this->parsedown->text('[Up to Root Level](../..)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item3/item3-3">Up and Down</a></p>',
- $this->parsedown->text('[Up and Down](../../item3/item3-3)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
- $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item2?foo=bar">Up a Level with Query</a></p>',
- $this->parsedown->text('[Up a Level with Query](../?foo=bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
- $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
- $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/item3/item3-3#foo">Up and Down with Anchor</a></p>',
- $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)')
- );
- }
- public function testSlugRelativeLinksSubDir(): void
- {
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="/subdir/item2/item2-1">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](../item2-1)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](item2-2-1)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2">Up a Level</a></p>',
- $this->parsedown->text('[Up a Level](..)')
- );
- self::assertSame(
- '<p><a href="/subdir">Up to Root Level</a></p>',
- $this->parsedown->text('[Up to Root Level](../..)')
- );
- self::assertSame(
- '<p><a href="/subdir/item3/item3-3">Up and Down</a></p>',
- $this->parsedown->text('[Up and Down](../../item3/item3-3)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
- $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2?foo=bar">Up a Level with Query</a></p>',
- $this->parsedown->text('[Up a Level with Query](../?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/subdir/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
- $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/subdir/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
- $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)')
- );
- self::assertSame(
- '<p><a href="/subdir/item3/item3-3#foo">Up and Down with Anchor</a></p>',
- $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)')
- );
- }
- public function testSlugRelativeLinksSubDirAbsoluteUrls(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-1">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](../item2-1)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](item2-2-1)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2">Up a Level</a></p>',
- $this->parsedown->text('[Up a Level](..)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir">Up to Root Level</a></p>',
- $this->parsedown->text('[Up to Root Level](../..)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item3/item3-3">Up and Down</a></p>',
- $this->parsedown->text('[Up and Down](../../item3/item3-3)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
- $this->parsedown->text('[Down a Level with Query](item2-2-1?foo=bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2?foo=bar">Up a Level with Query</a></p>',
- $this->parsedown->text('[Up a Level with Query](../?foo=bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
- $this->parsedown->text('[Up and Down with Query](../../item3/item3-3?foo=bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
- $this->parsedown->text('[Up and Down with Param](../../item3/item3-3/foo:bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item3/item3-3#foo">Up and Down with Anchor</a></p>',
- $this->parsedown->text('[Up and Down with Anchor](../../item3/item3-3#foo)')
- );
- }
- public function testDirectoryRelativeLinks(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="/item3/item3-3/foo:bar">Up and Down with Param</a></p>',
- $this->parsedown->text('[Up and Down with Param](../../03.item3/03.item3-3/foo:bar)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-1">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](../01.item2-1)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](01.item2-2-1)')
- );
- self::assertSame(
- '<p><a href="/item3/item3-3">Up and Down</a></p>',
- $this->parsedown->text('[Up and Down](../../03.item3/03.item3-3)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-2/item2-2-1?foo=bar">Down a Level with Query</a></p>',
- $this->parsedown->text('[Down a Level with Query](01.item2-2-1?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/item3/item3-3?foo=bar">Up and Down with Query</a></p>',
- $this->parsedown->text('[Up and Down with Query](../../03.item3/03.item3-3?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/item3/item3-3#foo">Up and Down with Anchor</a></p>',
- $this->parsedown->text('[Up and Down with Anchor](../../03.item3/03.item3-3#foo)')
- );
- }
- public function testAbsoluteLinks(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="/">Root</a></p>',
- $this->parsedown->text('[Root](/)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-1">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](/item2/item2-1)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-2/item2-2-1">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)')
- );
- self::assertSame(
- '<p><a href="/item2">Up a Level</a></p>',
- $this->parsedown->text('[Up a Level](/item2)')
- );
- self::assertSame(
- '<p><a href="/item2?foo=bar">With Query</a></p>',
- $this->parsedown->text('[With Query](/item2?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/item2/foo:bar">With Param</a></p>',
- $this->parsedown->text('[With Param](/item2/foo:bar)')
- );
- self::assertSame(
- '<p><a href="/item2#foo">With Anchor</a></p>',
- $this->parsedown->text('[With Anchor](/item2#foo)')
- );
- }
- public function testDirectoryAbsoluteLinksSubDir(): void
- {
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="/subdir/">Root</a></p>',
- $this->parsedown->text('[Root](/)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2/item2-1">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](/item2/item2-1)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2">Up a Level</a></p>',
- $this->parsedown->text('[Up a Level](/item2)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2?foo=bar">With Query</a></p>',
- $this->parsedown->text('[With Query](/item2?foo=bar)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2/foo:bar">With Param</a></p>',
- $this->parsedown->text('[With Param](/item2/foo:bar)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2#foo">With Anchor</a></p>',
- $this->parsedown->text('[With Anchor](/item2#foo)')
- );
- }
- public function testDirectoryAbsoluteLinksSubDirAbsoluteUrl(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/">Root</a></p>',
- $this->parsedown->text('[Root](/)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-1">Peer Page</a></p>',
- $this->parsedown->text('[Peer Page](/item2/item2-1)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-2/item2-2-1">Down a Level</a></p>',
- $this->parsedown->text('[Down a Level](/item2/item2-2/item2-2-1)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2">Up a Level</a></p>',
- $this->parsedown->text('[Up a Level](/item2)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2?foo=bar">With Query</a></p>',
- $this->parsedown->text('[With Query](/item2?foo=bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/foo:bar">With Param</a></p>',
- $this->parsedown->text('[With Param](/item2/foo:bar)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2#foo">With Anchor</a></p>',
- $this->parsedown->text('[With Anchor](/item2#foo)')
- );
- }
- public function testSpecialProtocols(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="mailto:user@domain.com">mailto</a></p>',
- $this->parsedown->text('[mailto](mailto:user@domain.com)')
- );
- self::assertSame(
- '<p><a href="xmpp:xyx@domain.com">xmpp</a></p>',
- $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)')
- );
- self::assertSame(
- '<p><a href="tel:123-555-12345">tel</a></p>',
- $this->parsedown->text('[tel](tel:123-555-12345)')
- );
- self::assertSame(
- '<p><a href="sms:123-555-12345">sms</a></p>',
- $this->parsedown->text('[sms](sms:123-555-12345)')
- );
- self::assertSame(
- '<p><a href="rdp://ts.example.com">ts.example.com</a></p>',
- $this->parsedown->text('[ts.example.com](rdp://ts.example.com)')
- );
- }
- public function testSpecialProtocolsSubDir(): void
- {
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="mailto:user@domain.com">mailto</a></p>',
- $this->parsedown->text('[mailto](mailto:user@domain.com)')
- );
- self::assertSame(
- '<p><a href="xmpp:xyx@domain.com">xmpp</a></p>',
- $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)')
- );
- self::assertSame(
- '<p><a href="tel:123-555-12345">tel</a></p>',
- $this->parsedown->text('[tel](tel:123-555-12345)')
- );
- self::assertSame(
- '<p><a href="sms:123-555-12345">sms</a></p>',
- $this->parsedown->text('[sms](sms:123-555-12345)')
- );
- self::assertSame(
- '<p><a href="rdp://ts.example.com">ts.example.com</a></p>',
- $this->parsedown->text('[ts.example.com](rdp://ts.example.com)')
- );
- }
- public function testSpecialProtocolsSubDirAbsoluteUrl(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="mailto:user@domain.com">mailto</a></p>',
- $this->parsedown->text('[mailto](mailto:user@domain.com)')
- );
- self::assertSame(
- '<p><a href="xmpp:xyx@domain.com">xmpp</a></p>',
- $this->parsedown->text('[xmpp](xmpp:xyx@domain.com)')
- );
- self::assertSame(
- '<p><a href="tel:123-555-12345">tel</a></p>',
- $this->parsedown->text('[tel](tel:123-555-12345)')
- );
- self::assertSame(
- '<p><a href="sms:123-555-12345">sms</a></p>',
- $this->parsedown->text('[sms](sms:123-555-12345)')
- );
- self::assertSame(
- '<p><a href="rdp://ts.example.com">ts.example.com</a></p>',
- $this->parsedown->text('[ts.example.com](rdp://ts.example.com)')
- );
- }
- public function testReferenceLinks(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- $sample = '[relative link][r_relative]
- [r_relative]: ../item2-3#blah';
- self::assertSame(
- '<p><a href="/item2/item2-3#blah">relative link</a></p>',
- $this->parsedown->text($sample)
- );
- $sample = '[absolute link][r_absolute]
- [r_absolute]: /item3#blah';
- self::assertSame(
- '<p><a href="/item3#blah">absolute link</a></p>',
- $this->parsedown->text($sample)
- );
- $sample = '[external link][r_external]
- [r_external]: http://www.cnn.com';
- self::assertSame(
- '<p><a href="http://www.cnn.com">external link</a></p>',
- $this->parsedown->text($sample)
- );
- }
- public function testAttributeLinks(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="#something" class="button">Anchor Class</a></p>',
- $this->parsedown->text('[Anchor Class](?classes=button#something)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-3" class="button">Relative Class</a></p>',
- $this->parsedown->text('[Relative Class](../item2-3?classes=button)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-3" id="unique">Relative ID</a></p>',
- $this->parsedown->text('[Relative ID](../item2-3?id=unique)')
- );
- self::assertSame(
- '<p><a href="https://github.com/getgrav/grav" class="button big">External</a></p>',
- $this->parsedown->text('[External](https://github.com/getgrav/grav?classes=button,big)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-3?id=unique">Relative Noprocess</a></p>',
- $this->parsedown->text('[Relative Noprocess](../item2-3?id=unique&noprocess)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-3" target="_blank">Relative Target</a></p>',
- $this->parsedown->text('[Relative Target](../item2-3?target=_blank)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-3" rel="nofollow">Relative Rel</a></p>',
- $this->parsedown->text('[Relative Rel](../item2-3?rel=nofollow)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-3?foo=bar&baz=qux" rel="nofollow" class="button">Relative Mixed</a></p>',
- $this->parsedown->text('[Relative Mixed](../item2-3?foo=bar&baz=qux&rel=nofollow&class=button)')
- );
- }
- public function testInvalidLinks(): void
- {
- $this->uri->initializeWithURL('http://testing.dev/item2/item2-2')->init();
- self::assertSame(
- '<p><a href="/item2/item2-2/no-page">Non Existent Page</a></p>',
- $this->parsedown->text('[Non Existent Page](no-page)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-2/existing-file.zip">Existent File</a></p>',
- $this->parsedown->text('[Existent File](existing-file.zip)')
- );
- self::assertSame(
- '<p><a href="/item2/item2-2/missing-file.zip">Non Existent File</a></p>',
- $this->parsedown->text('[Non Existent File](missing-file.zip)')
- );
- }
- public function testInvalidLinksSubDir(): void
- {
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="/subdir/item2/item2-2/no-page">Non Existent Page</a></p>',
- $this->parsedown->text('[Non Existent Page](no-page)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2/item2-2/existing-file.zip">Existent File</a></p>',
- $this->parsedown->text('[Existent File](existing-file.zip)')
- );
- self::assertSame(
- '<p><a href="/subdir/item2/item2-2/missing-file.zip">Non Existent File</a></p>',
- $this->parsedown->text('[Non Existent File](missing-file.zip)')
- );
- }
- public function testInvalidLinksSubDirAbsoluteUrl(): void
- {
- $this->config->set('system.absolute_urls', true);
- $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-2/no-page">Non Existent Page</a></p>',
- $this->parsedown->text('[Non Existent Page](no-page)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-2/existing-file.zip">Existent File</a></p>',
- $this->parsedown->text('[Existent File](existing-file.zip)')
- );
- self::assertSame(
- '<p><a href="http://testing.dev/subdir/item2/item2-2/missing-file.zip">Non Existent File</a></p>',
- $this->parsedown->text('[Non Existent File](missing-file.zip)')
- );
- }
- /**
- * @param $string
- *
- * @return mixed
- */
- private function stripLeadingWhitespace($string)
- {
- return preg_replace('/^\s*(.*)/', '', $string);
- }
- }
|