GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - bakpakin/luamd: Markdown to HTML in pure Lua.

BranchesTags
Open more actions menu

Latest commit

 

History

29 Commits
29 Commits

Folders and files

NameName
Last commit message
Last commit date
rockspecs
rockspecs
 
 
test_documents
test_documents
 
 
.gitignore
.gitignore
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
luamd
luamd
 
 
md.lua
md.lua
 
 
mddev
mddev
 
 
testrender.lua
testrender.lua
 
 

Repository files navigation

luamd

luamd is a Markdown to HTML renderer written in portable, pure Lua. It's also really easy to use.

local md = require "md"
local htmlFragment = md[[
# This is Some Markdown
Write whatever you want.
* Supports Lists
* And other features
]]

Install

Copy md.lua to your project in whatever directory you want.

Use it

Render markdown from a string. On bad input, retuns nil and an error message.

local html, err = md.renderString(str, options)

Render markdown from a line iterator. An iterator is a function the returns successive lines when called repeatedly, and nil when there are no lines left.

local html, err = md.renderLineIterator(iter, options)

Render markdown from a list like table of lines.

local html, err = md.renderTable(t, options)

Renders strings, iterators, and tables.

local html, err = md.render(object, options)

Calling the module as a function will invoke md.render. This is the easiest way to use the module.

The options table is an optional table of options. The currently supported options are below.

  • tag - Surrounding HTML tag for HTML fragment.
  • attributes - A table attributes for the surround HTML node. For example, { style = "padding: 10px;" }.
  • insertHead - An HTML fragment to insert before the main body of HTML. (Inserted after the wrapping tag, if present.)
  • insertTail - An HTML fragment to insert after the main body of HTML. (Inserted before the closing tag, if present.)
  • prependHead - An HTML fragment to insert before the main body of HTML. (Inserted before the opening tag, if present.)
  • appendTail - An HTML fragment to insert after the main body of HTML. (Inserted after the closing tag, if present.)

Here is a little diagram for where the optional fragments go.

** prependHead **
<tag [attributes k1="v1" k2="v2" k3="v3" ...]>
    ** insertHead **

    ... rendered markdown ...

    ** insertTail **
</tag>
** appendTail **

Testing

There is no unit-testing yet, but testing can be done by running the testrender.lua script. This builds HTML files in the test_documents directory that correspond to the markdown source files. Open these with a web browser and assure that they look fine. To add more test documents, place a markdown file in the test_documents folder and add it to the documents list in testrender.lua.

Todo

Needs some good unit testing. :).

Supports most of basic Markdown syntax, but there are some features that need to be implemented. I haven't implemented them because I don't need them - yet.

  • HTML and code escapes - Probably the most important one on the list.
  • Some alternative syntax for numbered Lists (using #.)
  • Indent style code - I prefer backtick quoted code
  • Tables - GitHub style tables would be cool
  • Footnotes - Might need them, but not yet.

Bugs

If anyone wants to use this and finds bugs and issues, let me know! I usually can fix things pretty quickly, and I appreciate help.

About

Markdown to HTML in pure Lua.

Resources

Readme
MIT license
Activity

Stars

40 stars

Watchers

5 watching

Forks

12 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.