diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html
index 24c65d07f..bc8d7d32a 100644
--- a/layouts/partials/textprocessing.html
+++ b/layouts/partials/textprocessing.html
@@ -26,29 +26,39 @@
{{if not $incode}}
+
{{$inner := . | strings.TrimPrefix "!" | strings.TrimPrefix "[[" | strings.TrimSuffix "]]" }}
+
{{$split := split $inner "|"}}
+
{{$path := index $split 0}}
{{$reference := split $path "#"}}
+
{{$title := index $reference 0}}
+
+
{{$display := default $title (index $split 1)}}
+
{{$display := index (last 1 (split $display "/")) 0}}
{{$curpage := $page.GetPage $title}}
{{$relpath := relURL $path}}
+
{{if not (eq $curpage.String "nopPage") }}
{{$block := default "" (index $reference 1)}}
{{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block)) | urlize | lower}}
{{$href := strings.TrimRight "/" $curpage.RelPermalink}}
{{$link := printf "%s" $href $block $href $display}}
{{$content = replace $content . $link}}
+
{{else if fileExists $relpath}}
{{$splitpath := split $relpath "/"}}
{{$dirname := first (sub (len $splitpath) 1) $splitpath | path.Join | urlize}}
{{$basename := index (last 1 $splitpath) 0}}
{{$href := printf "/%s/%s" $dirname $basename}}
+
{{if (hasPrefix . "!")}}
{{$width := index $split 1}}
{{$link := printf "
" $href (default "auto" $width)}}
@@ -57,6 +67,7 @@
{{$link := printf "%s" $href $display}}
{{$content = replace $content . $link}}
{{end}}
+
{{else}}
{{$link := printf "%s" $display}}
{{$content = replace $content . $link}}