blob: 239badcc24ab98d214dd5f347f5f80edbc242eb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
{{- $context := . -}}
{{- $content := $context.Content -}}
{{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}}
{{- $empty := eq (len $content) 0 -}}
{{-
$content = $content |
replaceRE "<p><figure>" "<figure>" |
replaceRE "<p>\n<figure>" "<figure>" |
replaceRE "</figure></p>" "</figure>" |
-}}
{{- $blockquoteFooters := findRE `</blockquote>\n<p>(–|—).*</p>` .Content -}}
{{- range $blockquoteFooter := $blockquoteFooters -}}
{{- $blockquoteFooterFixed := $blockquoteFooter |
replaceRE "</blockquote>\n<p>" "<footer><cite>" |
replaceRE "</p>" "</cite></footer></blockquote>" |
-}}
{{- $content = $content | replaceRE $blockquoteFooter $blockquoteFooterFixed -}}
{{- end -}}
{{- $blockquoteFooters = findRE `(?s)</blockquote>\n<p>(–|—).*</p>` .Content -}}
{{- range $blockquoteFooter := $blockquoteFooters -}}
{{- $blockquoteFooterFixed := $blockquoteFooter |
replaceRE "</blockquote>\n<p>" "<footer><cite>" |
replaceRE "</p>" "</cite></footer></blockquote>" |
-}}
{{- $content = $content | replaceRE $blockquoteFooter $blockquoteFooterFixed -}}
{{- end -}}
{{- if $empty -}}
{{- $content = "This message contains no content." -}}
{{- end -}}
{{- if $expired -}}
{{- $content = "This message has expired." -}}
{{- end -}}
{{- return $content -}}
|