diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 98c37aa162..38da2546ed 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -25,6 +25,7 @@ namespace FireflyIII\Support\Twig; use Carbon\Carbon; use FireflyIII\Models\Account; use FireflyIII\Models\TransactionJournal; +use League\CommonMark\CommonMarkConverter; use Route; use Steam; use Twig_Extension; @@ -45,6 +46,7 @@ class General extends Twig_Extension $this->balance(), $this->formatFilesize(), $this->mimeIcon(), + $this->markdown(), ]; } @@ -146,6 +148,21 @@ class General extends Twig_Extension ); } + /** + * @return Twig_SimpleFilter + */ + protected function markdown(): Twig_SimpleFilter + { + return new Twig_SimpleFilter( + 'markdown', + function (string $text): string { + $converter = new CommonMarkConverter; + + return $converter->convertToHtml($text); + },['is_safe' => ['html']] + ); + } + /** * @return Twig_SimpleFilter */ @@ -164,6 +181,7 @@ class General extends Twig_Extension ); } + /** * @return Twig_SimpleFunction */ diff --git a/resources/views/form/location.twig b/resources/views/form/location.twig index 9b1328ac67..c8201e641f 100644 --- a/resources/views/form/location.twig +++ b/resources/views/form/location.twig @@ -3,7 +3,7 @@
{% if env('MAPBOX_API_KEY','') == '' %}

- {{ trans('mapbox_api_key')|raw }} + {{ trans('firefly.mapbox_api_key')|raw }}

{% else %}
diff --git a/resources/views/rules/index.twig b/resources/views/rules/index.twig index 217d342bab..ecafa6dfea 100644 --- a/resources/views/rules/index.twig +++ b/resources/views/rules/index.twig @@ -130,7 +130,7 @@ {% if not rule.active %} class="text-muted" {% endif %} - >
{{ rule.description }} + >
{{ rule.description|markdown }} {% endif %} diff --git a/resources/views/rules/rule/create.twig b/resources/views/rules/rule/create.twig index 1ca0b13927..15fdc6740d 100644 --- a/resources/views/rules/rule/create.twig +++ b/resources/views/rules/rule/create.twig @@ -31,7 +31,7 @@

{{ 'optionalFields'|_ }}

- {{ ExpandedForm.textarea('description') }} + {{ ExpandedForm.textarea('description', null, {helpText: trans('firefly.field_supports_markdown')}) }}
diff --git a/resources/views/rules/rule/edit.twig b/resources/views/rules/rule/edit.twig index 129c8b03fa..3946a2fae4 100644 --- a/resources/views/rules/rule/edit.twig +++ b/resources/views/rules/rule/edit.twig @@ -30,7 +30,7 @@

{{ 'optionalFields'|_ }}

- {{ ExpandedForm.textarea('description') }} + {{ ExpandedForm.textarea('description', null, {helpText: trans('firefly.field_supports_markdown')}) }}