2025-12-13 01:28:21 +04:00
2025-12-14 22:31:17 +04:00
2025-12-14 22:31:17 +04:00
2025-12-13 01:28:21 +04:00
2025-12-13 01:28:21 +04:00
2025-12-13 01:28:21 +04:00
2025-12-13 01:28:21 +04:00
2025-12-13 01:28:21 +04:00
2025-12-14 23:45:26 +04:00
2025-12-13 01:28:21 +04:00

lua-discount3 Markdown

Lua bindings for the Discount Markdown library version >3.0.

Fork of Craig Barnes archive: https://github.com/craigbarnes/lua-discount

Jessica (ex- David) L. Parsons wrote (https://www.pell.portland.or.us/~orc/Code/discount/downloads.html):


I ran out of slots in the original bitmap flags structure, so I dumped it and replaced it with a new flag blob accessed through a flag pointer. This broke the entire published interface and required the update to version 3 (this is why it took me over 3 years to implement it; I needed to test the code to within an inch of its life and between that and transitioning it just ate up time like you wouldnt believe!)
Because I changed the mkd_flag_t structure and replaced it with a blob, the old flags are now a pointer and using the mkd_flag_isset(), mkd_set_flag(), and mkd_clr_flag() functions I introduced during the end of the run for version 2.x.x is now mandatory unless youre fond of core dumps.
The way Id originally implemented HTML5 (if thats even a thing anymore?) support was to have a global structure that I allocated once and then you were stuck with it forever (and had to deallocate the structure whenever you stopped using the library otherwise it would leak memory), so I fixed that for v3.0.0 by moving the html5 details inside the MMIOT (activated by setting the flag MKD_HTML5) so it will automatically be deallocated when you are done with a document without affecting other MMIOTs.

Here is the implementation of bindings for discount v3 API.

Install


luarocks install discount3


Troubleshooting

If you get a compilation error during installation, it's because discount isn't installed as a shared library. See the solution here: https://gitlabor.ru/Datenlabor/discount

Usage

local markdown = require('discount3')

local html = markdown.compile(markdown_text)

print(html.body)

Returns:

table:

  • body - html body
  • title - doc's title (if header exists)
  • author - doc's autor (if header exists)
  • date - docs's date (if header exists)
  • css - docs's CSS (if
Description
Lua bindings for the Discount V3 Markdown library.
Readme ISC 565 KiB
Languages
C 67.5%
Lua 23%
Makefile 9.5%