mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Document wiki relative link syntax
Summary: Also make `../` work to start relative a link so I don't have to document it as `./../path`. Test Plan: - Used `./`, `../`. `./../`, and normal links (proper title pickup). - Used bad links (red). - Regenerated documentation: {F1221692} Reviewers: hach-que Reviewed By: hach-que Differential Revision: https://secure.phabricator.com/D15734
This commit is contained in:
parent
b2d2f03dea
commit
025b243e27
2 changed files with 25 additions and 2 deletions
|
@ -19,7 +19,7 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule {
|
|||
$link = trim($matches[1]);
|
||||
|
||||
// Handle relative links.
|
||||
if (substr($link, 0, 2) === './') {
|
||||
if ((substr($link, 0, 2) === './') || (substr($link, 0, 3) === '../')) {
|
||||
$base = null;
|
||||
$context = $this->getEngine()->getConfig('contextObject');
|
||||
if ($context !== null && $context instanceof PhrictionContent) {
|
||||
|
@ -33,7 +33,7 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule {
|
|||
}
|
||||
if ($base !== null) {
|
||||
$base_parts = explode('/', rtrim($base, '/'));
|
||||
$rel_parts = explode('/', substr(rtrim($link, '/'), 2));
|
||||
$rel_parts = explode('/', rtrim($link, '/'));
|
||||
foreach ($rel_parts as $part) {
|
||||
if ($part === '.') {
|
||||
// Consume standalone dots in a relative path, and do
|
||||
|
|
|
@ -512,11 +512,34 @@ You can link to Phriction documents with a name or path:
|
|||
|
||||
Make sure you sign and date your [[legal/Letter of Marque and Reprisal]]!
|
||||
|
||||
By default, the link will render with the document title as the link name.
|
||||
With a pipe (`|`), you can retitle the link. Use this to mislead your
|
||||
opponents:
|
||||
|
||||
Check out these [[legal/boring_documents/ | exciting legal documents]]!
|
||||
|
||||
Links to pages which do not exist are shown in red. Links to pages which exist
|
||||
but which the viewer does not have permission to see are shown with a lock
|
||||
icon, and the link will not disclose the page title.
|
||||
|
||||
If you begin a link path with `./` or `../`, the remainder of the path will be
|
||||
evaluated relative to the current wiki page. For example, if you are writing
|
||||
content for the document `fruit/` a link to `[[./guava]]` is the same as a link
|
||||
to `[[fruit/guava]]` from elsewhere.
|
||||
|
||||
Relative links may use `../` to transverse up the document tree. From the
|
||||
`produce/vegetables/` page, you can use `[[../fruit/guava]]` to link to the
|
||||
`produce/fruit/guava` page.
|
||||
|
||||
Relative links do not work when used outside of wiki pages. For example,
|
||||
you can't use a relative link in a comment on a task, because there is no
|
||||
reasonable place for the link to start resolving from.
|
||||
|
||||
When documents are moved, relative links are not automatically updated: they
|
||||
are preserved as currently written. After moving a document, you may need to
|
||||
review and adjust any relative links it contains.
|
||||
|
||||
|
||||
= Literal Blocks =
|
||||
|
||||
To place text in a literal block use `%%%`:
|
||||
|
|
Loading…
Reference in a new issue