Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Replace parsedown with commonmark #288

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
17 changes: 13 additions & 4 deletions app/views/docs/environment-variables.phtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<?php
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
use League\CommonMark\MarkdownConverter;

$variables = $this->getParam('variables', []);

$markdown = new \Parsedown();
$markdown->setSafeMode(true);
$environment = new Environment(['html_input' => 'escape']);

$environment->addExtension(new CommonMarkCoreExtension());
$environment->addExtension(new GithubFlavoredMarkdownExtension());

$markdown = new MarkdownConverter($environment);
?>

<p>Appwrite environment variables allow you to edit your server setup configuration and customize it. You can easily change the environment variables by changing them when running Appwrite using Docker CLI or Docker Compose.</p>
Expand Down Expand Up @@ -34,7 +43,7 @@ $markdown->setSafeMode(true);
<h2 id="<?php echo $this->escape(strtolower(str_replace(' ', '_', $category))); ?>"><a href="/docs/environment-variables#<?php echo $this->escape(strtolower(str_replace(' ', '_', $category))); ?>"><?php echo $this->escape($category); ?></a></h2>

<?php if($description): ?>
<p><?php echo $markdown->text($this->escape($description)); ?></p>
<p><?php echo $markdown->convert($this->escape($description)); ?></p>
<?php endif; ?>

<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large">
Expand All @@ -58,7 +67,7 @@ $markdown->setSafeMode(true);
<p class="margin-top-small text-fade">version >= <?php echo $this->escape($introduction); ?></p>
<?php endif; ?>
</td>
<td><?php echo $markdown->text($this->escape($description)); ?></td>
<td><?php echo $markdown->convert($this->escape($description)); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down
15 changes: 12 additions & 3 deletions app/views/docs/models.phtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?php
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
use League\CommonMark\MarkdownConverter;

$models = $this->getParam('models', []);
$model = $this->getParam('model', null);
$rules = $model['properties'] ?? [];

$markdown = new \Parsedown();
$markdown->setSafeMode(true);
$environment = new Environment(['html_input' => 'escape']);

$environment->addExtension(new CommonMarkCoreExtension());
$environment->addExtension(new GithubFlavoredMarkdownExtension());

$markdown = new MarkdownConverter($environment);

$example = function ($model, $models) use (&$example)
{
Expand Down Expand Up @@ -126,7 +135,7 @@ $example = function ($model, $models) use (&$example)
<?php endif; ?>
<?php endif; ?>
</td>
<td data-title="<?php echo (!empty($description)) ? 'Description: ' : ''; ?>"><?php echo $markdown->text($description); ?></td>
<td data-title="<?php echo (!empty($description)) ? 'Description: ' : ''; ?>"><?php echo $markdown->convert($description); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down
15 changes: 12 additions & 3 deletions app/views/docs/sdks.phtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<?php
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
use League\CommonMark\MarkdownConverter;

$platforms = $this->getParam('platforms', []);
$markdown = new \Parsedown();
$markdown->setSafeMode(true);

$environment = new Environment(['html_input' => 'escape']);

$environment->addExtension(new CommonMarkCoreExtension());
$environment->addExtension(new GithubFlavoredMarkdownExtension());

$markdown = new MarkdownConverter($environment);

?>

Expand All @@ -23,7 +32,7 @@ $markdown->setSafeMode(true);
<?php if(!$platform['enabled']) { continue; } ?>
<h2 href="/docs/sdks#<?php echo strtolower($platform['name']); ?>" id="<?php echo strtolower($platform['name']); ?>"><?php echo $platform['name']; ?> SDKs<?php if($platform['beta']): ?> (beta)<?php endif; ?></h2>

<p><?php echo $markdown->text($platform['description']); ?></p>
<p><?php echo $markdown->convert($platform['description']); ?></p>

<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large text-size-small vertical">
<thead>
Expand Down
19 changes: 14 additions & 5 deletions app/views/docs/service.phtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
use League\CommonMark\MarkdownConverter;

$serviceName = $this->getParam('name', '');
$service = $this->getParam('service', []);
$blacklist = $this->getParam('blacklist', []);
Expand Down Expand Up @@ -32,8 +37,12 @@ $codes = [
],
];

$markdown = new \Parsedown();
$markdown->setSafeMode(true);
$environment = new Environment(['html_input' => 'escape']);
PineappleIOnic marked this conversation as resolved.
Show resolved Hide resolved

$environment->addExtension(new CommonMarkCoreExtension());
$environment->addExtension(new GithubFlavoredMarkdownExtension());

$markdown = new MarkdownConverter($environment);

$paramSDK = (!empty($sdk)) ? '?sdk='.$sdk : '';
?>
Expand Down Expand Up @@ -198,7 +207,7 @@ $paramSDK = (!empty($sdk)) ? '?sdk='.$sdk : '';
<div class="col span-8 margin-bottom">

<div class="content margin-end-xl">
<?php echo $markdown->text(file_get_contents($path)); ?>
<?php echo $markdown->convert(file_get_contents($path)); ?>

<div class="clear">
<a href="https://github.com/appwrite/appwrite/edit/master<?php echo $description; ?>" class="pull-end text-size-small" target="_blank">Edit on GitHub <i class="icon-github-circled"></i></a>
Expand Down Expand Up @@ -302,7 +311,7 @@ $paramSDK = (!empty($sdk)) ? '?sdk='.$sdk : '';
</div>

<?php if(!empty($description)): ?>
<?php echo $markdown->text($description); ?>
<?php echo $markdown->convert($description); ?>
<?php endif; ?>

<div class="clear">
Expand Down Expand Up @@ -408,7 +417,7 @@ $paramSDK = (!empty($sdk)) ? '?sdk='.$sdk : '';
<?php endif; ?>
</td>
<td data-title="Type: "><?php echo $this->escape($type); ?></td>
<td data-title="<?php echo (!empty($description)) ? 'Description: ' : ''; ?>"><?php echo $markdown->text($description); ?></td>
<td data-title="<?php echo (!empty($description)) ? 'Description: ' : ''; ?>"><?php echo $markdown->convert($description); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"ext-imagick": "*",
"ext-mbstring": "*",
"ext-json": "*",
"erusev/parsedown": "1.7.4",
"utopia-php/framework": "0.*.*"
"utopia-php/framework": "0.*.*",
"league/commonmark": "2.4.x-dev"
PineappleIOnic marked this conversation as resolved.
Show resolved Hide resolved
},
"require-dev": {
"vimeo/psalm": "4.1.1"
Expand Down
Loading