Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
namespace phpDocumentor\Guides\RestructuredText\Parser\References;

use function preg_match;
use function str_replace;
use function trim;

trait EmbeddedReferenceParser
{
/**
* https://regex101.com/r/KadqKx/1
* https://regex101.com/r/8O8N3h/2
*/
private string $referenceRegex = '/^(.*?)(<([^<]+)>)?$/s';
private string $referenceRegex = '/^(.*?)((?<!\\\\)<([^<]+)(?<!\\\\)>)?$/s';

private function extractEmbeddedReference(string $text): ReferenceData
{
Expand All @@ -37,6 +38,9 @@ private function extractEmbeddedReference(string $text): ReferenceData
$text = null;
}

return new ReferenceData($reference, $text);
return new ReferenceData(
str_replace(['\\<', '\\>'], ['<', '>'], $reference),
$text,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ public static function inlineNodeProvider(): array
'`myref`_',
new InlineCompoundNode([new HyperLinkNode('myref', 'myref')]),
],
'Named Reference, escaped phrase' => [
'`myref \<foo\>`_',
new InlineCompoundNode([new HyperLinkNode('myref <foo>', 'myref <foo>')]),
],
'Named Reference, Phrased, With URL' => [
'`myref <https://test.com>`_',
new InlineCompoundNode([new HyperLinkNode('myref', 'https://test.com')]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
<!-- content start -->
<div class="section" id="the-head">
<h1>the &lt;head&gt;</h1>

<a id="anchor"></a>
<p>See also <a href="/index.html#anchor">the &lt;head&gt; of this file</a> or <a href="/index.html#the-head">the &lt;head&gt;</a>.</p>
<p>See also this is a complex reference <a href="/index.html#the-head">the &lt;head&gt;</a>.</p>
</div>

<!-- content end -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.. _anchor:

the \<head\>
the <head>
============

See also :ref:`the \<head\> of this file <anchor>` or `the \<head\>`_.
See also this is a complex reference `the \<head\>`_.

This file was deleted.

Loading