1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 15:30:58 +01:00

Render object monograms and embedding references more gracefully when building a Remarkup table of contents

Summary:
Fixes T8845. Ref T13102. See PHI467. Currently, object monograms like `L1` which appear in Remarkup headers render incorrectly (with an internal placeholder "x") in the table of contents:

{F5475505}

Instead, render them down to just, e.g., `L1` in plain text.

For `{P123}` I just rendered it to `{P123}` since it's not really clear to me what users intend. This could be adjusted if there's some reasonable thing that someone is trying to do with this.

Test Plan: Wrote a Phriction document with several object references (like `L1` and `{P123}`) in headers. After patch, saw "x"-free, sensible-looking header names in the table of contents.

Maniphest Tasks: T13102, T8845

Differential Revision: https://secure.phabricator.com/D19234
This commit is contained in:
epriestley 2018-03-16 15:33:57 -07:00
parent dbc72a05bc
commit 2fa904921e

View file

@ -279,6 +279,15 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
return $matches[0];
}
// If we're rendering a table of contents, just render the raw input.
// This could perhaps be handled more gracefully but it seems unusual to
// put something like "{P123}" in a header and it's not obvious what users
// expect? See T8845.
$engine = $this->getEngine();
if ($engine->getState('toc')) {
return $matches[0];
}
return $this->markupObject(array(
'type' => 'embed',
'id' => $matches[1],
@ -292,6 +301,12 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
return $matches[0];
}
// If we're rendering a table of contents, just render the monogram.
$engine = $this->getEngine();
if ($engine->getState('toc')) {
return $matches[0];
}
return $this->markupObject(array(
'type' => 'ref',
'id' => $matches[1],