Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86539663
PhabricatorRemarkupRulePhriction.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Oct 7, 02:37
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Oct 9, 02:37 (2 d)
Engine
blob
Format
Raw Data
Handle
21443529
Attached To
rPH Phabricator
PhabricatorRemarkupRulePhriction.php
View Options
<?php
/**
* @group markup
*/
final
class
PhabricatorRemarkupRulePhriction
extends
PhutilRemarkupRule
{
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'@
\B\\
[
\\
[([^|
\\
]]+)(?:
\\
|([^
\\
]]+))?
\\
]
\\
]
\B
@U'
,
array
(
$this
,
'markupDocumentLink'
),
$text
);
}
public
function
markupDocumentLink
(
$matches
)
{
$link
=
trim
(
$matches
[
1
]);
$name
=
trim
(
idx
(
$matches
,
2
,
$link
));
$name
=
explode
(
'/'
,
trim
(
$name
,
'/'
));
$name
=
end
(
$name
);
$uri
=
new
PhutilURI
(
$link
);
$slug
=
$uri
->
getPath
();
$fragment
=
$uri
->
getFragment
();
$slug
=
PhabricatorSlug
::
normalize
(
$slug
);
$slug
=
PhrictionDocument
::
getSlugURI
(
$slug
);
$href
=
(
string
)
id
(
new
PhutilURI
(
$slug
))->
setFragment
(
$fragment
);
if
(
$this
->
getEngine
()->
getState
(
'toc'
))
{
$text
=
phutil_escape_html
(
$name
);
}
else
{
$text
=
phutil_render_tag
(
'a'
,
array
(
'href'
=>
$href
,
'class'
=>
'phriction-link'
,
),
phutil_escape_html
(
$name
));
}
return
$this
->
getEngine
()->
storeText
(
$text
);
}
}
Event Timeline
Log In to Comment