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:
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:
- Text: bold, italic, inline code, and why a blank line makes no paragraph.
- Blocks and styles: the
::system, the heart of LHTML. - Links and images:
link::,img::,video::.
Then, when you need it
- Headings:
=,==, with a class or an id. - Lists:
*,**, and numbered lists in HTML. - Classes and ids:
(.note #tip)on blocks, headings, links and images. - Code: highlighted code blocks.
- HTML, formulas and Jinja: what LHTML leaves alone.
- Your own tags: macros: a tag declared once, used on every page.
Every rule, with its edge cases, is in the Syntax reference.
Next: Headings.