https://github.com/leafo/lua-syntaxhighlight
A code syntax to HTML highlighter using lexers from Textadept
https://github.com/leafo/lua-syntaxhighlight
lua syntax-highlighting textadept
Last synced: 8 months ago
JSON representation
A code syntax to HTML highlighter using lexers from Textadept
- Host: GitHub
- URL: https://github.com/leafo/lua-syntaxhighlight
- Owner: leafo
- Created: 2019-09-25T06:01:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-09T13:55:46.000Z (over 2 years ago)
- Last Synced: 2025-04-20T17:39:48.502Z (8 months ago)
- Topics: lua, syntax-highlighting, textadept
- Language: Lua
- Size: 268 KB
- Stars: 22
- Watchers: 6
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# syntaxhighlight

Highlights code into HTML using lexers from [Textadept](https://foicica.com/textadept/).
```lua
local sh = require("syntaxhighlight")
local html = sh.highlight_to_html("lua", [[
local function hello_world(times)
for i=1,times do
print("hello world")
end
end
]])
print(html)
```
Output:
```html
local function hello_world(times)
for i=1,times do
print("hello world")
end
end
```
## Interface
### `highlight_to_html(language_name, code, opts={})`
Highlights code using the lexer for `language_name`. All input code is HTML escaped and is safe to embed directly into a page.
Options:
* `class_prefix` -- default `sh_`: Prefix put in front of every class name generated for each element
* `bare` -- default `false`: Set to `true` to not return the code wrapped in a `pre` tag
## License
### Files located in `syntaxhighlight/textadept/`
*See respective authors on top of each file*
The MIT License
Copyright (c) 2007-2019 Mitchell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
### Everything else
The MIT License
Copyright (c) 2020 Leaf Corcoran
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.