/** * Copyright JS Foundation and other contributors, http://js.foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ RED.utils = (function() { window._marked = window.marked; window.marked = function(txt) { console.warn("Use of 'marked()' is deprecated. Use RED.utils.renderMarkdown() instead"); return renderMarkdown(txt); } const descriptionList = { name: 'descriptionList', level: 'block', // Is this a block-level or inline-level tokenizer? start(src) { if (!src) { return null; } let m = src.match(/:[^:\n]/g); return m && m.index; // Hint to Marked.js to stop and check for a match }, tokenizer(src, tokens) { if (!src) { return null; } const rule = /^(?::[^:\n]+:[^:\n]*(?:\n|$))+/; // Regex for the complete token const match = rule.exec(src); if (match) { return { // Token to generate type: 'descriptionList', // Should match "name" above raw: match[0], // Text to consume from the source text: match[0].trim(), // Additional custom properties tokens: this.lexer.inlineTokens(match[0].trim()) // inlineTokens to process **bold**, *italics*, etc. }; } }, renderer(token) { return `
`; // parseInline to turn child tokens into HTML } }; const description = { name: 'description', level: 'inline', // Is this a block-level or inline-level tokenizer? start(src) { if (!src) { return null; } let m = src.match(/:/g); return m && m.index; // Hint to Marked.js to stop and check for a match }, tokenizer(src, tokens) { if (!src) { return null; } const rule = /^:([^:\n]+)\(([^:\n]+)\).*?:([^:\n]*)(?:\n|$)/; // Regex for the complete token const match = rule.exec(src); if (match) { return { // Token to generate type: 'description', // Should match "name" above raw: match[0], // Text to consume from the source dt: this.lexer.inlineTokens(match[1].trim()), // Additional custom properties types: this.lexer.inlineTokens(match[2].trim()), dd: this.lexer.inlineTokens(match[3].trim()), }; } }, renderer(token) { return `\n