LHTML+ lhtml-site

Learn LHTML

LHTML is HTML-first: everything you write is HTML, except a few symbols that LHTML converts. The rest goes through untouched, so all of HTML, CSS and JavaScript stays available, <script> and <style> included. Learn these symbols, and you know LHTML.

Each page below shows a few lines of LHTML, the HTML they produce, and the result. To convert your own files with the lhtml command or from Python: Use LHTML alone.

The whole syntax at a glance

You write You get
= Title <h1>Title</h1>; == Section is <h2>, and so on
* item a list; ** item a nested one
**bold** and __italic__ <strong> and <em>
`code` inline code, never read as LHTML
div::[color:gray;] ... :: <div style="color:gray;"> ... </div>
span::[color:red;] word :: <span style="color:red;"> word </span>, inside a sentence
link::https://example.org[text] <a href="https://example.org">text</a>
img::photo.jpg[width:300px;] <img style="width:300px;" src="photo.jpg" ...>
video::clip.mp4{controls} a <video> with its play buttons
code::[python] ... code::[-] a highlighted code block
::nl a one-line vertical space
<p>...</p>, <br> paragraphs and line breaks: a blank line makes none
<b>any HTML</b> kept as it is
Compared with Markdown

LHTML shares **bold**, * lists and `code` with Markdown. Three things work differently, because LHTML follows HTML:

  • __x__ is italic; bold is **x**.
  • Paragraphs are written in HTML: <p> and <br>. Like a browser, LHTML joins the lines of the source (Text).
  • A list starts with *; a numbered list is an <ol> (Lists).

Everything together

The main constructs together
LHTML
= Course notes

== Week 1

* **Read** the chapter on __interpolation__
* Run `python demo.py`
** compare with the slides
* link::https://example.org[The reference]

::[background:#f3f6ff; padding:8px 12px; border-radius:6px;]
A remark in a light blue box.
::
Result
HTML produced
<h1>Course notes</h1>


<h2>Week 1</h2>


<ul>
<li>
<strong>Read</strong> the chapter on <em>interpolation</em>
</li>
<li>
Run <code class="code-inline">python demo.py</code>
<ul>
<li>
compare with the slides
</li>
</ul>
</li>
<li>
<a href="https://example.org">The reference</a>
</li>
</ul>

<div style="background:#f3f6ff; padding:8px 12px; border-radius:6px;">
A remark in a light blue box.
</div>

The essentials in 10 minutes

The table above is the whole syntax. To use it with confidence, read this page, then three pages:

  1. Text: bold, italic, inline code, and why a blank line makes no paragraph.
  2. Blocks and styles: the :: system, the heart of LHTML.
  3. Links and images: link::, img::, video::.

Then, when you need it

Every rule, with its edge cases, is in the Syntax reference.

Next: Headings.

Built with lhtml-site, the docs theme. Part of ScholarTools.