@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorRemarkupDocumentEngine
4 extends PhabricatorDocumentEngine {
5
6 const ENGINEKEY = 'remarkup';
7
8 public function getViewAsLabel(PhabricatorDocumentRef $ref) {
9 return pht('View as Remarkup');
10 }
11
12 protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {
13 return 'fa-file-text-o';
14 }
15
16 protected function getContentScore(PhabricatorDocumentRef $ref) {
17 $name = $ref->getName();
18
19 if ($name !== null) {
20 if (preg_match('/\\.remarkup\z/i', $name)) {
21 return 2000;
22 }
23 }
24
25 return 500;
26 }
27
28 protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {
29 return $ref->isProbablyText();
30 }
31
32 protected function newDocumentContent(PhabricatorDocumentRef $ref) {
33 $viewer = $this->getViewer();
34
35 $content = $ref->loadData();
36 $content = phutil_utf8ize($content);
37
38 $remarkup = new PHUIRemarkupView($viewer, $content);
39
40 $container = phutil_tag(
41 'div',
42 array(
43 'class' => 'document-engine-remarkup',
44 ),
45 $remarkup);
46
47 return $container;
48 }
49
50}