blog: make links open in new tab by default
This commit is contained in:
parent
4bf676419d
commit
5f790e4b37
|
@ -256,6 +256,10 @@ impl PostContentCache {
|
||||||
let regex_code = RegExp::new("<pre><code class=\"language-([^\"]*)\">", "ig");
|
let regex_code = RegExp::new("<pre><code class=\"language-([^\"]*)\">", "ig");
|
||||||
let js_html = js_html.replace_by_pattern(®ex_code, "<pre><code class=\"hljs\">");
|
let js_html = js_html.replace_by_pattern(®ex_code, "<pre><code class=\"hljs\">");
|
||||||
|
|
||||||
|
// Transform all non-self-refernece links (does not start with "#") to target="_blank"
|
||||||
|
let regex_links = RegExp::new("<a href=\"((?!#)[^\"]*)\">", "ig");
|
||||||
|
let js_html = js_html.replace_by_pattern(®ex_links, "<a target=\"_blank\" href=\"$1\">");
|
||||||
|
|
||||||
js_html.into()
|
js_html.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue