Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101299640
katexinline.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
Fri, Feb 7, 14:30
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 9, 14:30 (2 d)
Engine
blob
Format
Raw Data
Handle
24132887
Attached To
rPH Phabricator
katexinline.php
View Options
<?php
final
class
PhabricatorInlineKaTeXRemarkupRule
extends
PhabricatorRemarkupCustomInlineRule
{
public
function
getPriority
()
{
return
300.0
;
}
public
function
apply
(
$text
)
{
return
preg_replace_callback
(
'@{tex
\b
([^{}]*({[^{}]*?([^{}]|(?R))*[^{}]*?}[^{}]*)*[^{}]*)}@m'
,
array
(
$this
,
'markupNavigation'
),
$text
);
}
public
function
markupNavigation
(
array
$matches
)
{
$future
=
id
(
new
ExecFuture
(
'node /opt/render2katex/index.js i'
))
->
setTimeout
(
15
)
->
write
(
trim
(
$matches
[
1
]));
list
(
$err
,
$stdout
,
$stderr
)
=
$future
->
resolve
();
if
(
$err
)
{
return
pht
(
'Execution of `%s` failed (#%d), check your syntax: %s'
,
'render2katex'
,
$err
,
$stderr
);
}
$result
=
$stdout
;
$engine
=
$this
->
getEngine
();
if
(
$engine
->
isTextMode
())
{
return
$matches
[
1
];
}
if
(
$engine
->
isHTMLMailMode
())
{
return
phutil_safe_html
(
$result
);
}
return
$this
->
getEngine
()->
storeText
(
phutil_safe_html
(
$result
));
}
}
Event Timeline
Log In to Comment