← 返回 Gene 目录

markdown-formatter

Native text.format

Normalizes Markdown formatting: fixes heading levels, standardizes list markers, wraps long lines, and enforces consistent spacing.

README

# markdown-formatter

A Native Gene that normalizes Markdown formatting for consistency.

## Usage

```bash
rotifer test markdown-formatter --input '{"markdown": "# Title\n* item1\n* item2\n", "listMarker": "-"}'
```

## Features

- Standardize list bullet markers (`-`, `*`, `+`)
- Normalize heading styles (ATX `#` or Setext underline)
- Enforce consistent blank line spacing
- Wrap long lines at configurable width
- Report number of changes applied

## Input

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `markdown` | string | Yes | Raw Markdown text |
| `lineWidth` | number | No | Max line width (default: 80) |
| `listMarker` | string | No | Bullet char: `-`, `*`, or `+` |
| `headingStyle` | string | No | `"atx"` or `"setext"` |

## Output

| Field | Type | Description |
|-------|------|-------------|
| `formatted` | string | Formatted Markdown |
| `changed` | boolean | Whether changes were made |
| `changeCount` | number | Number of changes applied |

表型

输入

属性类型 必填 描述
markdown string Raw Markdown text to format
lineWidth number = 80 Maximum line width for wrapping
listMarker - | * | + = - List bullet character
headingStyle atx | setext = atx Heading style

输出

属性类型 描述
changed boolean Whether any formatting changes were made
formatted string Formatted Markdown text
changeCount number Number of formatting changes applied
原始 JSON Schema

inputSchema

{
  "type": "object",
  "required": [
    "markdown"
  ],
  "properties": {
    "markdown": {
      "type": "string",
      "description": "Raw Markdown text to format"
    },
    "lineWidth": {
      "type": "number",
      "default": 80,
      "description": "Maximum line width for wrapping"
    },
    "listMarker": {
      "enum": [
        "-",
        "*",
        "+"
      ],
      "type": "string",
      "default": "-",
      "description": "List bullet character"
    },
    "headingStyle": {
      "enum": [
        "atx",
        "setext"
      ],
      "type": "string",
      "default": "atx",
      "description": "Heading style"
    }
  }
}

outputSchema

{
  "type": "object",
  "properties": {
    "changed": {
      "type": "boolean",
      "description": "Whether any formatting changes were made"
    },
    "formatted": {
      "type": "string",
      "description": "Formatted Markdown text"
    },
    "changeCount": {
      "type": "number",
      "description": "Number of formatting changes applied"
    }
  }
}

Arena 历史

日期 适应度 安全分 调用数
3月17日 0.7050 0.76 1