diff --git a/README.md b/README.md index b65b8cc..1ea567c 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ bytefield( ## Usage -To use this library through the Typst package manager (for Typst v0.6.0+), import bytefield with `#import "@preview/bytefield:0.0.2": *` at the top of your file. +To use this library through the Typst package manager (for Typst v0.6.0+), import bytefield with `#import "@preview/bytefield:0.0.3": *` at the top of your file. The package contains some of the most common network protocol headers: `ipv4`, `ipv6`, `icmp`, `icmpv6`, `dns`, `tcp`, `udp`. @@ -43,7 +43,7 @@ At the moment very limited features. Feel free to extend if you like. ## Changelog -### v0.0.3 (WIP) +### v0.0.3 - Added "smart" bit headers thanks to [hgruniaux](https://github.com/hgruniaux) - Added "smart-firstline" to only consider the first row for calculation. diff --git a/bytefield.typ b/bytefield.typ index a52d90f..92f6d8f 100644 --- a/bytefield.typ +++ b/bytefield.typ @@ -62,10 +62,13 @@ let bitheader_font_size = 9pt; let bh_num_text(num) = { - let alignment = if (msb_first) { - if (num == 0) {end} else if (num == (bits - 1)) { start } else { center } - } else { - if (num == (bits - 1)) {end} else if (num == 0) { start } else { center } + let alignment = if (bitheader == "all") {center} + else { + if (msb_first) { + if (num == 0) {end} else if (num == (bits - 1)) { start } else { center } + } else { + if (num == (bits - 1)) {end} else if (num == 0) { start } else { center } + } } align(alignment, text(bitheader_font_size)[#num]); diff --git a/example.pdf b/example.pdf index f23b466..e3821c8 100644 Binary files a/example.pdf and b/example.pdf differ diff --git a/example.typ b/example.typ index d71407e..2675b50 100644 --- a/example.typ +++ b/example.typ @@ -1,4 +1,4 @@ -#import "@local/bytefield:0.0.2": * +#import "@local/bytefield:0.0.3": * = Bytefield == Colored Example diff --git a/typst.toml b/typst.toml index 3640481..54888bb 100644 --- a/typst.toml +++ b/typst.toml @@ -1,6 +1,6 @@ [package] name="bytefield" -version = "0.0.2" +version = "0.0.3" entrypoint = "bytefield.typ" authors = ["Jomaway "] license = "MIT" @@ -8,4 +8,4 @@ description = "A package to create network protocol headers" repository = "https://github.com/jomaway/typst-bytefield" keywords = ["bytefields", "protocol", "header"] compiler = "0.8.0" -exclude = ["example.typ", "ipv4-example.png"] \ No newline at end of file +exclude = ["example.typ","example.pdf", "ipv4-example.png"] \ No newline at end of file