CDN (CBOR-EDN) for Visual Studio Code
Language support for CDN (Concise Diagnostic Notation,
draft-ietf-cbor-edn-literals),
the human-readable text format for CBOR data and a superset of JSON.
Powered by @cbortech/cbor, so
highlighting, validation, and formatting agree exactly with a real CDN parser.
A live playground for the library is available at
https://cbor.tech/cbor/.

Features
- Syntax highlighting for
.cdn, .diag, and .edn files: numbers in all bases,
hex floats, text/byte strings (h'…', b64'…', '…', `…`),
application-oriented literals (dt'…', ip'…', …), tags, embedded CBOR
(<< … >>), encoding indicators (_, _3), ellipsis (...), and all four
comment styles (#, //, /* … */, / … /).
- Validation as you type: syntax errors and CDN validity violations are
underlined at their exact source range.
- Application extensions: all bundled @cbortech/cbor extensions (
dt,
ip, cri, t1, b1, ilbs, ilts, float, same, b32, h32) plus
hash'…' (@cbortech/hash-extension), uuid'…' (@cbortech/uuid-extension),
and SET<<…>> / MAP<<…>> (@cbortech/set-map-extensions) are recognized
and validated out of the box. Each one can be disabled individually via
cdn.extensions.* for allowlisting scenarios.
- Formatting (
Format Document): pretty-prints with your editor's
indentation settings while preserving comments and the original spelling of
byte strings. The formatter verifies that the formatted text still parses to
the same data before touching your document, and does nothing otherwise.
Settings
| Setting |
Default |
Description |
cdn.validate.enable |
true |
Enable validation. |
cdn.validate.topLevel |
"item" |
"item": one CDN data item per document (application/cdn). "sequence": allow multiple items (CBOR sequence). Also controls the formatter. |
cdn.format.commas |
"comma" |
Comma style: comma, none, or trailing. |
cdn.format.comments |
"preserve" |
Keep comments as-is, normalize to c-style / cdn-style, or strip. |
cdn.format.encodingIndicators |
"auto" |
Emit _N indicators always, auto (only when non-canonical), or never. |
cdn.format.appPrefix |
true |
Prefer dt'…'-style app-prefix literals over raw tag notation. |
cdn.format.bstrEncoding |
"hex" |
Fallback byte-string encoding: hex, base64, base64url. |
cdn.format.preserveByteString |
true |
Keep the original spelling of byte-string literals. |
cdn.format.preserveRawString |
true |
Keep the original spelling of raw backtick string literals (`…`). |
cdn.format.preserveNumberFormat |
true |
Keep the original spelling of integer and floating-point literals. |
cdn.format.preserveAppPrefix |
true |
Keep the original notation (e.g. dt'…' vs DT<<…>> vs raw tag) of extension app-prefix literals. |
cdn.format.preserveBlankLines |
true |
Re-emit a blank line above an array/map entry that had one in the source. |
cdn.format.preserveConcatenation |
true |
Keep + concatenation chains ("a" + "b") from the source. |
cdn.format.splitCdn |
true |
Split text strings whose content parses as CDN, with structure-aware indentation. |
cdn.format.splitNewline |
true |
Split text strings at newline characters using + concatenation. |
cdn.format.inlineLeafContainers |
true |
Keep arrays/maps with no nested containers on a single line (e.g. [1, 2, 3]). |
cdn.format.floatFormat |
unset |
Numeric format for floats: decimal, hex, or app-extension (float'…', lossless for NaN/±Infinity). Only takes effect where the original spelling isn't otherwise kept: for a plain float literal, combine with preserveNumberFormat: false; for a float'…' literal, leave unset to keep its bit-pattern spelling — decimal/hex renormalize it and can lose a NaN payload. |
cdn.format.modernConcat |
false |
Render + concatenation / elision chains as t1<<…>> / b1<<…>> app-sequence notation. |
cdn.format.modernStreamSyntax |
false |
Render indefinite-length strings as ilts<<…>> / ilbs<<…>> app-sequence notation instead of (_ "a", "b"). |
cdn.extensions.<name> |
true |
Enable/disable each application extension individually: dt, ip, cri, t1, b1, ilbs, ilts, float, same, b32, h32, hash, uuid, set, map. Disabled prefixes are reported with a hint and parsed as unresolved (tag 999). |
Note: dt, ip, t1, and b1 are mandatory-to-implement per
draft-ietf-cbor-edn-literals-27 §3; disabling them makes validation stricter
than the spec recommends.
License
Apache-2.0
| |