Skip to content

dan200/LHP

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

LHP

LHP ("Lua Hypertext Processor") is an ultra minimal text file parser for embedding Lua code within other kinds of documents, just like PHP. It was created as part of a static website generator, but could in principle be used on a web server for dynamic website generation, or for any text creation task.

Example usage

Input file:

<!DOCTYPE HTML>
<html>   
    <body>
      <h1>The Fibonacci sequence:</h1>
      <ul>
        <?lua
          -- Print the first ten digits of the fibonacci sequence
          local a, b = 0, 1
          for n=1,10 do
            print( "<li>" .. a .. "</li>" )
            a, b = b, a + b
          end
        ?>
      </ul>
    </body>
</html>

Compiling:

lua lhp.lua input.lhp output.html

Output file:

<!DOCTYPE HTML>
<html>   
    <body>
      <h1>The Fibonacci sequence:</h1>
      <ul>
        <li>0</li>
        <li>1</li>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>5</li>
        <li>8</li>
        <li>13</li>
        <li>21</li>
        <li>34</li>
      </ul>
    </body>
</html>

About

Lua Hypertext Processor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages