https://github.com/soapdog/lua-markdown-extra
A rock that is able to process markdown files with metadata
https://github.com/soapdog/lua-markdown-extra
lua luarocks markdown metadata
Last synced: 5 months ago
JSON representation
A rock that is able to process markdown files with metadata
- Host: GitHub
- URL: https://github.com/soapdog/lua-markdown-extra
- Owner: soapdog
- License: mit
- Created: 2016-10-10T20:41:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-03T15:59:15.000Z (about 2 years ago)
- Last Synced: 2025-08-24T21:03:18.537Z (5 months ago)
- Topics: lua, luarocks, markdown, metadata
- Language: Lua
- Homepage:
- Size: 12.7 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lua-markdown-extra
[](https://travis-ci.org/soapdog/lua-markdown-extra)
[](https://raw.githubusercontent.com/soapdog/lua-markdown-extra/master/LICENSE)
[](https://luarocks.org/modules/soapdog/lua-markdown-extra)
[](https://img.shields.io/badge/Lua-5.1%2C%20JIT%2C%205.2-blue.svg)
[](https://github.com/soapdog/lua-markdown-extra/issues)
[](https://github.com/soapdog/lua-markdown-extra/stargazers)
[]()
A rock that is able to process markdown files with metadata
## Instalation
You can install it with [Luarocks](http://luarocks.org)
``` $ luarocks install lua-markdown-extra```
## Usage
Consider the following markdown file:
```
This is my Markdown
# This is a title
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate assumenda provident nisi accusamus animi magnam porro id, vel saepe voluptate similique quia quis exercitationem, soluta, error dolorem modi obcaecati. Iusto?
```
You can process it with ```markdown_extra.from_file(filePath)``` or ```markdown_extra.from_string(stringContent)``` both functions return two values ```html, metadata```:
```
local mde = require "markdown_extra"
local html, metadata = mde.from_file("test.md")
```
The ```html``` will contain your processed markdown, the ```metadata``` will be a table with your metadata. The metadata frontmatter needs to be in [YAML](http://yaml.org) format. If you have an error in your frontmatter, the ```metadata``` variable will be ```nil```.
## API
### markdown_extra.from_file(path)
Process the file specified by ```path``` and returns both html and metadata.
### markdown_extra.from_string(stringContent)
Process the content specified by ```stringContent``` and returns both html and metadata.
### markdown_extra.set_metadata_delimiters(startDelimiter, endDelimiter)
Change the delimiters used to find the metadata at the start of the markdown content. The default values are ``````.
### markdown_extra.enable_unsafe(yes)
Change the options for `cmark` from `OPT_DEFAULT` to `OPT_UNSAFE`
## Testing
I am using ```busted``` for testing. You can check our test spec inside the ```spec``` folder.