题目描述
Background
BBCode and Markdown are two commonly used formatting languages. Formatting languages, such as those used in website comment sections, allow you to decorate your comments with various styles like colors and bold text.
Problem Description
BBCode syntax is as follows:
[h1]Hello World![/h1]
[h2][i]This is a BBCode[/i][/h2]
[b][i]I love[/i] Olympic [i]Informatics[/i][/b]
For example, within the [h1] tag, the content between [h1] and [/h1] is considered a level-1 heading and should be rendered accordingly.
It is important to note that BBCode requires the opening and closing tags to be complete and correctly nested. The following examples are invalid BBCode:
[h1]Hello World! // Unclosed tag
[h1]Hello World![/h2] // Mismatched tags
[h1][i]Hello World![/h1][/i] // Incorrect nesting order
Additionally, BBCode has a special [quote][/quote] tag. Any text within this tag should not be parsed as BBCode but should be converted to Markdown and output as is.
Now, let's introduce Markdown. Its syntax is as follows:
# Hello World! #
## *This is a Markdown* ##
__*I love* Olympic *Informatics*__
Your task is to convert a given BBCode string to Markdown and report errors for invalid input.
The BBCode tags and their corresponding Markdown equivalents that will appear in the problem data are as follows, and no other tags will be present:

Additional notes for the [quote] tag:

Input Format
The BBCode to be converted.
Output Format
The converted Markdown or error messages for invalid input.
Sample Input and Output
Input Sample #1
[h1]Hello World![/h1]
[h2]How are [i]you[/i]?[/h2]
Output Sample #1
# Hello World! #
## How are *you*? ##
Input Sample #2
[h1]Introducing Swift.[/h1][quote]
import SpriteKit
let object = SKSpriteNode(imageNamed: “[L2/Ascention]”
[/quote]
Output Sample #2
# Introducing Swift. #
> import SpriteKit
> let object = SKSpriteNode(imageNamed: “[L2/Ascention]”
Input Sample #3
[h1]I knew you were
trouble when you walked in[/h1]
[url=http://www.example.com]By Taylor Swift[/url]
Output Sample #3
# I knew you were
trouble when you walked in #
[By Taylor Swift](http://www.example.com)
Input Sample #4
[h1]Thanks for [i]inviting[/h1] me.[/i]
Output Sample #4
Match Error
Input Sample #5
[h2]Your gift is awesome!
Output Sample #5
Unclosed Mark
Input Sample #6
[quote][/quote][/quote]
Output Sample #6
Match Error
(Explanation for this data: After matching the first closing tag, the subsequent content is not considered part of the code segment)
Input Sample #7
[quote][quote][/quote]
Output Sample #7
> [quote]
Notes
To ensure smooth evaluation without misinterpretation, please adhere to the following requirements:
Respect the original input and output line breaks, without adding or removing any.
An exception to the first rule is when the [quote] tag is not on a new line; in Markdown, start a new line. Also, remove leading and trailing blank lines within the [quote] tag; no blank quotes will be present.
Pay attention to spaces in the table.
For invalid BBCode input, your program must report errors: output "Match Error" for mismatched tags and "Unclosed Mark" for unclosed tags. When both conditions occur simultaneously, handle it as a mismatched tag and output "Match Error". Due to the special nature of the [quote] tag, data guarantees that the [quote] tag will not be erroneous. (For cases like [i][h1]Text[/i], handle it as "Match Error"; for [i][h1]Text[/h1], handle it as "Unclosed Mark")
Due to restrictions on the platform, when outputting "Unclosed Mark", split it into two strings at the word "close" to avoid being flagged.
The following three characters will not appear in text outside of the [quote] tag: [, ], /, *, _, #, >, but the / character may appear in URLs.
The input will not contain incomplete tags, such as [h1]Text[/h
For those who have used Markdown and BBCode elsewhere: The formats in this problem are not strict BBCode and Markdown formats; do not be misled by prior experience.
Your output should strictly follow the specified format.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分