#C7645. Markdown to HTML Converter

    ID: 51539 Type: Default 1000ms 256MiB

Markdown to HTML Converter

Markdown to HTML Converter

In this problem, you are required to implement a converter that transforms a single line of Markdown text into its corresponding HTML representation. The conversion rules are as follows:

  1. If the line starts with '# ' (a single hash followed by a space), the entire line (excluding the hash and space) should be wrapped in <h1> and </h1> tags.
  2. If the line starts with '## ' (two hashes followed by a space), the entire line (excluding the hashes and space) should be wrapped in <h2> and </h2> tags.
  3. If the line does not start with a header indicator, then any paired occurrences of either '' or '__' should be replaced by the appropriate HTML bold tag. More specifically, text enclosed between '' or between '__' should be wrapped in <strong> and </strong> tags.

The conversion for bold text should be applied globally. For example, the markdown text (This is bold text and this is also bold text.) should be converted to (This is bold text and this is also bold text.)

You need to read the markdown text from stdin and output the converted HTML text to stdout.

inputFormat

The input consists of a single line of text representing a markdown formatted string. It is read from standard input (stdin).

outputFormat

Output the converted HTML string on a single line to standard output (stdout).## sample

# Hello World

Hello World

</p>