Page MenuHomePhorge

D25457.1734607511.diff
No OneTemporary

D25457.1734607511.diff

diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php
--- a/src/applications/diffusion/controller/DiffusionBrowseController.php
+++ b/src/applications/diffusion/controller/DiffusionBrowseController.php
@@ -190,6 +190,10 @@
->setRequest($request)
->setDiffusionRequest($drequest);
+ if (method_exists($engine, 'setGenerateTableOfContents')) {
+ $engine->setGenerateTableOfContents(true);
+ }
+
$corpus = $engine->newDocumentView($ref);
$this->corpusButtons[] = $this->renderFileButton();
diff --git a/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php b/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php
--- a/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php
+++ b/src/applications/files/document/PhabricatorRemarkupDocumentEngine.php
@@ -36,6 +36,7 @@
$content = phutil_utf8ize($content);
$remarkup = new PHUIRemarkupView($viewer, $content);
+ $remarkup->setGenerateTableOfContents(true);
$container = phutil_tag(
'div',
diff --git a/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php b/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
--- a/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
+++ b/src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
@@ -208,12 +208,12 @@
$this->activeEngine = $engine;
$encode_setting = $request->getStr('encode');
- if (strlen($encode_setting)) {
+ if (phutil_nonempty_string($encode_setting)) {
$engine->setEncodingConfiguration($encode_setting);
}
$highlight_setting = $request->getStr('highlight');
- if (strlen($highlight_setting)) {
+ if (phutil_nonempty_string($highlight_setting)) {
$engine->setHighlightingConfiguration($highlight_setting);
}
diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php
--- a/src/infrastructure/markup/PhabricatorMarkupEngine.php
+++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php
@@ -459,6 +459,10 @@
$engine = self::newMarkupEngine(array());
$engine->setConfig('pygments.enabled', false);
break;
+ case 'remarkupField':
+ $engine = self::newMarkupEngine(array());
+ $engine->setConfig('header.generate-toc', true);
+ break;
default:
throw new Exception(pht('Unknown engine ruleset: %s!', $ruleset));
}
diff --git a/src/infrastructure/markup/PhabricatorMarkupOneOff.php b/src/infrastructure/markup/PhabricatorMarkupOneOff.php
--- a/src/infrastructure/markup/PhabricatorMarkupOneOff.php
+++ b/src/infrastructure/markup/PhabricatorMarkupOneOff.php
@@ -97,7 +97,11 @@
if ($this->engineRuleset) {
return PhabricatorMarkupEngine::getEngine($this->engineRuleset);
} else if ($this->preserveLinebreaks) {
- return PhabricatorMarkupEngine::getEngine();
+ $engine = PhabricatorMarkupEngine::getEngine();
+ if ($this->generateTableOfContents) {
+ $engine->setConfig('header.generate-toc', true);
+ }
+ return $engine;
} else {
return PhabricatorMarkupEngine::getEngine('nolinebreaks');
}
@@ -115,6 +119,7 @@
if ($this->getGenerateTableOfContents()) {
$toc = PhutilRemarkupHeaderBlockRule::renderTableOfContents($engine);
$this->tableOfContents = $toc;
+ $output = new PhutilSafeHTML($toc."\n".$output);
}
require_celerity_resource('phabricator-remarkup-css');
diff --git a/src/infrastructure/markup/blockrule/PhutilRemarkupHeaderBlockRule.php b/src/infrastructure/markup/blockrule/PhutilRemarkupHeaderBlockRule.php
--- a/src/infrastructure/markup/blockrule/PhutilRemarkupHeaderBlockRule.php
+++ b/src/infrastructure/markup/blockrule/PhutilRemarkupHeaderBlockRule.php
@@ -134,7 +134,7 @@
list($level, $name) = $info;
while ($depth < $level) {
- $toc[] = hsprintf('<ul>');
+ $toc[] = hsprintf('<ul class="remarkup-list">');
$depth++;
}
while ($depth > $level) {
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/interpreter-test.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/interpreter-test.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/interpreter-test.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/interpreter-test.txt
@@ -30,9 +30,7 @@
Content: (content)
Argv: (x=y)
-
-
-<div class="remarkup-interpreter-error">No interpreter found: phutil_fake_test_block_interpreter</div>
+<p>phutil_fake_test_block_interpreter {{{ content }}}</p>
~~~~~~~~~~
Content: (content)
Argv: (foo=bar)
@@ -53,6 +51,4 @@
Content: (content)
Argv: (x=y)
-
-
-(No interpreter found: phutil_fake_test_block_interpreter)
+phutil_fake_test_block_interpreter {{{ content }}}
diff --git a/src/infrastructure/markup/view/PHUIRemarkupView.php b/src/infrastructure/markup/view/PHUIRemarkupView.php
--- a/src/infrastructure/markup/view/PHUIRemarkupView.php
+++ b/src/infrastructure/markup/view/PHUIRemarkupView.php
@@ -85,7 +85,7 @@
$content = PhabricatorMarkupEngine::renderOneObject(
$oneoff,
- 'default',
+ 'remarkupField',
$viewer,
$context);

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 11:25 (9 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015039
Default Alt Text
D25457.1734607511.diff (5 KB)

Event Timeline