chore: Update bits syntax to use +<count>

This commit is contained in:
Sidharth Vinod
2025-04-15 12:14:06 +05:30
parent d7730aba46
commit ea321168bd
5 changed files with 56 additions and 38 deletions

View File

@@ -19,14 +19,15 @@ start-end: "Block name" %% Multi-bit blocks
### Bits Syntax (v<MERMAID_RELEASE_VERSION>+)
Using start and end bit counts can be difficult, especially when modifying a design. For this we add a bit count field, which starts from the end of the previous field automagically. Use `bit` or `bits` interchangeably to set the number of bits, thus:
Using start and end bit counts can be difficult, especially when modifying a design. For this we add a bit count field, which starts from the end of the previous field automagically. Use `+<count>` to set the number of bits, thus:
````md
```md
packet-beta
1bit: "Block name" %% Single-bit block
8bits: "Block name" %% 8-bit block
+1: "Block name" %% Single-bit block
+8: "Block name" %% 8-bit block
9-15: "Manually set start and end, it's fine to mix and match"
... More Fields ...
```
## Examples
@@ -35,8 +36,8 @@ packet-beta
title: "TCP Packet"
---
packet-beta
16bits: "Source Port"
16bits: "Destination Port"
0-15: "Source Port"
16-31: "Destination Port"
32-63: "Sequence Number"
64-95: "Acknowledgment Number"
96-99: "Data Offset"
@@ -53,13 +54,12 @@ packet-beta
160-191: "(Options and Padding)"
192-255: "Data (variable length)"
```
````
```mermaid-example
packet-beta
title UDP Packet
0-15: "Source Port"
16-31: "Destination Port"
+16: "Source Port"
+16: "Destination Port"
32-47: "Length"
48-63: "Checksum"
64-95: "Data (variable length)"