Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F441918
PhrictionRemarkupRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhrictionRemarkupRule.php
View Options
<?php
/**
* @group markup
*/
final
class
PhrictionRemarkupRule
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
=
$name
;
}
else
if
(
$this
->
getEngine
()->
isTextMode
())
{
return
PhabricatorEnv
::
getProductionURI
(
$href
);
}
else
{
$text
=
phutil_tag
(
'a'
,
array
(
'href'
=>
$href
,
'class'
=>
'phriction-link'
,
),
$name
);
}
return
$this
->
getEngine
()->
storeText
(
$text
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, May 4, 7:56 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
64545
Default Alt Text
PhrictionRemarkupRule.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment