From 9292de63336da42651c646253ef6000621d5328b Mon Sep 17 00:00:00 2001 From: Blake Allen Date: Tue, 26 Oct 2021 16:58:08 -0700 Subject: [PATCH] remove unnecessary regex, use encodeuri for label instead of replace --- layouts/_default/_markup/render-link.html | 1 + layouts/_default/single.html | 5 +---- layouts/index.html | 5 +---- layouts/partials/backlinks.html | 2 +- layouts/partials/graph.html | 2 +- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 0288029..f37614f 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,4 +1,5 @@ {{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}} +{{$trimmed = replace $trimmed "%20" "-"}} {{$external := strings.HasPrefix $trimmed "http" }} {{ if $external }} {{ .Text | safeHTML }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 9193ee6..9f6443d 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,6 +1,3 @@ -{{$content := replaceRE `a href="\.\.\/(.+%20.+)+"` `$1` .Content}} -{{$content = replace $content "%20" "-"}} -{{$content = $content | safeHTML}} {{ partial "head.html" . }} @@ -22,7 +19,7 @@ {{ .TableOfContents }} {{end}} - {{- $content -}} + {{.Content}} {{partial "footer.html" .}} diff --git a/layouts/index.html b/layouts/index.html index 6f7725b..6496b6f 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,6 +1,3 @@ -{{$content := replaceRE `a href="\.\.\/(.+%20.+)+"` `$1` .Content}} -{{$content = replace $content "%20" "-"}} -{{$content = $content | safeHTML}} {{ partial "head.html" . }} @@ -22,7 +19,7 @@ {{ .TableOfContents }} {{end}} - {{- $content -}} + {{- .Content -}} {{partial "footer.html" .}} diff --git a/layouts/partials/backlinks.html b/layouts/partials/backlinks.html index 16b96cd..744f7e3 100644 --- a/layouts/partials/backlinks.html +++ b/layouts/partials/backlinks.html @@ -10,7 +10,7 @@ {{$src = replace $src " " "-"}}
  • - {{index . "source"}} + {{index . "source"}}
  • {{- end -}} {{else}} diff --git a/layouts/partials/graph.html b/layouts/partials/graph.html index d10c7f5..d529e8d 100644 --- a/layouts/partials/graph.html +++ b/layouts/partials/graph.html @@ -184,7 +184,7 @@ const labels = graphNode.append("text") .attr("dx", 12) .attr("dy", ".35em") - .text((d) => d.id.replace("%20", " ")) + .text((d) => encodeURI(d.id)) .style("opacity", 0) .style("pointer-events", "none") .call(drag(simulation));