-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #761 from wouterj/html-tags-in-reference
Fix using < or > in a reference name
- Loading branch information
Showing
13 changed files
with
77 additions
and
158 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/guides-restructured-text/src/RestructuredText/Parser/EmbeddedUriParser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpDocumentor\Guides\RestructuredText\Parser; | ||
|
||
use function preg_match; | ||
|
||
trait EmbeddedUriParser | ||
{ | ||
/** @return array{text:?string,uri:string} */ | ||
private function extractEmbeddedUri(string $text): array | ||
{ | ||
preg_match('/^(.*?)(?:(?:\s|^)<([^<]+)>)?$/s', $text, $matches); | ||
|
||
$text = $matches[1] === '' ? null : $matches[1]; | ||
$uri = $matches[1]; | ||
|
||
if (isset($matches[2])) { | ||
// there is an embedded URI, text and URI are different | ||
$uri = $matches[2]; | ||
} else { | ||
$text = null; | ||
} | ||
|
||
return ['text' => $text, 'uri' => $uri]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.