mirror of
https://github.com/NohamR/hugo-asm-shortcode.git
synced 2026-02-21 18:15:42 +00:00
main
hugo-asm-shortcode
A Hugo shortcode for displaying assembly code blocks with syntax highlighting, hex bytes, and memory addresses.
Features
- Syntax highlighting for x86 (NASM) and ARM assembly
- Three display modes:
raw- Assembly with syntax highlighting onlyhex- Hex bytes + assembly instructionfull- Address + hex bytes + assembly instruction
- Capitalization option for hex bytes and addresses
- Dark/light mode compatible
Module Structure
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
Installation
As a Hugo Module
Add to your hugo.toml:
[module]
[[module.imports]]
path = "github.com/NohamR/hugo-asm-shortcode"
Manual Installation
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/
Usage
Raw Mode (syntax highlighting only)
{{</* asm mode="raw" arch="x86" */>}}
mov rax, 1
xor rdi, rdi
syscall
{{</* /asm */>}}
Hex Mode (hex bytes + instruction)
{{</* 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 */>}}
Full Mode (address + hex + instruction)
{{</* 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 */>}}
Parameters
| Parameter | Default | Description |
|---|---|---|
mode |
raw |
Display mode: raw, hex, or full |
arch |
x86 |
Architecture: x86 or arm |
capitalize |
false |
Uppercase hex bytes and addresses when true |
Demo
See a live demo at noh.am/en/posts/asm/
License
MIT License - see LICENSE for details.
Description
Languages
HTML
66.4%
CSS
33.6%