or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-6/

MDX Source Position Analyzer

Build a tool that analyzes MDX source files and reports detailed position information for elements discovered during compilation. The tool should track line, column, and offset information for specific node types as they are transformed through the compilation pipeline.

Capabilities

Position extraction

  • Given MDX input containing headings, the tool extracts position information (start line, start column, end line, end column) for each heading node @test
  • Given MDX input containing JSX elements, the tool extracts position information for JSX element nodes @test

Multiple node types

  • The tool can report positions for both markdown-generated elements and explicit JSX elements in the same file @test

Position accuracy

  • Position information accurately reflects the original source locations, including correct line and column numbers @test

Implementation

@generates

Requirements

The tool should:

  • Accept MDX source code as input
  • Process the MDX using the compilation pipeline
  • Extract and return position data for specified node types
  • Return results in a structured format containing node type, text content (or tag name), and position details

Output format should be an array of objects with this structure:

{
  type: string,        // e.g., "heading", "jsx"
  content: string,     // text or tag name
  position: {
    start: { line: number, column: number, offset: number },
    end: { line: number, column: number, offset: number }
  }
}

API

/**
 * Analyzes MDX source and extracts position information for elements.
 *
 * @param {string} mdxSource - The MDX source code to analyze
 * @param {object} options - Configuration options
 * @param {string[]} options.nodeTypes - Array of node types to extract (e.g., ['heading', 'mdxJsxFlowElement'])
 * @returns {Promise<Array>} Array of objects containing type, content, and position information
 */
export async function analyzePositions(mdxSource, options);

Dependencies { .dependencies }

@mdx-js/mdx { .dependency }

Provides MDX compilation and AST processing capabilities