mirror of
https://github.com/rustdesk/doc.rustdesk.com.git
synced 2026-04-03 06:16:08 +00:00
33 lines
1.4 KiB
HTML
33 lines
1.4 KiB
HTML
{{- $items := slice -}}
|
||
{{- $raw := .RawContent | default "" -}}
|
||
{{- if $raw -}}
|
||
{{- $sections := after 1 (split (printf "\n%s" $raw) "\n## ") -}}
|
||
{{- range $sections -}}
|
||
{{- if lt (len $items) 8 -}}
|
||
{{- $section := printf "## %s" . -}}
|
||
{{- $lines := split $section "\n" -}}
|
||
{{- $question := replaceRE `^##\s+` "" (index $lines 0) | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||
{{- if and $question (or (hasSuffix $question "?") (hasSuffix $question "?")) -}}
|
||
{{- $answerRaw := delimit (after 1 $lines) "\n" -}}
|
||
{{- $answerRaw = replaceRE "(?ms)```.*?```" " " $answerRaw -}}
|
||
{{- $answerRaw = replaceRE `(?m)^!\[[^\n]*$` " " $answerRaw -}}
|
||
{{- $answerRaw = replaceRE `(?m)^\{\{%[^\n]*$` " " $answerRaw -}}
|
||
{{- $answerRaw = replaceRE `(?m)^\{\{<[^\n]*$` " " $answerRaw -}}
|
||
{{- $answerRaw = replaceRE `(?m)^-{3,}$` " " $answerRaw -}}
|
||
{{- $answer := $answerRaw | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||
{{- if gt (len $answer) 40 -}}
|
||
{{- $items = $items | append (dict
|
||
"@type" "Question"
|
||
"name" $question
|
||
"acceptedAnswer" (dict
|
||
"@type" "Answer"
|
||
"text" (truncate 320 $answer)
|
||
)
|
||
) -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- end -}}
|
||
{{- return $items -}}
|