Garry's Mod Wiki

markup.Parse

  MarkupObject markup.Parse( string markup, number maxWidth = nil )

Description

Parses markup into a MarkupObject. Currently, this only supports fonts and colors as demonstrated in the example.

Arguments

1 string markup
The markup to be parsed.
2 number maxWidth = nil
The max width of the output

Returns

1 MarkupObject
The parsed markup object ready to be drawn via MarkupObject:Draw.

Example

Renders a markup string on the HUD.

The the <colour> tag can also be written as <color>, and the <font> tag can also be written as <face>
local parsed = markup.Parse("<font=Default>changed font</font>\n<colour=255,0,255,255>changed colour</colour>") hook.Add("HUDPaint", "MarkupTest", function() parsed:Draw(100, 100, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end)
Output: