nostr-content-parser
v0.0.8
Published
Your package.
Readme
Nostr Content Parser
Package to turn nostr Markdown into an Abstract Syntax Tree.
https://astexplorer.net/
Why?
Every Nostr client handles content parsing differently. Almost every Nostr client I tested has bugs when it comes to parsing markdown.
I created this library to scratch my own itch for asknostr.site.
Supported
- [x] Paragraphs
- [ ] Formatting
- [x] Emphasis
- [x] Formatting: Italic
- [x] Bold
- [ ] Headings
- [ ] Line Breaks
- [x] BlockQuotes
- [x] Lists
- [x] Code
- [ ] Horizontal Rules
- [x] Links
- [x] Markdown Links
- [x] Literal Links
- [x] Images
- [x] Markdown Images
- [x] Literal Images
- [x] Hashtags
- [x] Video/Youtube
- [ ] Nostr Entities
- [x] Mentions (nostr:nprofile nostr:npub npub1... nprofile1...)
- [x] Other nostr mentions (nostr:note nostr:nevent note1...m nevent1...)
- [ ] Naddre
Opinionated Behavior
- [x] Strip endlines from top/bottom of markdown
Example
Markdown
Anyone making chili today? What’s your secret ingredient? #foodstr #asknostrAbstract Syntax Tree
{
type: "root",
children: [
{
type: "paragraph",
children: [
{
type: "text",
value: "Anyone making chili today? What’s your secret ingredient? ",
},
{ type: "hashtag", name: "foodstr", hashtag: "#foodstr" },
{ type: "text", value: " " },
{ type: "hashtag", name: "asknostr", hashtag: "#asknostr" },
],
},
],
}