From cf606524661b6e32e6e15dff1677c794784a2672 Mon Sep 17 00:00:00 2001 From: Michele Sessa Date: Mon, 25 Sep 2023 11:13:56 +0100 Subject: [PATCH] feat(markdown_to_html): new optional exercise for rust piscine --- subjects/markdown_to_html/README.md | 76 +++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 subjects/markdown_to_html/README.md diff --git a/subjects/markdown_to_html/README.md b/subjects/markdown_to_html/README.md new file mode 100644 index 00000000..4c542cbe --- /dev/null +++ b/subjects/markdown_to_html/README.md @@ -0,0 +1,76 @@ +## markdown_to_html + +### Instructions + +Create a function which converts markdown into HTML. + +To easier the task you'll only have to account for the first three titles (`#`, `##`, `###`) and for `bold` and `italic` (`**` and `*`). + +Parsing and converting markdown can be very tricky and some edge cases can require a lot of time to solve, for this reason we will limit the tests to correct and simple inputs. + +No tests will be more complicated than the one showed in the usage example. + +### Expected Function + +```rust +pub fn markdown_to_html(s: &str) -> String { +} +``` + +### Usage + +Here is a possible program to test your function, + +```rust +const EXAMPLE: &str = "# This is a nice converter + + ## It handle *all* titles + +## From # to ### with no problems + +### With attention to details ;) +###With attention to details ;) + +> Blockquotes are handled too +>if well formatted of course + +And **bold** and *italics* of course work as well. + +**** + +**bold on +multiple +lines +also**"; + +fn main() { + println!("{}", markdown_to_html(EXAMPLE)); +} +``` + +And its output: + +```console +$ cargo run +

This is a nice converter

+ +

It handle all titles

+ +

From # to ### with no problems

+ +

With attention to details ;)

+###With attention to details ;) + +
Blockquotes are handled too
+>if well formatted of course + +And bold and italics of course work as well. + + + +bold on +multiple +lines +also +$ +```