rename refractor-content to refactor-content

This commit is contained in:
geekifan
2025-04-28 18:12:15 +08:00
parent 9265fe26b2
commit 85d0199301
2 changed files with 1 additions and 45 deletions

View File

@ -1,44 +0,0 @@
{{ $content := .Content }}
<!-- Handle tables -->
{{ if findRE `<table` $content }}
{{ $content = replace $content `<table` `<div class="table-wrapper"><table` }}
{{ $content = replace $content `</table>` `</table></div>` }}
{{ $content = replace $content `<code><div class="table-wrapper">` `<code>` }}
{{ $content = replace $content `</table></div></code>` `</table></code>` }}
{{ end }}
<!-- Change checkbox icons -->
{{ if findRE `<input.*type="checkbox"` $content }}
<!-- first replace the li with task-list-item class -->
{{ $content = replaceRE `<li>(\s*)<input` `<li class="task-list-item">$1<input` $content }}
{{ $content = replaceRE `<li class="([^"]*)"(\s*)<input` `<li class="task-list-item $1"$2<input` $content }}
<!-- then add task-list class to the parent ul of the li with task-list-item class -->
{{ $content = replaceRE `<ul>(\s*)<li class="task-list-item` `<ul class="task-list">$1<li class="task-list-item` $content }}
{{ $content = replaceRE `<ul class="([^"]*)"(\s*)<li class="task-list-item` `<ul class="task-list $1"$2<li class="task-list-item` $content }}
<!-- replace all checked checkbox format -->
{{ $content = replaceRE `<input.*?checked.*?type="checkbox".*?>` `<i class="fas fa-check-circle fa-fw checked"></i>` $content }}
{{ $content = replaceRE `<input.*?type="checkbox".*?checked.*?>` `<i class="fas fa-check-circle fa-fw checked"></i>` $content }}
<!-- replace all unchecked checkbox format -->
{{ $content = replaceRE `<input.*?type="checkbox".*?>` `<i class="far fa-circle fa-fw"></i>` $content }}
{{ end }}
<!-- Create heading anchors -->
{{ $headingLevels := slice "2" "3" "4" "5" }}
{{ $headingContent := $content }}
{{ range $level := $headingLevels }}
{{ $markStart := printf `<h%s id="` $level }}
{{ $markEnd := printf `</h%s>` $level }}
{{ $pattern := printf `%s([^"]+)">(.*?)%s` $markStart $markEnd }}
{{ $replacement := printf `%s$1"><span class="me-2">$2</span><a href="#$1" class="anchor text-muted"><i class="fas fa-hashtag"></i></a>%s` $markStart $markEnd }}
{{ $headingContent = replaceRE $pattern $replacement $headingContent }}
{{ end }}
{{ $content = $headingContent | safeHTML }}
{{ $content | safeHTML }}

View File

@ -116,7 +116,7 @@
{{ end }}
<div class="content">
{{ partial "refractor-content.html" . }}
{{ partial "refactor-content.html" . }}
</div>
<div class="post-tail-wrapper text-muted">