Meltdown is a text markup parser that is meant as a simple alternative to Markup for novice users.

Build a better mousetrap, and the world will beat a path to your door.

Meltdown is a text markup parser that is meant as a simple alternative to Markup for novice users. Simplicity in use and coding thereof is how it is intended as a “better mousetrap” than Markup. Does it measure up? It’s available as a Nuget package and as source on GitHub including some sample apps.

HTML tags may be an anathema for a non-programmer using a Content Management System. Markdown is a basic Markup language for converting plain text to formatted text. It has widespread adoption in apps and web sites for generating HTML formatted text from raw text. By inserting additional human readable characters into the body of a text, Markdown can convert them into HTML tags such that when the converted text is viewed in a web browser, the text appears appropriately formatted. Markdown provides a good mechanism for generating formatted text. It is used in many web apps such as GitHub, StackOverflow for user input of informative content such as Wikis, discussions and comments. Many CMS systems such as WordPress and website generators such as Jekyll have a Markdown plugin. Document editors such as Microsoft Word can load and save documents in Markdown format with a plugin.

So if Markup is so good and widely used why reinvent the wheel? The markup parser Meltdown has simplicity as its objectives. It is meant to be even simpler to use than Markdown and also simple to implement in code. Its target audience is a low-level non-technical user (read luddite) in an email sending web app context. The user wants to send an HTML formatted email to a mail list in a web app that takes the message as marked up input in a text panel. To that end Meltdown also has a method in its library for sending the email. Markup in Meltdown is implemented in two ways. Meltdown makes much use of bracketing. As a mathematician I quite used to clarifying expressions with brackets.

The Meltdown parser is passed a string containing multiple lines that are converting into an array of string lines. The default action is convert each line into a paragraph by prefixing it with <p> and postfixing it with </p>. A new line can be inserted in a paragraph using double exclamation marks. Within a paragraph, much use is made of square brackets parentheses and braces in delimiters, with an opening a delimiter containing two of them and closing with its mirror. By using brackets in twins to indicate markup, there can be no confusion with the normal individual use of brackets. For example:

  • [[text]] will be parsed to <b>text</b> and display in a browser as text.
  • ((text)) will be parsed to <i>text</i> and display in a browser as text.
  • [(text)] will be parsed to <b><i>text</i></b> and display in a browser as text.

Notes: The “mirror” of [( is )] etc.
Also, The only context that uses double brackets that I have come across is Jekyll that uses double braces. Hence as this site uses Jekyll there have been some workarounds for when double braces are required in the text.

Basic Formatting

Format Markup Opening Delimiter Notes
Bold [[text]] 2 SquareBrackets e.g. Bold is [[Text]]
Italics ((text)) 2 Parentheses  
UnderLine {{text}} 2 Braces  
Bold-Italics [(text)] SquareBracket-Parentheses Order doesn’t matter, but close delimiter must mirror
Bold-Underline [{text}] SquareBracket-Brace Order doesn’t matter, but close delimiter must mirror
Italics-Underline ({text}) Parentheses-Brace Order doesn’t matter, but close delimiter must mirror
Bold-Italics-Underline [({text})] SquareBracket-Parentheses-Brace Order doesn’t matter, but close delimiter must mirror

Examples


string msg = “nAA[[This is Bold]]BB”;
msg + = “\nAA((This is Italics))BB”;
msg + = “\nAA{{This is Underline}}BB;”
msg += “\nAA[({This is bold-italics-underline})]BB”;
string HtmlText = Meltdown.Meltdown.Parse(msg);

HtmlText Result

<p>AA<b>This is Bold</b>BB</p>
<p>AA<i>This is Italics</i>BB</p>
<p>AA<u>This is Underline</u>BB</p>
<p>AA<b><i><u>This is bold-italics-underline</u></i></b>BB</p>

Which displays as:

AAThis is BoldBB

AAThis is ItalicsBB

AAThis is UnderlineBB

AAThis is bold-italics-underlineBB


More Formatting

The setting of text color is also facilitated through double parentheses tags.
(With the vertical bar it has precedence over the Italics format).

Format Markup Outcome
Font Color ((color name|text)) <font color="color name">text</font>

Note the vertical bar as the separator between the setting (color in this case) and the text to be formatted. This layout is also used with HTML links:

Format Markup Outcome
Links <<url|link text>> <a href="url">link text</a>
’’’ <<url>> <a href="url">url</a>

Examples


Markup:
"AA((red|This is red))BB((blue|This is blue))CC"
HTML:
<p>AA<font color="Red">This is red</font>BB<font color="Blue">This is blue</font>CC</p>
Displays as:

AAThis is redBBThis is blueCC


Markup:
"AA<<https://davidjones.Sportronics.com.au|My Blog Site>>CC"
HTML:
<p><a href="https://davidjones.sportronics.com.au">My Blog Site</a></p>
Displays as:

My Blog Site


Note that as a concession, the Markdown format for HTML links can be used.

Headings, Lists and Tables

Lines that start with certain bracket combinations are interpreted as headings, lists or tables rather than paragraphs.

  • ((1)) at the start is interpreted as a first level list
  • [[1]] at the start of a line will format that line as a heading level 1.
  • [[T]] at the start is interpreted as a table header
  • [[t]] at the start is interpreted as a table row.

Headings

Pairs of square brackets at the start of a line surrounding a single digit mark a Heading of that level.
(Note that this takes precedence over the Bold format.)

Format Markup Notes
Heading [[n]] at start of line where n=1..9

Example: Heading


Markup:
[[3]]Heading Level 3
HTML:
<h3>Heading Level 2</h3>
Displays as:

Heading Level 3


Note as a second concession, the # format for headings as per Markdown can also be used.

Lists

Format Markup Notes
Bullet List -space or -tab at start of line Only one level of list
List Multilevel ((n)) at start of line where n=1..9

Example 1: Simple (Bullet) List


Markup:

- List line 1
- List line 2
- List Line 3

HTML:

<ul>
<li>List line 1</li>
<li>List line 2</li>
<li>List line 3</li>
</ul>

Displays as:

  • List line 1
  • List line 2
  • List line 3

Example 2: Multilevel List


Markup:

((1)) Extended list level one
((1)) Extended list level 1
((2)) Extended list level two
((3)) Extended list level three
((2)) Extended list level two
((1)) Extended list level one

HTML:

<ul>
    <li> Extended list level one
    </li>
    <li> Extended list level 1
    <ul>
        <li> Extended list level two
        <ul>
            <li> Extended list level three</li>
        </ul>
        </li>
        <li> Extended list level two</li>
    </ul>
    </li>
    <li> Extended list level one</li>
</ul>

Displays as:

  • Extended list level one
  • Extended list level 1
    • Extended list level two
      • Extended list level three
    • Extended list level two
  • Extended list level one

Comment: I think this is clearer and far less error prone than minus signs, spaces and tabs for multilevel lists.

Tables

Format Markup Notes
Table ((T)) at start of each line Table Header row. Headings are a Csv list.
,, ((t)) at start of each line Table Data row. Cells are a Csv list

The headings in a table header line are a CSV list as are the cells in a table row.


Example: Table


Markup:

((T))Name,Age,Country
((t))Fred,23,Australia
((t))Sue,45,USA
((t))John,21,NZ

HTML:

<table>
<tr><th>Name</th><th>Age</th><th>Country</th></tr>
<tr><td>Fred</td><td>23</td><td>Australia</td></tr>
<tr><td>Sue</td><td>45</td><td>USA</td></tr>
<tr><td>John</td><td>21</td><td>NZ</td></tr>
</table>

Displays as:

NameAgeCountry
Fred23Australia
Sue45USA
John21NZ

Comment: To my mind this is far simpler than Markdown tables.


The Meltdown Details

Class Methods

Method: public static string Parse(string txt)
Summary: Parse Meltdown markup text into HTML.
Input: The string of lines, delimited by the newline character.
Output: The marked up HTML.

Method: public static string SendMailMinimal(string Name, string FromEmail, string FromPassword, string ToEmail, string Subject, string htmlText, string Url, int Port)
Summary: Send a HTML formatted email using SmtpClient.

Method: static void SetDelimiters(string formatCsv, string webColorCsv)
Summary: Change the default delimiters by sending as Csv lists.

GitHub Code Repository

This implements the Meltdown to HTML parser as a .NET library as well as some sample code projects:
djaus2/Meltdown

Nuget:

The Meltdown library has been publish for .NET 5 as a package on Nuget.
https://www.nuget.org/packages/Meltdown/

To get the latest package: Install-Package Meltdown

Blog Posts:

Meltdown Posts


Cheat Sheet

Format Markup Notes
Bold [[text]] e.g. Bold is [[Text]]
Italics ((text))  
UnderLine {{text}}  
Bold-Italics [(text)] Order doesn’t matter, but close delimiter must mirror
Bold-Underline [{text}] Order doesn’t matter, but close delimiter must mirror
Italics-Underline ({text}) Order doesn’t matter, but close delimiter must mirror
Bold-Italics-Underline [({text})] Order doesn’t matter, but close delimiter must mirror
Font Color ((color name|text))  
Links <<url>>  
,, <<link text|url>>  
Heading [[n]] at start of line where n=1..9 eg [[2]]Heading Level 2
Bullet List -space or -tab at start of line Only one level of list
List Multilevel ((n)) at start of line where n=1..9
Table ((T)) at start of each line Table Header row. Headings are Csv list.
,, ((t)) at start of each line Table Data row. Cells are a Csv list
New line !! Anywhere in text translates to <br/>

Conclusion

Meltdown was developed with the objective that end users, those that use it in-app, fine it simpler and more intuitive to use as a Text to HTML Markup language. The library was specifically created for .NET email sending web app where the app user would normally submit HTML formatted text, or use a Markup parser to generate that. A Blazor example is provided in the GitHub repository that demonstrates parsing lines of text into HTML using Meltdown and sending the HTML as an email.

Meltdown was envisaged such that a second level developer (CS201) could write the parser. Whilst that is true for most of the functionality, some aspects were a little more complex to code.

Final comment: May be some of these constructs could be submitted as Markdown extensions. Apart from the bracketing and at start-of-line simplicity, I feel the Meltdown approach to to tables with its Csv list of headings and cells is far simpler than Markdown. Also the Meltdown approach for complex multi-level lists is indeed simpler and less error prone.


 TopicSubtopic
  Next: > Blazor Helpers App Twilio
   
 This Category Links 
Category:Web Sites Index:Web Sites
  Next: > Jekyll
<  Prev:   Meltdown