Meltdown: Intro - A Simple Markup Parser
A simple to code and use line based Markup language making much use of brackets within a line and with start of line monikers for whole of line impact.
The key point is to bracket the text that is to be formatted. Also, some line based content is simple to annotate with some characters at the start of the line.
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/
This Version 2.1
With strict adherence to precedence, pairs of brackets can have multiple meanings depending upon context. This version limits all markup to only use pairs, no triplets, except in one case:
- ColorPattern is based upon 2 brackets, not 3 …
"*((*|*))*"
- Link Patterns use greater than and less than symbols …
"*<<*|*>>*"
and"*<<*>>*"
- The bold-italic-underline format is the only triplet used:
[({ ... })]
- Line break within paragraph:
!!
translates to<br/>
- Code totally restructured.
Context
When implementing SendMail functionality with C# code, for example in a Blazor app, you can send unformatted text or text formatted with HTML tags. HTML tags are though not simple for a luddite. Alternatively, one could provide a Markdown parser to generate HTML tags. Meltdown is meant to be a simple to implement markup as a parser that outputs HTML, that makes much use of brackets.
Key Features
[[...]], ((...))
and {{…}} used for format Bold italics and underline, within a line.- Code ahs been formalised making it easy to change the delimiters used.
-
font color and links implemented with 3 bracket pairs {{… …}} and <<..!..>>
respectively.Note these are in 2 parts using as a separator. -
Easy to include Meltdown class into, say, the email functionality of a Blazor app.
-
Implemented headings. eg,
[[2]]
At start of line becomes
<h2>At start of Line</h2>
-
Simple lists
-<space>
and-<tab>
at start. One level only. -
Extended multi-level list: Lines start with
((n))
where n is line level. -
Table Header row starts with ((T)) Headings are a Csv list
Table data rows start with ((t)). Cell data is a Csv list -
Test console app included that has some test strings.
- BlazTest a Blazor Server App with which you can compose or paste text that then then gets parsed by Meltdown. Shows the rendered Html as well. Some samples on offer like the console Test app as well.
The Acid Tests
-
Can the markup syntax be implemented in, say, C#, by a CS201 level student?
-
Is the formatting easier than Markdown to use by a non-programmer?
Specification
The generated content is HTML so
-
The source content is, in the main, Text.
-
HTML can be seamlessly embedded in a page, and so is unmodified by the parser.
-
Certain start and end bracket sequences HTML format the internal text by replacing the brackets with the required HTML begin and end tags.
-
The brackets are used in pairs so that a sequence consisting of an open bracket, close bracket and text in between is unchanged.
-
Open brackets are combinations of [ ( and {
-
The corresponding close brackets are a mirroring pair of } ) and ]
-
For example:
[[Hello there]]
will translate to<b\>Hello there</b>
-
Where a parameter is required, or the sequence is in two parts a | is used as a separator.
-
Formatting tags can be combined with inner text of a Meltdown tag conforming to another tag. But 3 character bracketing tags are defined explicitly for often some combinations.
- Desirable: Text can be written in Word and with simple modification be used with a copy a paste as Meltdown.
- Some additional features are indicated by 5 characters at start of the a line:
Headings[[n]]
, Multilevel list((n))
and Table((T))/((t))
Nb 1: Bold, italics and underline formats are a pair of [,{ or {. Other combinations are used for pairs of these format. A delimiter consisting of all 3 is used for a format involving all 3.
Nb 2: Markdown syntax has also been implemented also been implemented for some other entities; currently for HTML links.
Next: The Meltdown Schema
Topic | Subtopic | |
< Prev: | Blazor-IoT | An Azure IoT Bridge via Blazor |
This Category Links | ||
Category: | Web Sites Index: | Web Sites |
Next: > | Meltdown | Schema |
< Prev: | Jekyll | Redirect http to https |