Skip to content

Commit

Permalink
2023-10-29 00:41:39
Browse files Browse the repository at this point in the history
  • Loading branch information
uidHUB committed Oct 29, 2023
1 parent 6b37464 commit b59a8c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 6 additions & 8 deletions layouts/_default/_markup/render-codeblock-terminal.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
{{ $attr := (.Attributes) }}
{{ $type := ((.Type) | default "text") }}
{{ $inner := (.Inner) }}
{{ $ordinal := (.Ordinal) }}

{{ $cp := (printf "clipboard-%s" (delimit (shuffle (seq 999)) "" | md5)) }}

<div class="shortcode shortcode-codeblock shortcode-codeblock-{{ ($type) }}
<div class="shortcode shortcode-codeblock shortcode-codeblock-{{ ($ordinal) }} shortcode-codeblock-{{ ($type) }}
{{ with ($attr.os) }}shortcode-codeblock-{{ ($type) }}-{{ . }}{{ end }}
{{ with ($attr.os) }}shortcode-codeblock-{{ ($type) }}-{{ . }}{{ end }}{{ with ($attr.mode) }}-{{ . }}{{ end }}">
<div class="card mb-3 overflow-hidden" data-bs-theme="dark">
Expand All @@ -59,13 +60,10 @@ <h5 class="mb-0">{{ (i18n "terminal") }}</h5>
</div>
</div>
</div>
{{ $lang := "" }}
{{ if (or (eq ($attr.hl) "false") (eq ($attr.hl) "0")) }}
{{ $lang = "plaintext" }}
{{ else }}
{{ if (eq ($attr.os) "windows") }}{{ $lang = "powershell" }}{{ end }}
{{ if (eq ($attr.os) "linux") }}{{ $lang = "bash" }}{{ end }}
{{ end }}
{{ $lang := "plaintext" }}
{{ if (eq ($attr.os) "windows") }}{{ $lang = "powershell" }}{{ end }}
{{ if (eq ($attr.os) "linux") }}{{ $lang = "bash" }}{{ end }}
{{ with ($attr.hl) }}{{ $lang = . }}{{ end }}
<div class="card-body p-0" id="{{ ($cp) }}">{{ (highlight (($inner) | chomp) ($lang)) }}</div>
</div>
</div>
5 changes: 3 additions & 2 deletions layouts/_default/_markup/render-codeblock.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
{{ $attr := (.Attributes) }}
{{ $type := ((.Type) | default "text") }}
{{ $inner := (.Inner) }}
{{ $ordinal := (.Ordinal) }}

{{ $cp := (printf "clipboard-%s" (delimit (shuffle (seq 999)) "" | md5)) }}

{{ if (or ($attr.title) ($attr.file)) }}

<div class="shortcode shortcode-codeblock shortcode-codeblock-{{ ($type) }}">
<div class="shortcode shortcode-codeblock shortcode-codeblock-{{ ($ordinal) }} shortcode-codeblock-{{ ($type) }}">
<div class="card mb-3 overflow-hidden">
<div class="card-header">
<div class="d-flex align-items-center">
Expand Down Expand Up @@ -51,7 +52,7 @@

{{ else }}

<div class="shortcode shortcode-codeblock {{ with ($type) }}shortcode-codeblock-{{ . }}{{ end }}">
<div class="shortcode shortcode-codeblock shortcode-codeblock-{{ ($ordinal) }} {{ with ($type) }}shortcode-codeblock-{{ . }}{{ end }}">
<div class="d-flex mb-3 overflow-hidden">
<div class="flex-grow-1 rounded overflow-hidden" id="{{ ($cp) }}">{{ (highlight (($inner) | chomp) ($type)) }}</div>
<div class="flex-shrink-0">
Expand Down

0 comments on commit b59a8c3

Please sign in to comment.