Coder Social home page Coder Social logo

marked-annotated-hexdump's Introduction

marked-annotated-hexdump

Generate annotated hexdumps using markdown. Supports marked and markdown-it

Give marked support a try in your browser

Give markdown-it support a try in your browser

Syntax

Annotated hexdumps are created with an annotated-hexdump code-block.

```annotated-hexdump
0000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0010 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
```

You can omit the address, and it'll assume data starts at offset 0.

```annotated-hexdump
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
```

Addresses do not need to be contiguous, or in any particular order. The only restriction is that you cannot define a range twice. Space will be left for any missing characters.

```annotated-hexdump
0010 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0100 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0028 28 29 30
```

The character used to replace missing bytes can be controlled with /missing.

```annotated-hexdump
/missing ?

0010 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0100 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0028 28 29 30
```

The width of the data and address elements in the hexdump can be controlled with /width and /awidth. /width accepts values between 2 and 32. /awidth accepts values between 2 and 8. Both are measured in bytes.

```annotated-hexdump
/width 4
/awidth 3
0000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
```

You can highlight regions of a hexdump with /highlight. This takes two arguments:

  • An inclusive range of addresses to highlight. This is enclosed in square brackets [], and can contain single addresses, or ranges delimited with a colon. Multiple ranges (or single addresses) can be combined with commas.
    • [1] - defines a address 0x01 only
    • [1,2,3] - defines a highlight over 0x01, 0x02 and 0x03. This will be rendered with gaps between the highlights.
    • [1:3] - defines a contiguous highlight over the same three bytes.
    • [1:3, 100:200] - defines two contiguous highlights.
  • A style in the form /N, where N is a number between 0 and 15.
```annotated-hexdump
0010 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0100 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0028 28 29 30

/highlight [10,11,12,16:19] /1
/highlight [1F:101] /2
/highlight [104:106] /3
```

You can leave comments by starting a line with #. This only works if it's the first character in a line.

You can leave visible notes with the /note command. This takes two arguments:

  • A style in the form of /N, where N is a number between 0 and 15.
  • A block of text, which will be formatted in this style.

Usage with marked

import { marked } from "marked";
import { annotatedHex } from "marked-annotated-hexdump/marked";

// or UMD script
// <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
// <script src="https://cdn.jsdelivr.net/npm/marked-annotated-hexdump/lib/index.umd.js"></script>

marked.use(annotatedHex());

marked.parse("```annotated-hexdump\nAA BB CC DD\n```");

Usage with markdown-it

import markdownIt from "../../node_modules/markdown-it/dist/markdown-it";
import { extendMarkdownIt } from "marked-annotated-hexdump/markdown-it";

const md = markdownIt();
extendMarkdownIt(md);

md.render("```annotated-hexdump\nAA BB CC DD\n```");

Limitations

  • If you configure your markdown to wrap, the highlighted regions will be at incorrect positions.
    This might be better expressed using spans rather than an svg overlay

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.