Home / Function/ remarkMkDocsAdmonition() — supabase Function Reference

remarkMkDocsAdmonition() — supabase Function Reference

Architecture documentation for the remarkMkDocsAdmonition() function in remarkAdmonition.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  1c6cc7f2_caeb_fb83_1fef_f0907c3c713e["remarkMkDocsAdmonition()"]
  67a945e1_7550_1b68_2ba7_665ba0ff6278["preprocessMdxWithDefaults()"]
  67a945e1_7550_1b68_2ba7_665ba0ff6278 -->|calls| 1c6cc7f2_caeb_fb83_1fef_f0907c3c713e
  8a27dbe0_3850_6088_23e6_d04481fa56dd["extractLinkedSiblings()"]
  1c6cc7f2_caeb_fb83_1fef_f0907c3c713e -->|calls| 8a27dbe0_3850_6088_23e6_d04481fa56dd
  80e649ba_ea8a_9a12_5b22_92f86be8bb38["mapAdmonitionType()"]
  1c6cc7f2_caeb_fb83_1fef_f0907c3c713e -->|calls| 80e649ba_ea8a_9a12_5b22_92f86be8bb38
  style 1c6cc7f2_caeb_fb83_1fef_f0907c3c713e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/lib/mdx/plugins/remarkAdmonition.ts lines 12–69

const remarkMkDocsAdmonition = function () {
  return function transformer(root: Root) {
    visit(root, 'paragraph', (paragraph: Paragraph, index: number, parent: Root) => {
      const [firstChild] = paragraph.children

      if (firstChild?.type === 'text') {
        // Look for 3 '!', followed by an admonition type, followed by
        // an optionally quoted title, followed by optional newlines of text
        const match = firstChild.value.match(/^!!! ?("?)(.+)\1 ?\n?((?:.|\n)*)/)

        if (!match) {
          return
        }

        // Extract the admonition type, title, and remaining text
        const [, , typeTitle, value] = match
        const typeTitleMatch = typeTitle.match(/^(.+?) ?(?:"(.*)")?$/)
        if (!typeTitleMatch) return
        const [, type, title] = typeTitleMatch

        // Rewrite the node's value to remove the admonition syntax
        firstChild.value = value

        // Extract sibling nodes that should be linked to this admonition
        const siblingsToNest = extractLinkedSiblings(parent, paragraph, index)

        const children: any[] = [...paragraph.children, ...siblingsToNest]

        // Generate a Supabase Admonition JSX element
        const admonitionElement: MdxJsxFlowElement = {
          type: 'mdxJsxFlowElement',
          name: 'Admonition',
          attributes: [
            {
              type: 'mdxJsxAttribute',
              name: 'type',
              value: mapAdmonitionType(type),
            },
          ],
          children,
        }

        if (title) {
          admonitionElement.attributes.push({
            type: 'mdxJsxAttribute',
            name: 'label',
            value: title,
          })
        }

        // Overwrite original node with new element
        parent.children.splice(index, 1, admonitionElement)
      }
    })

    return root
  }
}

Subdomains

Frequently Asked Questions

What does remarkMkDocsAdmonition() do?
remarkMkDocsAdmonition() is a function in the supabase codebase.
What does remarkMkDocsAdmonition() call?
remarkMkDocsAdmonition() calls 2 function(s): extractLinkedSiblings, mapAdmonitionType.
What calls remarkMkDocsAdmonition()?
remarkMkDocsAdmonition() is called by 1 function(s): preprocessMdxWithDefaults.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free