1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Diffusion - add ToC for readme files

Summary: see title. Fixes T4549.

Test Plan: made a readme that had some headers and observed a nice ToC

Reviewers: chad, epriestley

Reviewed By: epriestley

Subscribers: aran, epriestley, Korvin

Maniphest Tasks: T4549

Differential Revision: https://secure.phabricator.com/D8490
This commit is contained in:
Bob Trahan 2014-03-11 15:52:16 -07:00
parent a1faac0a21
commit 740757fd9b
2 changed files with 14 additions and 2 deletions

View file

@ -8,8 +8,8 @@ final class ConduitAPI_diffusion_readmequery_Method
public function getMethodDescription() {
return
'Retrieve any "readme" that can be found for a set of paths in '.
'repository.';
pht('Retrieve any "readme" that can be found for a set of paths in '.
'repository.');
}
public function defineReturnType() {
@ -89,6 +89,17 @@ final class ConduitAPI_diffusion_readmequery_Method
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
$engine->setConfig('viewer', $request->getUser());
$readme_content = $engine->markupText($readme_content);
$toc = PhutilRemarkupEngineRemarkupHeaderBlockRule::renderTableOfContents(
$engine);
if ($toc) {
$toc = phutil_tag_div('phabricator-remarkup-toc', array(
phutil_tag_div(
'phabricator-remarkup-toc-header',
pht('Table of Contents')),
$toc,
));
$readme_content = array($toc, $readme_content);
}
$class = 'phabricator-remarkup';
}

View file

@ -352,6 +352,7 @@ final class PhabricatorMarkupEngine {
*/
public static function newDiffusionMarkupEngine(array $options = array()) {
return self::newMarkupEngine(array(
'header.generate-toc' => true,
));
}