UNPKG

discord-markdown-parser

Version:

Parse discord-style markdown into an abstract syntax tree.

34 lines (33 loc) 1.29 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.guildNavigation = void 0; const simple_markdown_1 = __importDefault(require("../../simple-markdown")); const regex_1 = require("../../utils/regex"); exports.guildNavigation = { order: simple_markdown_1.default.defaultRules.strong.order, match: (source) => regex_1.GuildNavigationRegex.exec(source), parse: function (capture) { var _a, _b, _c; // linked-roles navigation type adds an optional role ID const navigation = (_a = capture[2]) !== null && _a !== void 0 ? _a : capture[3]; if (navigation === 'linked-roles') { // the start of the roleId is padded with a colon, // so we need to remove it const roleId = (_c = (_b = capture[4]) === null || _b === void 0 ? void 0 : _b.slice(1)) !== null && _c !== void 0 ? _c : null; return { id: capture[1], navigation, roleId, }; } else { return { id: capture[1], navigation, }; } }, };