feat(ruby): support ruby extended syntax

This commit is contained in:
imagicw 2024-07-08 16:25:27 +08:00
parent 66c8634a09
commit e41d75f9ab
12 changed files with 22 additions and 10 deletions

View file

@ -49,7 +49,7 @@
</div>
{{ end }}
<div class="min-w-0 min-h-0 max-w-prose">
{{ .Content }}
{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}
</div>

View file

@ -9,7 +9,7 @@
</h1>
</header>
<section class="max-w-full mt-6 prose dark:prose-invert">
{{ .Content }}
{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}
</section>
<footer class="pt-8">
{{ partial "sharing-links.html" . }}

View file

@ -80,7 +80,7 @@
{{ partial "series/series.html" . }}
<div class="article-content max-w-prose mb-20">
{{ .Content }}
{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}
</div>
{{ if (.Params.showAuthorBottom | default ( .Site.Params.article.showAuthorBottom | default false)) }}

View file

@ -25,7 +25,7 @@
{{ if .Content }}
<section class="flex flex-col max-w-full mt-0 prose dark:prose-invert lg:flex-row">
<div class="min-w-0 min-h-0 max-w-prose">
{{ .Content }}
{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}
</div>
</section>
{{ end }}

View file

@ -24,7 +24,7 @@
<section class="flex flex-col max-w-full mt-0 mb-5 prose dark:prose-invert lg:flex-row">
{{ if .Content }}
<div class="min-w-0 min-h-0 max-w-prose">
{{ .Content }}
{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}
</div>
{{ end }}
<script>

View file

@ -0,0 +1,7 @@
{{- $content := .Content -}}
{{- if .Ruby -}}
{{- $content = partial "functions/ruby.html" $content -}}
{{- end -}}
{{- return $content -}}

View file

@ -0,0 +1,5 @@
{{- /* Ruby */ -}}
{{- /* [EN]^(English) -> <strong><ruby>EN<rt>English</rt></ruby></strong> */ -}}
{{- $REin := `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout := `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- return replaceRE $REin $REout . -}}

View file

@ -67,7 +67,7 @@
</div>
{{ end }}
</div>
<section class="prose dark:prose-invert">{{ .Content }}</section>
<section class="prose dark:prose-invert">{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}</section>
</div>
</div>
</div>

View file

@ -9,7 +9,7 @@
<h1>{{ . | emojify }}</h1>
</header>
{{ end }}
<section>{{ .Content }}</section>
<section>{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}} </section>
</article>
</div>
<div class="mt-6 sm:mt-16 lg:mt-0 mx-auto max-w-xl px-4 sm:px-6 lg:mx-0 lg:max-w-none lg:py-16 lg:px-0">

View file

@ -64,7 +64,7 @@
</div>
{{ end }}
</div>
<section class="prose prose-invert">{{ .Content }}</section>
<section class="prose prose-invert">{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}</section>
</div>
</div>
</div>

View file

@ -4,7 +4,7 @@
<h1>{{ . | emojify }}</h1>
</header>
{{ end }}
<section>{{ .Content }}</section>
<section>{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}</section>
</article>
<section>
{{ partial "recent-articles/main.html" . }}

View file

@ -30,7 +30,7 @@
{{ partialCached "author-links.html" . }}
</div>
</header>
<section class="prose dark:prose-invert">{{ .Content }}</section>
<section class="prose dark:prose-invert">{{- dict "Content" .Content "Ruby" .Site.Params.ruby | partial "functions/content.html" | safeHTML -}}</section>
</article>
<section>
{{ partial "recent-articles/main.html" . }}