diff --git a/layouts/partials/refractor-content.html b/layouts/partials/refractor-content.html new file mode 100644 index 0000000..79b485b --- /dev/null +++ b/layouts/partials/refractor-content.html @@ -0,0 +1,63 @@ +{{ $content := .Content }} + + +{{ if findRE `` `` }} + {{ $content = replace $content `
` `` }} + {{ $content = replace $content `
` `
` }} +{{ end }} + + +{{ if findRE ` + {{ $content = replaceRE `
  • (\s*)$1 + {{ $content = replaceRE `
      (\s*)
    • $1
    • ` `` $content }} + {{ $content = replaceRE `` `` $content }} + + + {{ $content = replaceRE `` `` $content }} +{{ end }} + + +{{ $headingLevels := slice "2" "3" "4" "5" }} +{{ $headingContent := $content }} + +{{ range $level := $headingLevels }} + {{ $markStart := printf `` $id }} + + {{ $left := index (split $snippet $markEnd) 0 }} + {{ $right := substr $snippet (len $left) }} + {{ $left = replace $left `">` `">` | printf `%s` }} + + {{ $newContent = printf `%s%s%s%s%s` $newContent $markStart $left $anchor $right }} + {{ end }} + + {{ $headingContent = $newContent }} + {{ end }} +{{ end }} + +{{ $content = $headingContent | safeHTML }} + +{{ $content }} \ No newline at end of file diff --git a/layouts/post/single.html b/layouts/post/single.html index 15f2f63..4a87d04 100644 --- a/layouts/post/single.html +++ b/layouts/post/single.html @@ -114,7 +114,7 @@ {{ end }}
      - {{ .Content }} + {{ partial "refractor-content.html" . }}