Skip to content

Instantly share code, notes, and snippets.

@aziis98
Last active June 23, 2019 23:52
Show Gist options
  • Select an option

  • Save aziis98/f9f29d72b1475a86308ee15e7b0749ca to your computer and use it in GitHub Desktop.

Select an option

Save aziis98/f9f29d72b1475a86308ee15e7b0749ca to your computer and use it in GitHub Desktop.
Unicode Markdown

Unicode Markdown

All text is processed in blocks, there is a top
block and then more can be nested by using 「those
brackets」.They count as a single character so
tokenizing is easier and they are also less intrusive
in the text. 

「
A block can span multiple lines
」

§₂ Subtitle

An heading spans from the starting symbol to the end
of the line (so no block is needed).

**Bold**  and __Italic__  for now can be as in Markdown
without any new symbol as they are used very frequently.

The macro system is triggered by symbols and then can "ask"
for a number of blocks as arguments or work until a
certain pattern is matched (for the headings).

Links are defined as two blocks with an arrow ➤ in the
middle. A similar system can be made for including files 
or images.

An initial backed can be written in JavaScript (for easy extensibility) but then it can be ported to Rust with the later creataion of a basic system for defining macros and transformations.

UD -> HTML

↪§『depth∈ℕ』『heading』↩↦<h□depth>□heading</h□depth>
「label」➤「url」↦<a href="□url">□label</a>

The first line rapresents the transformations for all headings:

  • , : match the start and the end of the line respectivly.
  • §: is just a symbol to detect headings.
  • 『depth∈ℕ』: this is a lite group that matches a number and places it in the depth variable.
  • 『heading』: matches the the rest of the line and binds it to the heading variable.

On the other side of the map symbol all the square-varname symbols like □depth gets replaced with the matched text.

A better example, less complicated and that shows better the expressivness of this tool, is the second one. A link is composed of two blocks that rappresent the label and the url and the mapping to HTML is very clear and

IDEA: Ok the heading example is too much like "let's recreate regex again" and is not really the point of this

Good looking characters

A list can be implemented like

 • Item 1
 • Item 2
 • Item 3

Or with numbering or styles

1 • Item...
2 • Items
3 • Item

or romans

  i • Item...
 ii • Items
iii • Item

or nested

  i • Item...
 ii • Items
        • Item...
iii • Item
        • Item...
        • Items
        • Item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment