Page Menu
Home
Xreate
Search
Configure Global Search
Log In
Docs
Questions
Repository
Issues
Patches
Internal API
Files
F2718162
RemarkupBlocksParser.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 15, 12:52 PM
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Feb 17, 12:52 PM (1 d, 13 h)
Engine
blob
Format
Raw Data
Handle
237774
Attached To
rXR Xreate
RemarkupBlocksParser.php
View Options
<?php
class
RemarkupBlocksParser
implements
PhabricatorParserIf
{
private
$engine
=
null
;
public
function
parse
(
$text
)
{
$blocks
=
$this
->
engine
->
splitTextIntoBlocks
(
$text
)
;
$output
=
array
(
)
;
foreach
(
$blocks
as
$block
)
{
$block
[
'rule'
]
=
get_class
(
$block
[
'rule'
]
)
;
$output
[
]
=
new
Block
(
$block
)
;
}
return
$output
;
}
public
function
__construct
(
)
{
$this
->
engine
=
$this
->
initialize
(
)
;
$this
->
engine
->
setMode
(
PhutilRemarkupEngine
::
MODE_TEXT
)
;
}
private
function
initialize
(
)
{
$engine
=
new
PhutilRemarkupEngine
(
)
;
$engine
->
setConfig
(
'uri.prefix'
,
'http://www.example.com/'
)
;
$engine
->
setConfig
(
'uri.allowed-protocols'
,
array
(
'http'
=>
true
,
'mailto'
=>
true
,
'tel'
=>
true
,
)
)
;
$rules
=
array
(
)
;
$rules
[
]
=
new
PhutilRemarkupEscapeRemarkupRule
(
)
;
$rules
[
]
=
new
PhutilRemarkupMonospaceRule
(
)
;
$rules
[
]
=
new
PhutilRemarkupDocumentLinkRule
(
)
;
$rules
[
]
=
new
PhutilRemarkupHyperlinkRule
(
)
;
$rules
[
]
=
new
PhutilRemarkupBoldRule
(
)
;
$rules
[
]
=
new
PhutilRemarkupItalicRule
(
)
;
$rules
[
]
=
new
PhutilRemarkupDelRule
(
)
;
$rules
[
]
=
new
PhutilRemarkupUnderlineRule
(
)
;
$rules
[
]
=
new
PhutilRemarkupHighlightRule
(
)
;
$blocks
=
array
(
)
;
$blocks
[
]
=
new
PhutilRemarkupQuotesBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupReplyBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupHeaderBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupHorizontalRuleBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupCodeBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupLiteralBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupNoteBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupTableBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupSimpleTableBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupDefaultBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupListBlockRule
(
)
;
$blocks
[
]
=
new
PhutilRemarkupInterpreterBlockRule
(
)
;
foreach
(
$blocks
as
$block
)
{
if
(
!
(
$block
instanceof
PhutilRemarkupCodeBlockRule
)
)
{
$block
->
setMarkupRules
(
$rules
)
;
}
}
$engine
->
setBlockRules
(
$blocks
)
;
return
$engine
;
}
}
Event Timeline
Log In to Comment