Gemtext is a very simple markup format used by the alternative web protocol Gemini. Write a Gemtext to HTML converter.
From the Wiki:
A line of text is a paragraph, to be wrapped by the client. It is is independent from the lines coming before or after it.
A list item starts with an asterisk and a space. Again, the rest of the line is the line item, to be wrapped by the client.
A heading starts with one, two, or three number signs and a space. The rest of the line is the heading.
A link is never an inline link like it is for HTML: it’s simply a line starting with an equal-sign and a greater-than sign: “=>”, a space, an URI, and some text. It could be formatted like a list item, or like a paragraph. Relative URIs are explicitly allowed.
Example:
# This is a heading This is the first paragraph. * a list item * another list item This is the second paragraph. => http://example.org/ Absolute URI => //example.org/ No scheme URI => /robots.txt Just a path URI => GemText a page link
This should produce this HTML tree (just the equivalent tree, not the exact formatting):
EDIT you don't need the <ul>
tags to produce valid HTML
<h1>This is a heading</h1>
<p>This is the first paragraph.</p>
<li>a list item</li>
<li>another list item</li>
<p>This is the second paragraph.</p>
<a href="http://example.org/">Absolute URI</a>
<a href="//example.org/">No scheme URI</a>
<a href="/robots.txt">Just a path URI</a>
<a href="GemText">a page link</a>
All text must pass through. All of <>"&
should be converted to HTML entities, even if they don't confuse browsers, to be safe
EDIT: For the sake of this question, you don't have to do 2nd and 3rd level headings
This is code-golf so the shortest code in bytes wins
<>
, so you'd need to list each HTML escape, for example. If the question you want to ask is more like that, consider deleting for now and moving to the sandbox, as there are likely a lot of changes required to make it clear. But if you just want it to be a "lazy" conversion then feel free to leave it here. \$\endgroup\$