{"id":13636591,"url":"https://github.com/bungle/lua-resty-hoedown","last_synced_at":"2025-04-11T01:52:02.545Z","repository":{"id":21546806,"uuid":"24866412","full_name":"bungle/lua-resty-hoedown","owner":"bungle","description":"LuaJIT FFI bindings to Hoedown, a standards compliant, fast, secure markdown processing library in C.","archived":false,"fork":false,"pushed_at":"2015-12-16T21:06:18.000Z","size":27,"stargazers_count":26,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-02-15T02:32:59.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bungle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-06T21:52:50.000Z","updated_at":"2020-07-29T03:32:42.000Z","dependencies_parsed_at":"2022-08-21T17:40:27.710Z","dependency_job_id":null,"html_url":"https://github.com/bungle/lua-resty-hoedown","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bungle%2Flua-resty-hoedown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bungle%2Flua-resty-hoedown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bungle%2Flua-resty-hoedown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bungle%2Flua-resty-hoedown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bungle","download_url":"https://codeload.github.com/bungle/lua-resty-hoedown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248328108,"owners_count":21085258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T00:01:03.081Z","updated_at":"2025-04-11T01:52:02.522Z","avatar_url":"https://github.com/bungle.png","language":"Lua","funding_links":[],"categories":["Libraries","Third Modules","Rust Modules"],"sub_categories":["C Modules","Lua Modules"],"readme":"# lua-resty-hoedown\n\n`lua-resty-hoedown` is a Markdown, SmartyPants, buffer, and html and href/url escaping library implementing LuaJIT bindings to\n[Hoedown](https://github.com/hoedown/hoedown).\n\n## Hello World with lua-resty-hoedown\n\n```lua\nlocal hoedown = require \"resty.hoedown\"\nhoedown[[\n# Are you ready for the truth?\n\nNow that there is the Tec-9, a crappy spray gun from South Miami.\nThis gun is advertised as the most popular gun in American crime.\nDo you believe that shit? It actually says that in the little book\nthat comes with it: the most popular gun in American crime. Like\nthey're actually proud of that shit.\n\n## I'm serious as a heart attack\n\nThe path of the righteous man is beset on all sides by the iniquities\nof the selfish and the tyranny of evil men. Blessed is he who, in the\nname of charity and good will, shepherds the weak through the valley\nof darkness, for he is truly his brother's keeper and the finder of\nlost children. And I will strike down upon thee with great vengeance\nand furious anger those who would attempt to poison and destroy My\nbrothers.\n]]\n```\n\nThis will return string containing:\n\n```html\n\u003ch1\u003eAre you ready for the truth?\u003c/h1\u003e\n\n\u003cp\u003eNow that there is the Tec-9, a crappy spray gun from South Miami.\nThis gun is advertised as the most popular gun in American crime.\nDo you believe that shit? It actually says that in the little book\nthat comes with it: the most popular gun in American crime. Like\nthey\u0026#39;re actually proud of that shit.\u003c/p\u003e\n\n\u003ch2\u003eI\u0026#39;m serious as a heart attack\u003c/h2\u003e\n\n\u003cp\u003eThe path of the righteous man is beset on all sides by the iniquities\nof the selfish and the tyranny of evil men. Blessed is he who, in the\nname of charity and good will, shepherds the weak through the valley\nof darkness, for he is truly his brother\u0026#39;s keeper and the finder of\nlost children. And I will strike down upon thee with great vengeance\nand furious anger those who would attempt to poison and destroy My\nbrothers.\u003c/p\u003e\n```\n\n## Installation\n\nJust place [`resty directory`](https://github.com/bungle/lua-resty-hoedown/blob/master/lib/resty) somewhere in your `package.path`. If you are using OpenResty, the default location would be `/usr/local/openresty/lualib`.\nPlease check though that you do not overwrite the existing resty-directory if one exists already.\n\n### Compiling and Installing Hoedown C-library\n\nThese are just rudimentary notes. Better installation instructions will follow:\n\n1. First download Hoedown from here: https://github.com/hoedown/hoedown\n2. Run `make`\n3. Place `libhoedown.so` somewhere in the default search path for dynamic libraries of your operating system (or modify `resty/hoedown/library.lua` and point `ffi_load(\"libhoedown\")` with full path to `libhoedown.so`.\n\n### Using LuaRocks or MoonRocks\n\nIf you are using LuaRocks \u003e= 2.2:\n\n```Shell\n$ luarocks install lua-resty-hoedown\n```\n\nIf you are using LuaRocks \u003c 2.2:\n\n```Shell\n$ luarocks install --server=http://rocks.moonscript.org moonrocks\n$ moonrocks install lua-resty-hoedown\n```\n\nMoonRocks repository for `lua-resty-hoedown` is located here: https://rocks.moonscript.org/modules/bungle/lua-resty-hoedown.\n\n## Lua API\n\nThere are some functions called `free` on the API (to be complete implementation of Hoedown). You don't really need to\ncall `:free()` as the library automatically handles freeing the external resources using normal LuaJIT garbage collector\n(the library registers the garbage collector handlers with `ffi.gc`).\n\n### Document Processing Extensions\n\nWith extensions, you may extend how to document processing works.\nHere are the available extensions:\n\n```lua\ntables                = HOEDOWN_EXT_TABLES,\nfenced_code           = HOEDOWN_EXT_FENCED_CODE,\nfootnotes             = HOEDOWN_EXT_FOOTNOTES,\nautolink              = HOEDOWN_EXT_AUTOLINK,\nstrikethrough         = HOEDOWN_EXT_STRIKETHROUGH,\nunderline             = HOEDOWN_EXT_UNDERLINE,\nhighlight             = HOEDOWN_EXT_HIGHLIGHT,\nquote                 = HOEDOWN_EXT_QUOTE,\nsuperscript           = HOEDOWN_EXT_SUPERSCRIPT,\nmath                  = HOEDOWN_EXT_MATH,\nno_intra_emphasis     = HOEDOWN_EXT_NO_INTRA_EMPHASIS,\nspace_headers         = HOEDOWN_EXT_SPACE_HEADERS,\nmath_explicit         = HOEDOWN_EXT_MATH_EXPLICIT,\ndisable_indented_code = HOEDOWN_EXT_DISABLE_INDENTED_CODE\n```\n\n##### Example\n\n```lua\nlocal hoedown = require \"resty.hoedown\"\nprint(hoedown.document.extensions.tables)\nlocal doc = require \"resty.hoedown.document\"\nlocal extensions = doc.extensions\nprint(extensions.tables)\n```\n\n### HTML Rendering Flags\n\nWith HTML rendering flags you can control the HTML rendering process.\nHare are the available flags:\n\n```lua\nskip_html = HOEDOWN_HTML_SKIP_HTML,\nescape    = HOEDOWN_HTML_ESCAPE,\nhard_wrap = HOEDOWN_HTML_HARD_WRAP,\nuse_xhtml = HOEDOWN_HTML_USE_XHTML\n```\n\n##### Example\n\n```lua\nlocal hoedown = require \"resty.hoedown\"\nprint(hoedown.html.flags.skip_html)\nlocal html  = require \"resty.hoedown.html\"\nlocal flags = html.flags\nprint(flags.use_xhtml)\n```\n\n### HTML Tag States\n\nThese present values returned from `resty.hoedown.html.is_tag` function.\nThe possible values are:\n\n```lua\nnone  = HOEDOWN_HTML_TAG_NONE,\nopen  = HOEDOWN_HTML_TAG_OPEN,\nclose = HOEDOWN_HTML_TAG_CLOSE\n```\n\n##### Example\n\n```lua\nlocal hoedown = require \"resty.hoedown\"\nprint(hoedown.html.tag.open)\nlocal html = require \"resty.hoedown.html\"\nlocal tag  = html.tag\nprint(tag.open)\n```\n\n### resty.hoedown\n\nA helper library that you may `require` with a single statement.\n\n#### string hoedown(source, opts)\n\nHelper function to rendering. `source` is a `string` containing a source document.\nYou can also pass in options with `opts` argument. Here are the different options\nthat you may use (you can also skip passing options):\n\n```lua\nopts = {\n    renderer    = (\"html\" or \"html.toc\" or function or nil),\n    extensions  = (table or number or nil),\n    max_nesting = (number or nil),\n    flags       = (table or number or nil),\n    nesting     = (number or nil),\n    smartypants = (true or false or nil)\n}\n```\n\n##### Example\n\n```lua\nlocal hoedown = require \"resty.hoedown\"\nprint(hoedown[[\n# Hello World\n\nHi this is Markdown.\n]])\n\nlocal flags = hoedown.html.flags\n\nprint(hoedown([[\n# Hello World\n\nHi this is Markdown.\n]], {\n    rendered    = \"html.toc\",\n    nesting     = 1,\n    flags       = { flags.use_xhtml, \"escape\", 1 },\n    extensions  = { \"underline\", \"quote\" },\n    smartypants = true\n}))\n```\n\n#### Fields\n\n##### table resty.hoedown.buffer\n\nThis returns a [`buffer`](#restyhoedownbuffer) module.\n\n##### table resty.hoedown.document\n\nThis returns a [`document`](#restyhoedowndocument) module.\n\n##### table resty.hoedown.html\n\nThis returns an [`html`](#restyhoedownhtml) module.\n\n##### table resty.hoedown.escape\n\nThis returns an [`escape`](#restyhoedownescape) module.\n\n##### table resty.hoedown.version\n\nThis returns a [`version`](#restyhoedownversion) module.\n\n### resty.hoedown.buffer\n\n#### cdata buffer.context\n#### string buffer.data\n#### number buffer.size\n#### number buffer.asize\n#### number buffer.unit\n#### table buffer.new(size)\n#### buffer:reset()\n#### buffer:grow(size)\n#### buffer:put(str)\n#### buffer:puts(str)\n#### buffer:set(str)\n#### buffer:sets(str)\n#### boolean buffer:eq(str)\n#### boolean buffer:eqs(str)\n#### number buffer:prefix(prefix)\n#### buffer:slurp(size)\n#### cdata buffer:cstr()\n#### buffer:printf(format, ...)\n#### buffer:free()\n#### number buffer.__len()\n#### boolean buffer:__eq()\n#### string buffer:__concat(x, y)\n#### string buffer:__tostring()\n\n### resty.hoedown.document\n\n#### cdata document.context\n#### table document.extensions\n#### table document.new(renderer, extensions, max_nesting)\n#### string document:render(data)\n#### string document:render_inline(date)\n#### document:free()\n\n### resty.hoedown.html\n\n#### cdata html.context\n#### table html.flags\n#### table html.tag\n#### string html.smartypants(data)\n#### number html.is_tag(data, tag)\n#### table html.new(flags, nesting)\n#### html:free()\n#### table html.toc\n#### table html.toc.new(nesting)\n#### html.toc:free()\n\n### resty.hoedown.escape\n\n#### string escape(source, secure)\n#### string escape.href(source)\n#### string escape.html(source, secure)\n\n### resty.hoedown.version\n\n#### number version.major\n#### number version.minor\n#### number version.revision\n#### string version:__tostring()\n\n## License\n\n`lua-resty-hoedown` uses two clause BSD license.\n\n```\nCopyright (c) 2014, Aapo Talvensaari\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n  list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this\n  list of conditions and the following disclaimer in the documentation and/or\n  other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbungle%2Flua-resty-hoedown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbungle%2Flua-resty-hoedown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbungle%2Flua-resty-hoedown/lists"}