Package: pango

Function pango:parse-markup

Lambda List

pango:parse-markup (markup marker)

Arguments

markup -- a string with the parkup to parse
marker -- a character that precedes an accelerator, or 0 for none

Return Value

text -- a string with the text with tags stripped
attrlist -- a pango:attr-list instance
char -- a character with the accelerator char

Details

Parses marked-up text to create a plain-text string and an attribute list. If marker is nonzero, the given character will mark the character following it as an accelerator. For example, marker might be an ampersand or underscore. All characters marked as an accelerator will receive a :underline-low attribute, and the first character so marked will be returned in char. Two marker characters following each other produce a single literal marker character.

If any error happens, nil is returned.

Examples

(multiple-value-bind (text attrlist char)
    (pango:parse-markup "<b>_Text</b>" #\_)
  (values text
          (pango:attr-list-to-string attrlist)
          char))
=> "Text"
   "0 1 underline low
    0 4 weight bold"
   #\T

(multiple-value-bind (text attrlist char) (pango:parse-markup "<span foreground='blue' size='x-large'> Blue text </span> is <i>cool</i>!" #\_) (values text (pango:attr-list-to-string attrlist) char)) => "Blue text is cool!" "0 9 scale 1.440000 0 9 foreground #00000000ffff 13 17 style italic" #\Nul
 

See also

2024-11-21