mirror of
https://tildegit.org/sbgodin/HtmGem.git
synced 2023-08-25 13:53:12 +02:00
Opens external links in new windows
This commit is contained in:
parent
9471816b1e
commit
6a8c220716
@ -341,16 +341,18 @@ class GemtextTranslate_html {
|
||||
if ($textDecoration) self::addTextDecoration($linkText);
|
||||
}
|
||||
preg_match("/^([^:]+):/", $link, $matches);
|
||||
$protocol = @$matches[1];
|
||||
if (empty($protocol)) {
|
||||
$protocol = "local";
|
||||
$protocol = @$matches[1]??"local";
|
||||
if ("local"==$protocol) {
|
||||
if (!is_null($this->baseUrl)) { // No URL rewriting
|
||||
if ($link[0]!="/") $link = "{$this->baseUrl}/$link";
|
||||
$link = self::resolve_path($link);
|
||||
$link = "/htmgem/index.php?url=$link";
|
||||
}
|
||||
$newWindow = "";
|
||||
} else {
|
||||
$newWindow = "target='_blank' ";
|
||||
}
|
||||
$output .= "<p><a class='$protocol' href='$link'>$linkText</a></p>\n";
|
||||
$output .= "<p><a {$newWindow}class='$protocol' href='$link'>$linkText</a></p>\n";
|
||||
break;
|
||||
case "#":
|
||||
$title = $node["title"];
|
||||
|
@ -5,5 +5,5 @@ $fileName = $argv[1];
|
||||
require_once dirname(__FILE__)."/../../lib-htmgem.inc.php";
|
||||
|
||||
$text = file_get_contents($fileName);
|
||||
$gt_gemtext = new \htmgem\GemtextTranslate_html($text);
|
||||
echo strval($gt_gemtext);
|
||||
$gt_html = new \htmgem\GemtextTranslate_html($text);
|
||||
echo $gt_html->translatedGemtext;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<p>NOTE: this page was downloaded on 2021-03-04 from the original capsule</p>
|
||||
<p><a class='gemini' href='gemini://gemini.circumlunar.space/docs/specification.gmi'>Gemini</a></p>
|
||||
<p><a class='https' href='https://gemini.circumlunar.space/docs/specification.gmi'>Web</a></p>
|
||||
<p><a target='_blank' class='gemini' href='gemini://gemini.circumlunar.space/docs/specification.gmi'>Gemini</a></p>
|
||||
<p><a target='_blank' class='https' href='https://gemini.circumlunar.space/docs/specification.gmi'>Web</a></p>
|
||||
<p><a class='local' href='specification_Gemini_v0.14.3.txt'>Copie locale texte</a></p>
|
||||
<p> </p>
|
||||
<h1>Project Gemini</h1>
|
||||
|
Loading…
x
Reference in New Issue
Block a user