Linked Markdown for TypeScript

Extract structured frontmatter (YAML, JSON, TOML) and JSON-LD RDF graph attributes from markdown documents with full spec conformance.

deno add linked-markdown@jsr:@wazoo/linked-markdown

⚑ Quick Usage

Parse frontmatter attributes, raw frontmatter text, and clean document body in a single call.

TypeScript API Example
import { extract, LinkedMarkdownError } from "@wazoo/linked-markdown";

const markdown = `---
@id: "https://example.org/note/1"
@type: "KnowledgeNote"
title: "Linked Markdown Document"
tags: ["rdf", "typescript"]
---

# Hello Linked World
This is the document body.`;

// Parse document
const { attrs, frontMatter, body } = extract(markdown);

console.log(attrs.title);       // => "Linked Markdown Document"
console.log(attrs["@type"]);     // => "KnowledgeNote"
console.log(frontMatter);       // => Raw frontmatter string
console.log(body);              // => Clean body with leading newlines stripped

πŸ“‘ Supported Delimiters

Automatic format detection across YAML, JSON, and TOML frontmatter markers.

Format Supported Markers Default Object Type
YAML ---  ·  ---yaml  ·  = yaml = YAML Object
JSON ---json  ·  = json = JSON Object
TOML ---toml  ·  +++  ·  = toml = TOML Object

✨ Core Highlights

Built for reliable parsing, knowledge graph compatibility, and spec adherence.

πŸ•ΈοΈ
RDF & JSON-LD Native
Frontmatter attributes format as valid JSON-LD for direct conversion to RDF quads with jsonld.toRDF().
🧼
BOM & Line Hygiene
Strips UTF-8 BOM markers and normalizes Windows CRLF line endings automatically prior to extraction.
πŸ›‘οΈ
Typed Error Codes
Throws LinkedMarkdownError with programmatic codes like LMD_NO_FRONTMATTER and LMD_INVALID_FRONTMATTER.
🎯
Conformance Suite
Tested directly against the cross-language conformance suite from wazootech/linked-markdown.
Copied to clipboard!