From 7f6ca43728f3f550b857cde59d8d618cdfe068ca Mon Sep 17 00:00:00 2001 From: maxpozdeev Date: Tue, 5 Sep 2023 22:49:09 +0300 Subject: [PATCH] * open links in markdown notes in new window (fixes GH-72) (cherry picked from commit f9f97f3b7f5d5889142378bc1df4cb09eb16a523) --- src/includes/markup.parsedown.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/includes/markup.parsedown.php b/src/includes/markup.parsedown.php index 60e7caf..26b8be4 100644 --- a/src/includes/markup.parsedown.php +++ b/src/includes/markup.parsedown.php @@ -2,7 +2,7 @@ /* This file is a part of myTinyTodo. - (C) Copyright 2022 Max Pozdeev + (C) Copyright 2022-2023 Max Pozdeev Licensed under the GNU GPL version 2 or any later. See file COPYRIGHT for details. */ @@ -73,4 +73,20 @@ class MTTParsedown extends Parsedown ); } } + + protected function inlineLink($Excerpt) { + $a = parent::inlineLink($Excerpt); + if (is_array($a) && isset($a['element']['attributes']['href'])) { + $a['element']['attributes']['target'] = '_blank'; + } + return $a; + } + + protected function inlineUrl($Excerpt) { + $a = parent::inlineUrl($Excerpt); + if (is_array($a) && isset($a['element']['attributes']['href'])) { + $a['element']['attributes']['target'] = '_blank'; + } + return $a; + } }