Initial commit

This commit is contained in:
√(noham)²
2026-02-01 15:07:11 +01:00
commit 92e8af31c3
9 changed files with 548 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
/* Assembly code block styling */
.asm-raw {
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}
.asm-raw pre {
margin: 0;
padding: 1em;
}
.asm-hex,
.asm-full {
position: relative;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
line-height: 1.6;
}
.asm-hex pre,
.asm-full pre {
margin: 0;
padding: 1em;
overflow-x: auto;
background: var(--hljs-bg) !important;
color: var(--content);
}
.asm-hex code,
.asm-full code {
display: block;
background: transparent;
color: inherit;
padding: 0;
}
.asm-line {
display: block;
white-space: pre;
}
/* Address styling */
.address {
color: #858585;
margin-right: 1em;
display: inline-block;
min-width: 10ch;
user-select: none;
}
.address::after {
content: ':';
margin-left: 0.2em;
}
/* Hex bytes styling */
.hex-bytes {
color: #569cd6;
margin-right: 1.5em;
display: inline-block;
min-width: 20ch;
font-weight: 500;
}
/* Instruction styling */
.instruction {
color: #ce9178;
}
/* Ensure highlighted code displays inline */
.asm-hex .line,
.asm-full .line {
display: inline;
}
.asm-hex .cl,
.asm-full .cl {
display: inline;
}
/* Syntax highlighting enhancements for instructions */
.instruction::before {
content: '';
}
/* Dark mode compatibility */
.dark .asm-hex pre,
.dark .asm-full pre {
background: var(--hljs-bg) !important;
color: var(--content);
}
/* Light mode */
@media (prefers-color-scheme: light) {
body:not(.dark) .asm-hex pre,
body:not(.dark) .asm-full pre {
background: var(--hljs-bg) !important;
color: var(--content);
}
body:not(.dark) .address {
color: #666;
}
body:not(.dark) .hex-bytes {
color: #0451a5;
}
body:not(.dark) .instruction {
color: #a31515;
}
}

View File

@@ -0,0 +1,90 @@
{{- /* 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 -}}
<div class="asm-block asm-{{ $mode }}">
{{- if eq $mode "raw" -}}
{{- /* Raw assembly with syntax highlighting only */ -}}
<div class="asm-raw">
{{- if eq $arch "x86" -}}
{{- highlight $content "nasm" "" -}}
{{- else if eq $arch "arm" -}}
{{- highlight $content "armasm" "" -}}
{{- else -}}
{{- highlight $content "asm" "" -}}
{{- end -}}
</div>
{{- else if eq $mode "hex" -}}
{{- /* Hex bytes + assembly on same line (format: HEX | INSTRUCTION) */ -}}
<div class="highlight">
<div class="asm-hex">
<pre tabindex="0" class="chroma"><code>{{- range split $content "\n" -}}
{{- if . -}}
<span class="asm-line">
{{- $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 */ -}}
<span class="hex-bytes">{{ $hexBytes }}</span>{{ $highlighted | replaceRE "<div class=\"highlight\"><pre[^>]*><code[^>]*>" "" | replaceRE "</code></pre></div>" "" | safeHTML }}
{{- else -}}
{{ . }}
{{- end -}}
</span>
{{- end -}}
{{- end -}}</code></pre>
<button class="copy-code">copy</button>
</div>
</div>
{{- else if eq $mode "full" -}}
{{- /* Address + hex bytes + assembly (format: ADDRESS | HEX | INSTRUCTION) */ -}}
<div class="highlight">
<div class="asm-full">
<pre tabindex="0" class="chroma"><code>{{- range split $content "\n" -}}
{{- if . -}}
<span class="asm-line">
{{- $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 */ -}}
<span class="address">{{ $address }}</span><span class="hex-bytes">{{ $hexBytes }}</span>{{ $highlighted | replaceRE "<div class=\"highlight\"><pre[^>]*><code[^>]*>" "" | replaceRE "</code></pre></div>" "" | safeHTML }}
{{- else -}}
{{ . }}
{{- end -}}
</span>
{{- end -}}
{{- end -}}</code></pre>
<button class="copy-code">copy</button>
</div>
</div>
{{- end -}}
</div>