@petroglyph/renderer
v0.2.0
Published
Markdown renderers for Petroglyph. Supports Obsidian-flavored Markdown with wikilinks, callouts, and embeds.
Maintainers
Readme
@petroglyph/renderer
Markdown renderers for Petroglyph. Supports Obsidian-flavored Markdown with wikilinks, callouts, and embeds.
Installation
bun add @petroglyph/renderer
# or
npm install @petroglyph/renderer
# or
pnpm add @petroglyph/rendererUsage
RemarkRenderer
The main renderer that supports Obsidian-flavored Markdown:
import { RemarkRenderer } from '@petroglyph/renderer/remark';
import { LocalFileSystem } from '@petroglyph/fs';
const fs = new LocalFileSystem('/path/to/vault');
const renderer = new RemarkRenderer({
// Auto-configure with file system for wikilink resolution
fileSystem: fs,
});
// Render markdown content
const result = await renderer.render('# My Note\n\n[[Link to other note]]');
console.log(result.content); // HTML output
console.log(result.metadata); // Extracted metadataRawContentRenderer
A simple renderer that returns raw content without processing:
import { RawContentRenderer } from '@petroglyph/renderer/raw';
const renderer = new RawContentRenderer();
const result = await renderer.render('# My Note\n\nContent');
console.log(result.content); // Raw markdown contentFeatures
- Wikilinks:
[[note-name]]resolved using nearest-neighbor logic - Embeds:
![[image.png]]resolved to file paths - Callouts:
> [!note]converted to styled HTML - GFM: GitHub Flavored Markdown support
- Custom plugins: Extensible plugin system
Exports
This package provides multiple entry points:
@petroglyph/renderer- Main exports (types, errors, renderers)@petroglyph/renderer/remark- RemarkRenderer@petroglyph/renderer/raw- RawContentRenderer
Plugins
The package includes several remark/rehype plugins:
remarkWikilink- Parse and resolve wikilinksremarkEmbed- Parse and resolve embedsremarkCallout- Convert callouts to HTMLremarkHighlight- Syntax highlighting
License
MIT
