Meltdown: CS201 Exrecises
A set of programming questions for a 201 level Computer Science Student that reflect the programming used in developing the Meltdown parser.
GitHub Code Repository
This implements the Meltdown to HTML parser as well as some sample code:
djaus2/Meltdown
Meltdown V2.1.0 is now available as Nuget package and can be used with any .NET 5.0 apps.
https://www.nuget.org/packages/Meltdown/
Context
Whilst the GitHub Meltdown repository has been written using C#, it could be authored in any suitable language. These question notionally are for C#-.NET but could be implemented in what ever context you wish.
- Given a string that consists of a number of lines, each terminated with the newline, ‘\n’ character, how do you break it up into lines? Write a code snippet that takes the string, and prints its line by line.
- Given string that is a single line, how do you replace all instances of a specific string with another? For the following Meltdown patterns, write the code that takes a single line and replaces the beginning and ending Bold, Italics and Underline Meltdown markup with their HTML codes. You can assume that for every opening Meltdown tag there is a closing one on the line. Q. How could you enforce this?
Format | Markup |
---|---|
Bold | [[text]] |
Italics | ((text)) |
UnderLine | `````` |
- How can you check the first 5 characters of a line for the
[[n]]
pattern at the start of a line when n is a digit? Apply the HTML heading begin and end tags to such lines. Follow up, can you do this for the Markdown ## format where the number of consecutive hashtags at the start of line followed by a space indicates the HTML heading level? - Similarly, can you code
((n))
recognition (n is a digit representing the list level starting at 1) at the start of a line and translate into HTML unordered list?. Hint: This requires a bit more care with multiple level lists. - Can you implement tables where
((T))
at the start of a line is a table header, with headings a csv list, and((t))
is a table row with cells being a csv list as well? ((*|*))
anywhere in the line represents a font color which is interpreted as ((font color|text to be colored)). Can you repeatedly find such patterns in a line and replace them with the equivalent HTML code?<<*|*>>
anywhere in the line is a link with the first part being the link text and second part the Url. Can you repeatedly find such patterns in a line and replace them with the equivalent HTML code?- Implement each of the above as method in a class, with and an overarching Parse method that takes the initial string as input, breaks it into lines, calls these methods in a suitable order, and returns the generated HTML. Create some text vectors.
- Implement any of the other Meltdown features as per Meltdown Schema
- Complete this exercise but “dotting the Is and crossing the Ts”. For example, you is a line is not part of a list, you will need to check if the previous line was part of an un-terminated listt and insert one or more ```</ul>`` into the text stream if so; etc.
ENJOY!
Topic | Subtopic | |
This Category Links | ||
Category: | Web Sites Index: | Web Sites |
Next: > | Meltdown | Send Mail and Nuget Package |
< Prev: | Meltdown | Coding |