markup/Parse

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(quickly added info about available functions)
 
(2 intermediate revisions by one user not shown)
Line 16: Line 16:
 
{{Ret
 
{{Ret
 
|type=MarkupObject
 
|type=MarkupObject
|desc=parsed
+
|desc=The parsed markup object ready to be drawn.
 
}}
 
}}
 
{{Example
 
{{Example
Line 23: Line 23:
  
 
hook.Add("HUDPaint", "MarkupTest", function()
 
hook.Add("HUDPaint", "MarkupTest", function()
parsed:Draw(100, 100, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
+
parsed:Draw(100, 100, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
 
end)
 
end)
|Output=<br /><br />[[File:Screenshot-2012-08-30 13.13.59.png]]
+
|Output=[[File:Screenshot-2012-08-30 13.13.59.png]]
 
}}
 
}}

Latest revision as of 16:24, 11 August 2019

 markup.Parse( )

Contents

Description

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

Arguments

string markup

The markup to be parsed.

Arguments

number maxwidth

The max width of the output

Returns

MarkupObject

The parsed markup object ready to be drawn.

Examples

Example

Renders a markup string on the HUD.

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:

Screenshot-2012-08-30 13.13.59.png
Personal tools
Navigation