function resolveText()

in site/src/buildtime/legacyImportDemoInstruction/remarkPlugin.ts [68:80]


function resolveText(text: string) {
  const prefix = '#include '
  if (!text.startsWith(prefix)) return null
  // something like: `"demo/demo1.js"`
  const pathWithQuote = text.substr(prefix.length)
  const quoteStart = pathWithQuote[0]
  const quoteEnd = pathWithQuote[pathWithQuote.length - 1]
  if (pathWithQuote.length <= 2) return null
  if (quoteStart !== quoteEnd) return null
  if (quoteStart !== "'" && quoteStart !== '"') return null
  const demoPath = pathWithQuote.substring(1, pathWithQuote.length - 1)
  return `./${path.normalize(demoPath)}`
}