Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Downloaded styles can be unzipped into `customisations/` and mounted into boards
php bin/qi style:mount test customisations/stylename
```

See the complete [QuickInstall CLI docs](index.php?page=cli).
See the complete [QuickInstall CLI docs](docs/sandbox-cli.md).

## 🐞 Support
You can receive support at the [phpBB3 QuickInstall Discussion/Support](https://www.phpbb.com/customise/db/official_tool/phpbb3_quickinstall/support) forum.
Expand Down
21 changes: 20 additions & 1 deletion includes/qi.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,13 @@ public static function lang_key_exists($key)
return isset($user->lang[$key]);
}

public static function render_markdown($doc_body, $anchor_prefix = '')
public static function render_markdown($doc_body, $anchor_prefix = '', array $link_rewrites = array())
{
if (!empty($link_rewrites))
{
$doc_body = self::rewrite_markdown_links($doc_body, $link_rewrites);
}

if ($anchor_prefix !== '')
{
$doc_body = self::add_markdown_anchors($doc_body, $anchor_prefix);
Expand All @@ -184,6 +189,20 @@ public static function render_markdown($doc_body, $anchor_prefix = '')
);
}

private static function rewrite_markdown_links($doc_body, array $link_rewrites)
{
return preg_replace_callback('/\]\(([^)\s]+)\)/', function ($matches) use ($link_rewrites) {
$url = $matches[1];

if (!isset($link_rewrites[$url]))
{
return $matches[0];
}

return '](' . $link_rewrites[$url] . ')';
}, $doc_body);
}

public static function get_markdown_anchors($doc_body, $prefix)
{
$links = array();
Expand Down
4 changes: 3 additions & 1 deletion modules/qi_docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public function run()
$doc_file = $quickinstall_path . 'README.md';
if (file_exists($doc_file))
{
$doc_body = qi::render_markdown(file_get_contents($doc_file), 'readme');
$doc_body = qi::render_markdown(file_get_contents($doc_file), 'readme', array(
'docs/sandbox-cli.md' => 'index.php?page=cli',
));
$template->assign_var('DOC_BODY', $doc_body);
}

Expand Down