nostr-content-parser
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

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
    • [ ] Formatting: Italic
    • [ ] Bold
  • [ ] Headings
  • [ ] Line Breaks
  • [ ] BlockQuotes
  • [ ] Lists
  • [ ] 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...)

Opinionated Behavior

  • [x] Strip endlines from top/bottom of markdown

Example

Markdown

Anyone making chili today? What’s your secret ingredient? #foodstr #asknostr

Abstract 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" },
        ],
      },
    ],
  }

Readme

Keywords

none

Package Sidebar

Install

npm i nostr-content-parser

Weekly Downloads

7

Version

0.0.6

License

MIT

Unpacked Size

92.2 kB

Total Files

77

Last publish

Collaborators

  • asknostr.site