JSPM

discord-markdown-parser

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5754
  • Score
    100M100P100Q124243F
  • License GNU GPLv3

Parse discord-style markdown into an abstract syntax tree.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (discord-markdown-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    discord-markdown-parser

    Discord npm GitHub package.json version GitHub Repo stars A node.js markdown implementation based on the simple-markdown library, which is the same technology discord use.

    Designed to be used for discord-html-transcripts

    discord-markdown-parser will parse any given string into an AST tree and supports:

    • links
    • block quotes
    • inline quotes
    • code blocks
    • inline code
    • italics (em)
    • spoilers
    • bold
    • strikethrough
    • underline
    • channel mentions
    • user mentions
    • role mentions
    • @everyone
    • @here
    • emojis & more

    Usage

    import { parse } from 'discord-markdown-parser';
    // or const { parse } = require('discord-markdown-parser');
    
    // input is a string
    const input = "test **markdown** with `cool` *stuff*";
    
    // specify what type of markdown this is
    // this can be 'normal' or 'extended' (default = normal)
    // extended should be used if the input is from a webhook message or embed description.
    const type  = "normal";
    
    // will return an AST tree
    const parsed = parse(input, type);

    Extending

    // you can import the default rules using
    import { rules } from 'discord-markdown-parser';
    
    // and you can add your own rules
    const newRules = {
        ...rules,
        customRule: {
            ...
        } // see simple-markdown documentation for details
    };
    
    // import simpleMarkdown
    import SimpleMarkdown from 'simple-markdown';
    
    // and create the parser
    const parser = SimpleMarkdown.parserFor(newRules);