This exercise requires you to use regular expressions (RegEx) using the standard C++ library regex classes.
In this exercise you will read a file that is written in Markdown format. Markdown is text based formatting language that uses a simple set of format markers to allow you to do things like Headings, Bold Text, Indented text, Italics etc. We will have you write code to read in the file, find these format markers using Regex, and convert the format to HTML as a web page
md_convert -i markdown_sample.md -o index.html
markdown_sample.md
file, but you should experiment with other markdown files as well!
Markdown | Markdown 'rule' | HTML |
---|---|---|
# Heading level 1 | Line starts with # | <h1>Heading level 1</h1> |
## Heading level 2 | Line starts with ## | <h2>Heading level 2</h2> |
### Heading level 3 | Line starts with ### | <h3>Heading level 3</h3> |
**Bold** | There are two asterisks followed by alphanumerics, followed by two asterisks | <strong>Bold text</strong> OR <b>Bold text</b> |
_Italics_ | There is an underscore followed by alphanumerics, followed by an underscore | <i>Italicized text</i> |
>Block quote (aligned/ block of text) | Line starts with > (The text after the '>' will be aligned in a block until an empty line is found) | <blockquote>Block quote (aligned/ block of text)</blockquote> |
The CI will publish your generated webpage (index.html). See the CI output in gitlab for the URL to that page. Use the .gitlab-ci.yml
file (make sure you place it in your top level repo folder) to configure the CI correctly. Modify and folder paths if necessary for your setup.
You can view also the results of your markdown-to-html conversion by opening your copying your .html output file to your local PC and opening it in any browser. e.g. In Windows explorer, just right click on 'index.html' and select 'open with Firefox'.
regex_md
. You will place all your code in this folderregex_md_convert
folder)string ConvertH1(string)
or string ConvertBold(string)
parser
, then call the appropriate Conversion methodstd::list<std::string>
or std::vector<std::string>
)<body></body> tags
. Use ifstream
and ofstream
to help read/ write the files.