INNER CODE UNIT · JavaScript

markdownImage

mermaid-js/mermaid-cli · src/index.js:913

function markdownImage({ url, title, alt }) {
  // we can't use String.prototype.replaceAll since it's not supported in Node v14
  const altEscaped = alt.replace(/[[\]\\]/g, "\\$&");
  if (title) {
    const titleEscaped = title.replace(/["\\]/g, "\\$&");
    return `![${altEscaped}](${url} "${titleEscaped}")`;
  } else {
    return `![${altEscaped}](${url})`;
  }
}

/**
 * @typedef {<Arguments extends unknown[], ReturnType>(
 *  function_: (...arguments_: Arguments) => Promise<ReturnType>,
 *    ...arguments_: Arguments
 * ) => Promise<ReturnType>} Limiter - Adapted from `p-limit` package.
 */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…