mirror of
https://github.com/edems-dev/md-discord-syntax.git
synced 2026-07-22 08:37:37 +00:00
777 B
777 B
@edems-dev/md-discord-syntax-core
Platform-independent Discord spoiler (||spoiler||) and subtext (-# subtext) syntax parser with zero dependencies.
Part of the md-discord-syntax repository.
Installation
npm install @edems-dev/md-discord-syntax-core
Minimal API Usage
import {
findSpoilerRanges,
isSubtextLine,
stripSubtextPrefix,
} from "@edems-dev/md-discord-syntax-core";
const text = "Hello ||secret|| world";
const spoilers = findSpoilerRanges(text);
// [{ from: 6, to: 16, contentFrom: 8, contentTo: 14 }]
const line = "-# Subtext line";
if (isSubtextLine(line)) {
const content = stripSubtextPrefix(line); // "Subtext line"
}
License
GPL-3.0 © Edems-DEV