A Hugo shortcode for displaying assembly code blocks with syntax highlighting, hex bytes, and memory addresses.
- Syntax highlighting for x86 (NASM) and ARM assembly
- Four display modes:
raw- Assembly with syntax highlighting onlyhex- Hex bytes + assembly instructionfull- Address + hex bytes + assembly instructionida- IDA-style section:address + assembly instruction
- Capitalization option for hex bytes and addresses
- Dark/light mode compatible
This project is structured as a Hugo module with the following components:
layouts/shortcodes/asm.html- The shortcode templateassets/css/extended/asm.css- Styling for assembly code blockshugo.toml- Module mount configurationgo.mod- Go module definition
Add to your hugo.toml:
[module]
[[module.imports]]
path = "github.com/NohamR/hugo-asm-shortcode"Copy the following files to your Hugo site:
layouts/shortcodes/asm.html→ your site'slayouts/shortcodes/assets/css/extended/asm.css→ your site'sassets/css/extended/
{{</* asm mode="raw" arch="x86" */>}}
mov rax, 1
xor rdi, rdi
syscall
{{</* /asm */>}}
{{</* asm mode="hex" arch="x86" */>}}
48 c7 c0 01 00 00 00 | mov rax, 1
48 31 ff | xor rdi, rdi
0f 05 | syscall
{{</* /asm */>}}
{{</* asm mode="full" arch="x86" */>}}
00401000 | 48 c7 c0 01 00 00 00 | mov rax, 1
00401007 | 48 31 ff | xor rdi, rdi
0040100a | 0f 05 | syscall
{{</* /asm */>}}
{{</* asm mode="ida" arch="x86" */>}}
__text:000000010045C182 | mov rdi, [rbp+var_88]
__text:000000010045C189 | call _RuntimeUnlockString
__text:000000010045C18E | mov [rbp+var_88], 0
{{</* /asm */>}}
| Parameter | Default | Description |
|---|---|---|
mode |
raw |
Display mode: raw, hex, full, or ida |
arch |
x86 |
Architecture: x86 or arm |
capitalize |
false |
Uppercase hex bytes and addresses when true |
See a live demo at noh.am/en/posts/asm/
MIT License - see LICENSE for details.