import type { Metadata } from "next";
import { ToolLanding } from "@/components/marketing/tool-landing";
import { buildMetadata } from "@/lib/seo";

const PATH = "/tools/markdown-formatter";

export const metadata: Metadata = buildMetadata({
  title: "Markdown Formatter — Beautify and Lint Your Markdown",
  description:
    "Beautify messy Markdown in seconds. Our formatter normalizes whitespace, headings, lists, and task markers — and the linter flags common issues with auto-fix.",
  path: PATH,
  keywords: [
    "markdown formatter",
    "markdown beautifier",
    "markdown linter",
    "format markdown",
    "fix markdown",
  ],
});

export default function Page() {
  return (
    <ToolLanding
      eyebrow="Markdown Formatter"
      title="Beautify and lint your Markdown in one click"
      description="Auto-format messy Markdown. Normalizes whitespace, headings, list bullets, task markers, and trailing spaces — plus a built-in linter that flags common mistakes."
      path={PATH}
      bullets={[
        "Beautify with a single click — no config",
        "Linter flags issues with line numbers and rule names",
        "Auto-fix common problems with one button",
        "Conventions match GitHub & markdownlint defaults",
      ]}
      sample={`## Before\n\n#Heading without space\n\n* Mixed bullet style\n+ Another bullet\n\n- [X] Uppercase task marker\n\n\n\n\nMultiple blank lines.\n\n## After\n\n# Heading without space\n\n- Mixed bullet style\n- Another bullet\n\n- [x] Uppercase task marker\n\nMultiple blank lines.\n`}
      body={`## What does the Markdown formatter fix?

The Markdown beautifier is intentionally minimal — every transformation is something most teams agree on:

- **Heading spaces** — \`#Title\` becomes \`# Title\`
- **List bullets** — \`*\` and \`+\` are normalized to \`-\`
- **Task markers** — \`[X]\` becomes \`[x]\`
- **Trailing whitespace** — stripped on every line outside code blocks
- **Blank line collapse** — three or more blank lines collapse to one
- **Trailing newline** — exactly one at the end of the file

We never touch the contents of fenced code blocks, so your code samples stay exactly as you wrote them.

## How to format your Markdown

1. Open the [editor](/editor).
2. Paste your Markdown.
3. Press **Ctrl/⌘ + Shift + F** or click **Beautify** in the Tools sidebar.

## Built-in linter

The linter runs on every keystroke and surfaces issues in the **Format** tab of the sidebar:

| Rule                  | Severity | Description                                |
| --------------------- | :------: | ------------------------------------------ |
| heading-space         | warning  | Missing space after \`#\`                    |
| heading-increment     | warning  | Heading jumps more than one level          |
| consistent-bullets    | info     | Use \`-\` for unordered list items           |
| no-trailing-whitespace| info     | Trailing whitespace on a line              |
| no-multiple-blanks    | info     | More than one consecutive blank line       |

Click an issue to jump to the offending line, or hit **Auto-fix common issues** to apply the formatter.
`}
      faq={[
        {
          question: "Will the formatter change my code blocks?",
          answer:
            "No. Anything inside fenced code blocks is left untouched. The formatter only normalizes prose-level formatting.",
        },
        {
          question: "Does it follow markdownlint conventions?",
          answer:
            "The formatter follows a sensible subset of markdownlint defaults — particularly the rules that have clean automatic fixes.",
        },
        {
          question: "Can I disable certain rules?",
          answer:
            "Not yet — the formatter is intentionally minimal. If you need rule-level control, run our output through a dedicated linter like markdownlint-cli2.",
        },
        {
          question: "Will my links and images change?",
          answer:
            "No. Link and image URLs are preserved exactly. The link checker in the sidebar can validate them on demand.",
        },
      ]}
    />
  );
}
