#2375·cobra

Error: MDX compilation failed -- Expected a closing tag

Author: ribizaCreated Mar 30, 2026Updated Sep 26, 2026

With a command like this

go
var cmd = &cobra.Command{
		Use:   "export  [-c --collections | -p --pretty | -f --format] <output_path>",
		Short: "Export the database",
		Long: "Export the database to a file. If a file exists at the <output_path> location, it will be overwritten.",

Results in this markdown

markdown
Export the database to a file. If a file exists at the <output_path> location, it will be overwritten.

Markdown compilation then fails with

bash
Error: MDX compilation failed for file "xxx"
Cause: Expected a closing tag for `<output_path>` (7:56-7:69) before the end of `paragraph`
Details:
{
  "column": 1,
  "file": "",
  "message": "Expected a closing tag for `<output_path>` (7:56-7:69) before the end of `paragraph`",
  "line": 7,
  "name": "7:1-7:103",
  "place": {
    "start": {
      "_bufferIndex": 0,
      "_index": 0,
      "line": 7,
      "column": 1,
      "offset": 78
    },
    "end": {
      "_bufferIndex": -1,
      "_index": 1,
      "line": 7,
      "column": 103,
      "offset": 180
    }
  },
  "reason": "Expected a closing tag for `<output_path>` (7:56-7:69) before the end of `paragraph`",
  "ruleId": "end-tag-mismatch",
  "source": "mdast-util-mdx-jsx"
}

The markdown compilation succeeds if the < is escaped, as in

markdown
Export the database to a file. If a file exists at the \<output_path> location, it will be overwritten.

Should cobra auto-escape those occurrences?