Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97338173
PhutilRemarkupEngineRemarkupReplyBlockRule.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
Sat, Jan 4, 06:12
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Jan 6, 06:12 (2 d)
Engine
blob
Format
Raw Data
Handle
23388518
Attached To
rPHU libphutil
PhutilRemarkupEngineRemarkupReplyBlockRule.php
View Options
<?php
final
class
PhutilRemarkupEngineRemarkupReplyBlockRule
extends
PhutilRemarkupEngineBlockRule
{
public
function
getPriority
()
{
return
400.0
;
}
public
function
getMatchingLineCount
(
array
$lines
,
$cursor
)
{
$pos
=
$cursor
;
if
(
preg_match
(
'/^>>!/'
,
$lines
[
$pos
]))
{
do
{
++
$pos
;
}
while
(
isset
(
$lines
[
$pos
])
&&
preg_match
(
'/^>/'
,
$lines
[
$pos
]));
}
return
(
$pos
-
$cursor
);
}
public
function
supportsChildBlocks
()
{
return
true
;
}
public
function
extractChildText
(
$text
)
{
$text
=
phutil_split_lines
(
$text
,
true
);
$head
=
array
();
$body
=
array
();
$head
=
substr
(
reset
(
$text
),
3
);
$body
=
array_slice
(
$text
,
1
);
// Remove the carets.
foreach
(
$body
as
$key
=>
$line
)
{
$body
[
$key
]
=
substr
(
$line
,
1
);
}
// Strip leading empty lines.
foreach
(
$body
as
$key
=>
$line
)
{
if
(
strlen
(
trim
(
$line
)))
{
break
;
}
unset
(
$body
[
$key
]);
}
return
array
(
trim
(
$head
),
implode
(
''
,
$body
));
}
public
function
markupText
(
$text
,
$children
)
{
$text
=
$this
->
applyRules
(
$text
);
if
(
$this
->
getEngine
()->
isTextMode
())
{
$children
=
phutil_split_lines
(
$children
,
true
);
foreach
(
$children
as
$key
=>
$child
)
{
if
(
strlen
(
trim
(
$child
)))
{
$children
[
$key
]
=
'> '
.
$child
;
}
else
{
$children
[
$key
]
=
'>'
.
$child
;
}
}
$children
=
implode
(
''
,
$children
);
return
$text
.
"
\n\n
"
.
$children
;
}
return
phutil_tag
(
'blockquote'
,
array
(
'class'
=>
'remarkup-reply-block'
,
),
array
(
"
\n
"
,
phutil_tag
(
'div'
,
array
(
'class'
=>
'remarkup-reply-head'
,
),
$text
),
"
\n
"
,
phutil_tag
(
'div'
,
array
(
'class'
=>
'remarkup-reply-body'
,
),
$children
),
"
\n
"
,
));
}
}
Event Timeline
Log In to Comment