@@ -201,7 +201,16 @@ private function requireKeyProcessed($key) {
201
201
private function getMarkupFieldKey (
202
202
PhabricatorMarkupInterface $ object ,
203
203
$ field ) {
204
- return $ object ->getMarkupFieldKey ($ field ).'@ ' .$ this ->version ;
204
+
205
+ $ custom = array_merge (
206
+ self ::loadCustomInlineRules (),
207
+ self ::loadCustomBlockRules ());
208
+
209
+ $ custom = mpull ($ custom , 'getRuleVersion ' , null );
210
+ ksort ($ custom );
211
+ $ custom = PhabricatorHash::digestForIndex (serialize ($ custom ));
212
+
213
+ return $ object ->getMarkupFieldKey ($ field ).'@ ' .$ this ->version .'@ ' .$ custom ;
205
214
}
206
215
207
216
@@ -328,10 +337,6 @@ public static function newFeedMarkupEngine() {
328
337
*/
329
338
public static function newDifferentialMarkupEngine (array $ options = array ()) {
330
339
return self ::newMarkupEngine (array (
331
- 'custom-inline ' => PhabricatorEnv::getEnvConfig (
332
- 'differential.custom-remarkup-rules ' ),
333
- 'custom-block ' => PhabricatorEnv::getEnvConfig (
334
- 'differential.custom-remarkup-block-rules ' ),
335
340
'differential.diff ' => idx ($ options , 'differential.diff ' ),
336
341
));
337
342
}
@@ -381,8 +386,6 @@ private static function getMarkupEngineDefaultConfiguration() {
381
386
'pygments ' => PhabricatorEnv::getEnvConfig ('pygments.enabled ' ),
382
387
'youtube ' => PhabricatorEnv::getEnvConfig (
383
388
'remarkup.enable-embedded-youtube ' ),
384
- 'custom-inline ' => array (),
385
- 'custom-block ' => array (),
386
389
'differential.diff ' => null ,
387
390
'header.generate-toc ' => false ,
388
391
'macros ' => true ,
@@ -419,12 +422,6 @@ public static function newMarkupEngine(array $options) {
419
422
$ rules [] = new PhutilRemarkupRuleEscapeRemarkup ();
420
423
$ rules [] = new PhutilRemarkupRuleMonospace ();
421
424
422
- $ custom_rule_classes = $ options ['custom-inline ' ];
423
- if ($ custom_rule_classes ) {
424
- foreach ($ custom_rule_classes as $ custom_rule_class ) {
425
- $ rules [] = newv ($ custom_rule_class , array ());
426
- }
427
- }
428
425
429
426
$ rules [] = new PhutilRemarkupRuleDocumentLink ();
430
427
@@ -450,6 +447,10 @@ public static function newMarkupEngine(array $options) {
450
447
$ rules [] = new PhutilRemarkupRuleItalic ();
451
448
$ rules [] = new PhutilRemarkupRuleDel ();
452
449
450
+ foreach (self ::loadCustomInlineRules () as $ rule ) {
451
+ $ rules [] = $ rule ;
452
+ }
453
+
453
454
$ blocks = array ();
454
455
$ blocks [] = new PhutilRemarkupEngineRemarkupQuotesBlockRule ();
455
456
$ blocks [] = new PhutilRemarkupEngineRemarkupLiteralBlockRule ();
@@ -461,16 +462,12 @@ public static function newMarkupEngine(array $options) {
461
462
$ blocks [] = new PhutilRemarkupEngineRemarkupTableBlockRule ();
462
463
$ blocks [] = new PhutilRemarkupEngineRemarkupSimpleTableBlockRule ();
463
464
$ blocks [] = new PhutilRemarkupEngineRemarkupInterpreterRule ();
465
+ $ blocks [] = new PhutilRemarkupEngineRemarkupDefaultBlockRule ();
464
466
465
- $ custom_block_rule_classes = $ options ['custom-block ' ];
466
- if ($ custom_block_rule_classes ) {
467
- foreach ($ custom_block_rule_classes as $ custom_block_rule_class ) {
468
- $ blocks [] = newv ($ custom_block_rule_class , array ());
469
- }
467
+ foreach (self ::loadCustomBlockRules () as $ rule ) {
468
+ $ blocks [] = $ rule ;
470
469
}
471
470
472
- $ blocks [] = new PhutilRemarkupEngineRemarkupDefaultBlockRule ();
473
-
474
471
foreach ($ blocks as $ block ) {
475
472
$ block ->setMarkupRules ($ rules );
476
473
}
@@ -564,4 +561,16 @@ public static function summarize($corpus) {
564
561
return $ best ;
565
562
}
566
563
564
+ private static function loadCustomInlineRules () {
565
+ return id (new PhutilSymbolLoader ())
566
+ ->setAncestorClass ('PhabricatorRemarkupCustomInlineRule ' )
567
+ ->loadObjects ();
568
+ }
569
+
570
+ private static function loadCustomBlockRules () {
571
+ return id (new PhutilSymbolLoader ())
572
+ ->setAncestorClass ('PhabricatorRemarkupCustomBlockRule ' )
573
+ ->loadObjects ();
574
+ }
575
+
567
576
}
0 commit comments