Sublinks Markdown
A markdown parser with rules for frontends of sublinks. Used to easily add markdown support compatible with the standard sublinks frontend.
About
Sublinks markdown is a package that can be imported into your frontend and then used to add markdown support through one function call. All of the markdown rules used in the standard sublinks frontend are supported meaning your users will see the same things as users using the standard frontend without you needing to implement every single rule yourself.
Install
This package is ESM only. To install with npm use:
npm i sublinks-markdown
Usage
To convert text from markdown syntax into html use the mdToHtml function
import { mdToHtml } from "sublinks-markdown";
const html = await mdToHtml("## Hello World", "example.com")
The first argument is the markdown you want converted and the second is the instance of the user currently interacting with the frontend (so things such as relative links populate properly).
Features
- Headings (h1, h2, h3, h4, h5, h6)
- Bold
- Italic
- Strikethrough
- Relative user links (@user@example.com or https://example.com/u/user turns into a link relative to the user's instance. https://example.org/u/user@example.com)
- Relative community links (!community@example.com or https://example.com/c/community turns into a link relative to the user's instance. https://example.org/c/community@example.com)
- Links
- Image embedding
- Blockquote
- Unordered list
- Ordered list
- Horizontal rule
- Code blocks
- and more coming in the future