Created
January 2, 2024 13:47
-
-
Save Be1zebub/d58b09f169a09d505a2f41c10e870419 to your computer and use it in GitHub Desktop.
Markdown api (wip)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- parse markdown, its portable (can be used in any framework) | |
local markdown_data = markdown.parse("Hello **bold world!** I use *italic text*.") | |
-- returns: | |
{ | |
{ | |
body = "Hello ", | |
type = "raw" | |
}, | |
{ | |
body = "bold world!", | |
type = "bold" | |
}, | |
{ | |
body = " I use ", | |
type = "raw" | |
}, | |
{ | |
body = "italic text", | |
type = "italic" | |
}, | |
{ | |
body = ".", | |
type = "raw" | |
}, | |
} | |
-- prepare markdown text to render in gmod | |
local markdown_renderdata = markdown.prepare("Hello **bold world!** I use *italic text*.", font, x, y, maxW) | |
-- returns: | |
{ | |
font = "Roboto", | |
text = "Hello **bold world!** I use *italic text*.", | |
w = 256, | |
x = 32, | |
y = 32, | |
data = { | |
{ | |
color = Color( 225, 225, 225 ), | |
font = "markdown-Roboto-basic", | |
text = "Hello ", | |
type = "raw", | |
w = 33, | |
h = 16, | |
x = 32, | |
y = 32 | |
}, | |
{ | |
color = Color( 225, 225, 225 ), | |
font = "markdown-Roboto-bold", | |
text = "bold world!", | |
type = "bold", | |
w = 79, | |
h = 16, | |
x = 65, | |
y = 32 | |
}, | |
{ | |
color = Color( 225, 225, 225 ), | |
font = "markdown-Roboto-basic", | |
text = " I use ", | |
type = "raw", | |
w = 35, | |
h = 16, | |
x = 144, | |
y = 32 | |
}, | |
{ | |
color = Color( 225, 225, 225 ), | |
font = "markdown-Roboto-italic", | |
text = "italic text", | |
type = "italic", | |
w = 52, | |
h = 16, | |
x = 179, | |
y = 32 | |
}, | |
{ | |
color = Color( 225, 225, 225 ), | |
font = "markdown-Roboto-basic", | |
text = ".", | |
type = "raw", | |
w = 4, | |
h = 16, | |
x = 231, | |
y = 32 | |
} | |
} | |
} | |
-- render prepared markdown in gmod | |
markdown.draw(markdown_renderdata) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment