{{- /* Assembly code block shortcode - supports multiple display modes */ -}} {{- /* Parameters: - mode: "raw" (syntax highlighted), "hex" (hex + asm), "full" (addr + hex + asm) - arch: "x86" or "arm" (default: "x86") - capitalize: "true" to uppercase hex bytes and addresses (default: "false") */ -}} {{- $mode := .Get "mode" | default "raw" -}} {{- $arch := .Get "arch" | default "x86" -}} {{- $capitalize := .Get "capitalize" | default "false" -}} {{- $content := .Inner | strings.TrimSpace -}}
{{- range split $content "\n" -}}
{{- if . -}}
{{- $parts := split . "|" -}}
{{- if eq (len $parts) 2 -}}
{{- /* Extract and optionally capitalize hex bytes */ -}}
{{- $hexBytes := index $parts 0 | strings.TrimSpace -}}
{{- if eq $capitalize "true" -}}
{{- $hexBytes = upper $hexBytes -}}
{{- end -}}
{{- /* Extract instruction and apply syntax highlighting */ -}}
{{- $instruction := index $parts 1 | strings.TrimSpace -}}
{{- $lang := cond (eq $arch "arm") "armasm" "nasm" -}}
{{- $highlighted := highlight $instruction $lang "" -}}
{{- /* Strip wrapper divs from highlighted output */ -}}
{{ $hexBytes }}{{ $highlighted | replaceRE "]*>]*>" "" | replaceRE "
" "" | safeHTML }}
{{- else -}}
{{ . }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- range split $content "\n" -}}
{{- if . -}}
{{- $parts := split . "|" -}}
{{- if eq (len $parts) 3 -}}
{{- /* Extract address and hex bytes */ -}}
{{- $address := index $parts 0 | strings.TrimSpace -}}
{{- $hexBytes := index $parts 1 | strings.TrimSpace -}}
{{- /* Optionally capitalize address and hex bytes */ -}}
{{- if eq $capitalize "true" -}}
{{- $address = upper $address -}}
{{- $hexBytes = upper $hexBytes -}}
{{- end -}}
{{- /* Extract instruction and apply syntax highlighting */ -}}
{{- $instruction := index $parts 2 | strings.TrimSpace -}}
{{- $lang := cond (eq $arch "arm") "armasm" "nasm" -}}
{{- $highlighted := highlight $instruction $lang "" -}}
{{- /* Strip wrapper divs from highlighted output */ -}}
{{ $address }}{{ $hexBytes }}{{ $highlighted | replaceRE "]*>]*>" "" | replaceRE "
" "" | safeHTML }}
{{- else -}}
{{ . }}
{{- end -}}
{{- end -}}
{{- end -}}