Markup

class markuptools.Markup(contents=None, direction=None, stack_priority=0)

LilyPond markup.

Initializes from string:

>>> string = r'\italic { "Allegro assai" }'
>>> markup = Markup(string)
>>> f(markup)
\markup {
    \italic
        {
            "Allegro assai"
        }
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> string = r'\italic { "Allegro assai" }'
>>> markup = expression(string)
>>> f(markup)
\markup {
    \italic
        {
            "Allegro assai"
        }
    }
>>> show(markup) 

Initializes from other markup:

>>> markup = Markup('Allegro assai', direction=Up)
>>> markup = markup.italic()
>>> markup = Markup(markup, direction=Down)
>>> f(markup)
_ \markup {
    \italic
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> markup = Markup('Allegro assai', direction=Up)
>>> markup = markup.italic()
>>> markup = expression(markup, direction=Down)
>>> f(markup)
_ \markup {
    \italic
        "Allegro assai"
    }
>>> show(markup) 

Attaches markup to score components:

>>> staff = Staff("c'8 d'8 e'8 f'8")
>>> string = r'\italic { "Allegro assai" }'
>>> markup = Markup(string, direction=Up)
>>> f(markup)
^ \markup {
    \italic
        {
            "Allegro assai"
        }
    }
>>> attach(markup, staff[0])
>>> show(staff) 
>>> staff = Staff("c'8 d'8 e'8 f'8")
>>> string = r'\italic { "Allegro assai" }'
>>> expression = Expression().markup()
>>> markup = expression(string, direction=Up)
>>> f(markup)
^ \markup {
    \italic
        {
            "Allegro assai"
        }
    }
>>> attach(markup, staff[0])
>>> show(staff) 

Note

Make sure all static markup methods implement a direction keyword when extending this class.

Set direction to Up, Down, 'neutral', '^', '_', '-' or None.

Markup objects are immutable.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_markuptools { graph [label=markuptools]; "abjad.tools.markuptools.Markup.Markup" [color=black, fontcolor=white, group=2, label=<<B>Markup</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.markuptools.Markup.Markup"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

bold() LilyPond \bold markup command.
box() LilyPond \box markup command.
bracket() LilyPond \bracket markup command.
caps() LilyPond \caps markup command.
center_align() LilyPond \center-align markup command.
center_column(markup_list[, direction]) LilyPond \center-column markup command.
circle() LilyPond \circle markup command.
column(markup_list[, direction]) LilyPond \column markup command.
combine(markup_list[, direction]) LilyPond \combine markup command.
concat(markup_list[, direction]) LilyPond \concat markup command.
contents Gets contents of markup.
direction Gets direction of markup.
draw_circle(radius, thickness[, direction, ...]) LilyPond \draw-circle markup command.
draw_line(x, y[, direction]) LilyPond \draw-line markup command.
dynamic() LilyPond \dynamic markup command.
filled_box(x_extent, y_extent[, blot, direction]) LilyPond filled-box markup command.
finger() LilyPond \finger markup command.
flat([direction]) LilyPond \flat markup command.
fontsize(fontsize) LilyPond \fontsize markup command.
fraction(numerator, denominator[, direction]) LilyPond \fraction markup command.
general_align(axis, direction) LilyPond \general-align markup command.
halign(direction) LilyPond halign markup command.
hcenter_in(length) LilyPond \hcenter-in markup command.
hspace(amount[, direction]) LilyPond \hspace markup command.
huge() LilyPond \huge markup command.
italic() LilyPond \italic markup command.
larger() LilyPond \larger markup command.
left_column(markup_list[, direction]) LilyPond \left-column markup command.
line(markup_list[, direction]) LilyPond \line markup command.
make_improper_fraction_markup(rational[, ...]) Makes improper fraction markup.
musicglyph([glyph_name, direction]) LilyPond \musicglyph markup command.
natural([direction]) LilyPond \natural markup command.
note_by_number(log, dot_count, stem_direction) LilyPond \note-by-number markup command.
null([direction]) LilyPond \null markup command.
overlay(markup_list[, direction]) LilyPond \overlay markup command.
override(new_property) LilyPond \override markup command.
pad_around(padding) LilyPond \pad-around markup command.
pad_to_box(x_extent, y_extent) LilyPond pad-to-box markup command.
parenthesize() LilyPond \parenthesize markup command.
postscript(postscript[, direction]) LilyPond \postscript markup command.
raise_(amount) LilyPond \raise markup command.
right_column(markup_list[, direction]) LilyPond \right-column markup command.
rotate(angle) LilyPond \rotate markup command.
sans() LilyPond \sans markup command.
scale(factor_pair) LilyPond \scale markup command.
sharp([direction]) LilyPond \sharp markup command.
small() LilyPond \small markup command.
smaller() LilyPond \smaller markup command.
stack_priority Gets stack priority of markup.
sub() LilyPond \sub markup command.
super() LilyPond \super markup command.
tiny() LilyPond \tiny markup command.
translate(offset_pair) LilyPond translate markup command.
triangle([direction, is_filled]) LilyPond \triangle markup command.
upright() LilyPond \upright markup command.
vcenter() LilyPond \vcenter markup command.
vspace(amount[, direction]) LilyPond \vspace markup command.
whiteout() LilyPond \whiteout markup command.
with_color(color) LilyPond \with-color markup command.
with_dimensions(x_extent, y_extent) LilyPond with-dimensions markup command.
__add__(argument) Adds markup to argument.
__copy__(*arguments) Copies markup.
__eq__(argument) Is true markup equals argument.
__format__([format_specification]) Formats markup.
__hash__() Hashes markup.
__illustrate__() Illustrates markup.
__lt__(argument) Is true when markup contents compare less than argument contents.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.
__str__() Gets string representation of markup.

Read-only properties

Markup.contents

Gets contents of markup.

Initializes contents positionally:

>>> Markup('Allegro assai')
Markup(contents=['Allegro assai'])

Initializes contents from keyword:

>>> Markup(contents='Allegro assai')
Markup(contents=['Allegro assai'])

Initializes contents positionally:

>>> expression = Expression().markup()
>>> expression('Allegro assai')
Markup(contents=['Allegro assai'])

Initializes contents from keyword:

>>> expression = Expression().markup()
>>> expression(contents='Allegro assai')
Markup(contents=['Allegro assai'])

Returns tuple.

Markup.direction

Gets direction of markup.

Initializes without direction:

>>> Markup('Allegro')
Markup(contents=['Allegro'])

Initializes with direction:

>>> Markup('Allegro', direction=Up)
Markup(contents=['Allegro'], direction=Up)

Initializes without direction:

>>> expression = Expression().markup()
>>> expression('Allegro')
Markup(contents=['Allegro'])

Sets direction at initialization:

>>> expression = Expression().markup(direction=Up)
>>> expression('Allegro')
Markup(contents=['Allegro'], direction=Up)

Sets direction at evaluation:

>>> expression = Expression().markup()
>>> expression('Allegro', direction=Down)
Markup(contents=['Allegro'], direction=Down)

Overrides direction at evaluation:

>>> expression = Expression().markup(direction=Up)
>>> expression('Allegro', direction=Down)
Markup(contents=['Allegro'], direction=Down)

Defaults to none.

Set to up, down, center or none.

Returns up, down, center or none.

Markup.stack_priority

Gets stack priority of markup.

>>> staff = Staff("c'8 d'8 e'8 f'8")
>>> attach(Markup(('Non',  'troppo'), stack_priority=1000), staff[1])
>>> attach(Markup('allegro', stack_priority=0), staff[1])
>>> show(staff) 
>>> staff = Staff("c'8 d'8 e'8 f'8")
>>> attach(Markup(('non',  'troppo'), stack_priority=0), staff[1])
>>> attach(Markup('Allegro', stack_priority=1000), staff[1])
>>> show(staff) 

Higher priority equals greater absolute distance from staff.

Defaults to zero.

Set to integer.

Returns integer.

Methods

Markup.bold()

LilyPond \bold markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.bold()
>>> f(markup)
\markup {
    \bold
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = expressiontools.Expression()
>>> expression = expression.markup()
>>> expression = expression.bold()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \bold
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.box()

LilyPond \box markup command.

Default box:

>>> markup = Markup('Allegro assai')
>>> markup = markup.box()
>>> f(markup)
\markup {
    \box
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.box()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \box
        "Allegro assai"
    }
>>> show(markup) 

Customized box:

>>> markup = Markup('Allegro assai')
>>> markup = markup.box()
>>> markup = markup.override(('box-padding', 0.5))
>>> f(markup)
\markup {
    \override
        #'(box-padding . 0.5)
        \box
            "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.box()
>>> expression = expression.override(('box-padding', 0.5))
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \override
        #'(box-padding . 0.5)
        \box
            "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.bracket()

LilyPond \bracket markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.bracket()
>>> f(markup)
\markup {
    \bracket
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.bracket()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \bracket
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.caps()

LilyPond \caps markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.caps()
>>> f(markup)
\markup {
    \caps
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.caps()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \caps
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.center_align()

LilyPond \center-align markup command.

>>> markup_a = Markup('allegro')
>>> markup_b = Markup('non').center_align()
>>> markup_c = Markup('troppo')
>>> markup = Markup.column([markup_a, markup_b, markup_c])
>>> f(markup)
\markup {
    \column
        {
            allegro
            \center-align
                non
            troppo
        }
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.center_align()
>>> markup_a = Markup('allegro')
>>> markup_b = expression('non')
>>> markup_c = Markup('troppo')
>>> markups = [markup_a, markup_b, markup_c]
>>> markup_list = MarkupList()
>>> markup_list.extend([markup_a, markup_b, markup_c])
>>> markup = markup_list.column()
>>> f(markup)
\markup {
    \column
        {
            allegro
            \center-align
                non
            troppo
        }
    }
>>> show(markup) 

Returns new markup

Markup.circle()

LilyPond \circle markup command.

>>> markup = Markup.fraction(3, 5)
>>> markup = markup.circle()
>>> markup = markup.override(('circle-padding', 0.45))
>>> f(markup)
\markup {
    \override
        #'(circle-padding . 0.45)
        \circle
            \fraction
                3
                5
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.circle()
>>> expression = expression.override(('circle-padding', 0.45))
>>> markup = expression(Markup.fraction(3, 5))
>>> f(markup)
\markup {
    \override
        #'(circle-padding . 0.45)
        \circle
            \fraction
                3
                5
    }
>>> show(markup) 

Returns new markup

Markup.dynamic()

LilyPond \dynamic markup command.

>>> markup = Markup('sffz')
>>> markup = markup.dynamic()
>>> f(markup)
\markup {
    \dynamic
        sffz
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.dynamic()
>>> markup = expression('sffz')
>>> f(markup)
\markup {
    \dynamic
        sffz
    }
>>> show(markup) 

Returns new markup.

Markup.finger()

LilyPond \finger markup command.

>>> markup = Markup(1)
>>> markup = markup.finger()
>>> f(markup)
\markup {
    \finger
        1
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.finger()
>>> markup = expression(1)
>>> f(markup)
\markup {
    \finger
        1
    }
>>> show(markup) 

Returns new markup

Markup.fontsize(fontsize)

LilyPond \fontsize markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.fontsize(-3)
>>> f(markup)
\markup {
    \fontsize
        #-3
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.fontsize(-3)
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \fontsize
        #-3
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup

Markup.general_align(axis, direction)

LilyPond \general-align markup command.

With Abjad direction constant:

>>> markup = Markup('Allegro assai')
>>> markup = markup.general_align('Y', Up)
>>> f(markup)
\markup {
    \general-align
        #Y
        #UP
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.general_align('Y', Up)
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \general-align
        #Y
        #UP
        "Allegro assai"
    }
>>> show(markup) 

With numeric direction value:

>>> markup = Markup('Allegro assai')
>>> markup = markup.general_align('Y', 0.75)
>>> f(markup)
\markup {
    \general-align
        #Y
        #0.75
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.general_align('Y', 0.75)
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \general-align
        #Y
        #0.75
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.halign(direction)

LilyPond halign markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.halign(0)
>>> f(markup)
\markup {
    \halign
        #0
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.halign(0)
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \halign
        #0
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.hcenter_in(length)

LilyPond \hcenter-in markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.hcenter_in(12)
>>> f(markup)
\markup {
    \hcenter-in
        #12
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.hcenter_in(12)
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \hcenter-in
        #12
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.huge()

LilyPond \huge markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.huge()
>>> f(markup)
\markup {
    \huge
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.huge()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \huge
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.italic()

LilyPond \italic markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.italic()
>>> f(markup)
\markup {
    \italic
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.italic()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \italic
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.larger()

LilyPond \larger markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.larger()
>>> f(markup)
\markup {
    \larger
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.larger()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \larger
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.override(new_property)

LilyPond \override markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.parenthesize()
>>> markup = markup.override(('padding', 0.75))
>>> f(markup)
\markup {
    \override
        #'(padding . 0.75)
        \parenthesize
            "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.parenthesize()
>>> expression = expression.override(('padding', 0.75))
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \override
        #'(padding . 0.75)
        \parenthesize
            "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.pad_around(padding)

LilyPond \pad-around markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.pad_around(10)
>>> markup = markup.box()
>>> f(markup)
\markup {
    \box
        \pad-around
            #10
            "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.pad_around(10)
>>> expression = expression.box()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \box
        \pad-around
            #10
            "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.pad_to_box(x_extent, y_extent)

LilyPond pad-to-box markup command.

Positive extents.

The following postscript describes a filled box between the x-coordinates of 0 and 10 and the y-coordinates of 0 and 10. Normally, this would be drawn off the edge of the page.

>>> up_postscript = markuptools.Postscript()
>>> up_postscript = up_postscript.newpath()
>>> up_postscript = up_postscript.moveto(0, 0)
>>> up_postscript = up_postscript.rlineto(10, 0)
>>> up_postscript = up_postscript.rlineto(0, 10)
>>> up_postscript = up_postscript.rlineto(-10, 0)
>>> up_postscript = up_postscript.closepath()
>>> up_postscript = up_postscript.setgray(0.75)
>>> up_postscript = up_postscript.fill()
>>> up_postscript_markup = up_postscript.as_markup()
>>> f(up_postscript_markup)
\markup {
    \postscript
        #"
        newpath
        0 0 moveto
        10 0 rlineto
        0 10 rlineto
        -10 0 rlineto
        closepath
        0.75 setgray
        fill
        "
    }

Notice how the top half of the square is cut off. The coordinates of the postscript put most of the drawing off the edge of the page. LilyPond does not know what the size of the postscript is, so it does not attempt to reposition it:

>>> show(up_postscript_markup) 

Wrapping the postscript in a box shows that LilyPond believes the postscript has effectively no x or y extent:

>>> show(up_postscript_markup.box()) 

By giving the postscript markup explicit extents, we can instruct LilyPond to position it properly:

>>> up_postscript_markup = up_postscript_markup.pad_to_box(
...     (0, 10), (0, 10))
>>> show(up_postscript_markup) 

Boxing also shows that extents have been applied correctly:

>>> show(up_postscript_markup.box()) 
>>> expression = Expression().markup()
>>> expression = expression.pad_to_box((0, 10), (0, 10))
>>> up_postscript = markuptools.Postscript()
>>> up_postscript = up_postscript.newpath()
>>> up_postscript = up_postscript.moveto(0, 0)
>>> up_postscript = up_postscript.rlineto(10, 0)
>>> up_postscript = up_postscript.rlineto(0, 10)
>>> up_postscript = up_postscript.rlineto(-10, 0)
>>> up_postscript = up_postscript.closepath()
>>> up_postscript = up_postscript.setgray(0.75)
>>> up_postscript = up_postscript.fill()
>>> up_postscript_markup = up_postscript.as_markup()
>>> up_postscript_markup = expression(up_postscript_markup)
>>> f(up_postscript_markup)
\markup {
    \pad-to-box
        #'(0 . 10)
        #'(0 . 10)
        \postscript
            #"
            newpath
            0 0 moveto
            10 0 rlineto
            0 10 rlineto
            -10 0 rlineto
            closepath
            0.75 setgray
            fill
            "
    }
>>> show(up_postscript_markup) 
>>> show(up_postscript_markup.box()) 

Negative extents.

LilyPond does not appear to handle negative extents in the same was as it handles positive extents.

The following postscript describes a box of the same shape as in the previous example. However, this box’s x- and y-coordinates range between 0 and 10 and 0 and -10 respectively.

>>> down_postscript = markuptools.Postscript()
>>> down_postscript = down_postscript.newpath()
>>> down_postscript = down_postscript.moveto(0, 0)
>>> down_postscript = down_postscript.rlineto(10, 0)
>>> down_postscript = down_postscript.rlineto(0, -10)
>>> down_postscript = down_postscript.rlineto(-10, 0)
>>> down_postscript = down_postscript.closepath()
>>> down_postscript = down_postscript.setgray(0.75)
>>> down_postscript = down_postscript.fill()
>>> down_postscript_markup = down_postscript.as_markup()
>>> f(down_postscript_markup)
\markup {
    \postscript
        #"
        newpath
        0 0 moveto
        10 0 rlineto
        0 -10 rlineto
        -10 0 rlineto
        closepath
        0.75 setgray
        fill
        "
    }

This time, the entire markup appears to display, without being cut off:

>>> show(down_postscript_markup) 

However, boxing the markup shows that LilyPond still believes it to be of 0-height and 0-width. Notice that the box appears in a different corner of the grey square than in the previous example. This corner is the markup origin. The grey box in example 2 descends from the origin, while the grey box in example 1 ascends from it.

>>> show(down_postscript_markup.box()) 

Giving the postscript markup positive extents does not work:

>>> markup = down_postscript_markup.pad_to_box(
...     (0, 10), (0, 10))
>>> show(markup.box()) 

Likewise, giving the postscript markup negative extents also does not work. The negative extents are treated as 0. In this case, the postscript markup is treated as though it had a height of 0:

>>> markup = down_postscript_markup.pad_to_box(
...     (0, 10), (0, -10))
>>> show(markup.box()) 

Unfortunately, this means that any part of a postscript-created markup that uses negative coordinates cannot be treated properly by LilyPond’s markup spacing logic. To avoid this, only use positive coordinates in postscript.

Returns new markup.

Markup.parenthesize()

LilyPond \parenthesize markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.parenthesize()
>>> f(markup)
\markup {
    \parenthesize
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.parenthesize()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \parenthesize
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.raise_(amount)

LilyPond \raise markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.raise_(0.35)
>>> f(markup)
\markup {
    \raise
        #0.35
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.raise_(0.35)
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \raise
        #0.35
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.rotate(angle)

LilyPond \rotate markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.rotate(45)
>>> f(markup)
\markup {
    \rotate
        #45
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.rotate(45)
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \rotate
        #45
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.sans()

LilyPond \sans markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.sans()
>>> f(markup)
\markup {
    \sans
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.sans()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \sans
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.scale(factor_pair)

LilyPond \scale markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.scale((0.75, 0.75))
>>> f(markup)
\markup {
    \scale
        #'(0.75 . 0.75)
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.scale((0.75, 0.75))
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \scale
        #'(0.75 . 0.75)
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.small()

LilyPond \small markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.small()
>>> f(markup)
\markup {
    \small
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.small()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \small
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.smaller()

LilyPond \smaller markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.smaller()
>>> f(markup)
\markup {
    \smaller
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.smaller()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \smaller
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.sub()

LilyPond \sub markup command.

>>> markup_list = [Markup('A'), Markup('j').sub()]
>>> markup = Markup.concat(markup_list)
>>> f(markup)
\markup {
    \concat
        {
            A
            \sub
                j
        }
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.sub()
>>> expression = expression.wrap_in_list()
>>> expression = expression.markup_list()
>>> expression = expression.insert(0, 'A')
>>> expression = expression.concat()
>>> markup = expression('j')
>>> f(markup)
\markup {
    \concat
        {
            A
            \sub
                j
        }
    }
>>> show(markup) 

Returns new markup.

Markup.super()

LilyPond \super markup command.

>>> markups = [Markup('1'), Markup('st').super()]
>>> markup_list = MarkupList(markups)
>>> markup = markup_list.concat()
>>> f(markup)
\markup {
    \concat
        {
            1
            \super
                st
        }
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.super()
>>> expression = expression.wrap_in_list()
>>> expression = expression.markup_list()
>>> expression = expression.insert(0, 1)
>>> expression = expression.concat()
>>> markup = expression('st')
>>> f(markup)
\markup {
    \concat
        {
            1
            \super
                st
        }
    }
>>> show(markup) 

Returns new markup.

Markup.tiny()

LilyPond \tiny markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.tiny()
>>> f(markup)
\markup {
    \tiny
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.tiny()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \tiny
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.translate(offset_pair)

LilyPond translate markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.translate((2, 1))
>>> f(markup)
\markup {
    \translate
        #'(2 . 1)
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.translate((2, 1))
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \translate
        #'(2 . 1)
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.upright()

LilyPond \upright markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.upright()
>>> f(markup)
\markup {
    \upright
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.upright()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \upright
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.vcenter()

LilyPond \vcenter markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.vcenter()
>>> f(markup)
\markup {
    \vcenter
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.vcenter()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \vcenter
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.whiteout()

LilyPond \whiteout markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.whiteout()
>>> f(markup)
\markup {
    \whiteout
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.whiteout()
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \whiteout
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.with_color(color)

LilyPond \with-color markup command.

>>> markup = Markup('Allegro assai')
>>> markup = markup.with_color('blue')
>>> f(markup)
\markup {
    \with-color
        #blue
        "Allegro assai"
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> expression = expression.with_color('blue')
>>> markup = expression('Allegro assai')
>>> f(markup)
\markup {
    \with-color
        #blue
        "Allegro assai"
    }
>>> show(markup) 

Returns new markup.

Markup.with_dimensions(x_extent, y_extent)

LilyPond with-dimensions markup command.

Note

See the API entry for Markup.pad_to_box() for an extensive discussion of setting explicit markup extents.

>>> up_postscript = markuptools.Postscript()
>>> up_postscript = up_postscript.newpath()
>>> up_postscript = up_postscript.moveto(0, 0)
>>> up_postscript = up_postscript.rlineto(10, 0)
>>> up_postscript = up_postscript.rlineto(0, 10)
>>> up_postscript = up_postscript.rlineto(-10, 0)
>>> up_postscript = up_postscript.closepath()
>>> up_postscript = up_postscript.setgray(0.75)
>>> up_postscript = up_postscript.fill()
>>> up_markup = up_postscript.as_markup()
>>> show(up_markup.box()) 
>>> up_markup = up_markup.with_dimensions((0, 10), (0, 10))
>>> up_markup = up_markup.box()
>>> show(up_markup) 
>>> up_markup = up_postscript.as_markup()
>>> up_markup = up_markup.with_dimensions((0, 20), (0, 20))
>>> up_markup = up_markup.box()
>>> show(up_markup) 
>>> up_markup = up_postscript.as_markup()
>>> up_markup = up_markup.with_dimensions((0, 20), (0, -20))
>>> up_markup = up_markup.box()
>>> show(up_markup) 
>>> down_postscript = markuptools.Postscript()
>>> down_postscript = down_postscript.newpath()
>>> down_postscript = down_postscript.moveto(0, 0)
>>> down_postscript = down_postscript.rlineto(10, 0)
>>> down_postscript = down_postscript.rlineto(0, -10)
>>> down_postscript = down_postscript.rlineto(-10, 0)
>>> down_postscript = down_postscript.closepath()
>>> down_postscript = down_postscript.setgray(0.75)
>>> down_postscript = down_postscript.fill()
>>> down_markup = down_postscript.as_markup()
>>> show(down_markup.box()) 
>>> down_markup = down_markup.with_dimensions((0, 10), (0, 10))
>>> down_markup = down_markup.box()
>>> show(down_markup) 
>>> down_markup = down_postscript.as_markup()
>>> down_markup = down_markup.with_dimensions(
...     (0, 10), (0, -10))
>>> down_markup = down_markup.box()
>>> show(down_markup) 
>>> down_markup = down_postscript.as_markup()
>>> down_markup = down_markup.with_dimensions(
...     (-5, 15), (5, -15))
>>> down_markup = down_markup.box()
>>> show(down_markup) 

Returns new markup.

Class & static methods

static Markup.center_column(markup_list, direction=None)

LilyPond \center-column markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = Markup.center_column([city, date])
>>> f(markup)
\markup {
    \center-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Also works with a list of strings:

>>> city = 'Los Angeles'
>>> date = 'May - August 2014'
>>> markup = Markup.center_column([city, date])
>>> f(markup)
\markup {
    \center-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

static Markup.column(markup_list, direction=None)

LilyPond \column markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = Markup.column([city, date])
>>> f(markup)
\markup {
    \column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

static Markup.combine(markup_list, direction=None)

LilyPond \combine markup command.

>>> markup_one = Markup('Allegro assai')
>>> markup_two = Markup.draw_line(13, 0)
>>> markup_list = [markup_one, markup_two]
>>> markup = Markup.combine(markup_list, direction=Up)
>>> f(markup)
^ \markup {
    \combine
        "Allegro assai"
        \draw-line
            #'(13 . 0)
    }
>>> show(markup) 

Returns new markup.

static Markup.concat(markup_list, direction=None)

LilyPond \concat markup command.

>>> downbow = Markup.musicglyph('scripts.downbow')
>>> hspace = Markup.hspace(1)
>>> upbow = Markup.musicglyph('scripts.upbow')
>>> markup_list = [downbow, hspace, upbow]
>>> markup = Markup.concat(markup_list, direction=Up)
>>> f(markup)
^ \markup {
    \concat
        {
            \musicglyph
                #"scripts.downbow"
            \hspace
                #1
            \musicglyph
                #"scripts.upbow"
        }
    }
>>> show(markup) 

Returns new markup.

static Markup.draw_circle(radius, thickness, direction=None, filled=False)

LilyPond \draw-circle markup command.

>>> markup = Markup.draw_circle(10, 1.5, direction=Up)
>>> f(markup)
^ \markup {
    \draw-circle
        #10
        #1.5
        ##f
    }
>>> show(markup) 

Returns new markup

static Markup.draw_line(x, y, direction=None)

LilyPond \draw-line markup command.

>>> markup = Markup.draw_line(5, -2.5, direction=Up)
>>> f(markup)
^ \markup {
    \draw-line
        #'(5 . -2.5)
    }
>>> show(markup) 

Returns new markup

static Markup.filled_box(x_extent, y_extent, blot=0, direction=None)

LilyPond filled-box markup command.

>>> markup = Markup.filled_box((0, 10), (2, 5), 1.5, direction=Up)
>>> f(markup)
^ \markup {
    \filled-box
        #'(0 . 10)
        #'(2 . 5)
        #1.5
    }
>>> show(markup) 

Returns new markup.

static Markup.flat(direction=None)

LilyPond \flat markup command.

>>> markup = Markup.flat(direction=Up)
>>> f(markup)
^ \markup {
    \flat
    }
>>> show(markup) 

Returns new markup.

static Markup.fraction(numerator, denominator, direction=None)

LilyPond \fraction markup command.

Fraction with integer numerator and denominator:

>>> markup = Markup.fraction(1, 4, direction=Up)
>>> f(markup)
^ \markup {
    \fraction
        1
        4
    }
>>> show(markup) 

Fraction with string numerator and integer denominator:

>>> markup = Markup.fraction('π', 4)
>>> f(markup)
\markup {
    \fraction
        π
        4
    }
>>> show(markup) 

Returns new markup

static Markup.hspace(amount, direction=None)

LilyPond \hspace markup command.

>>> markup = Markup.hspace(0.75, direction=Up)
>>> f(markup)
^ \markup {
    \hspace
        #0.75
    }
>>> show(markup) 

Returns new markup.

static Markup.left_column(markup_list, direction=None)

LilyPond \left-column markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = Markup.left_column([city, date])
>>> f(markup)
\markup {
    \left-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

static Markup.line(markup_list, direction=None)

LilyPond \line markup command.

>>> markups = ['Allegro', 'assai']
>>> markups = [Markup(_) for _ in markups]
>>> markup = Markup.line(markups)
>>> f(markup)
\markup {
    \line
        {
            Allegro
            assai
        }
    }
>>> show(markup) 

Returns new markup.

static Markup.make_improper_fraction_markup(rational, direction=None)

Makes improper fraction markup.

With integer-equivalent number:

>>> markup = Markup.make_improper_fraction_markup(
...     Fraction(6, 3),
...     direction=Up,
...     )
>>> f(markup)
^ \markup { 2 }
>>> show(markup) 

With non-integer-equivalent number:

>>> markup = Markup.make_improper_fraction_markup(Fraction(7, 3))
>>> f(markup)
\markup {
    2
    \tiny
        \fraction
            1
            3
    }
>>> show(markup) 
static Markup.musicglyph(glyph_name=None, direction=None)

LilyPond \musicglyph markup command.

>>> markup = Markup.musicglyph(
...     'accidentals.sharp',
...     direction=Up,
...     )
>>> f(markup)
^ \markup {
    \musicglyph
        #"accidentals.sharp"
    }
>>> show(markup) 

Returns new markup.

static Markup.natural(direction=None)

LilyPond \natural markup command.

>>> markup = Markup.natural(direction=Up)
>>> f(markup)
^ \markup {
    \natural
    }
>>> show(markup) 

Returns new markup.

static Markup.note_by_number(log, dot_count, stem_direction, direction=None)

LilyPond \note-by-number markup command.

>>> markup = Markup.note_by_number(3, 2, 1, direction=Up)
>>> f(markup)
^ \markup {
    \note-by-number
        #3
        #2
        #1
    }
>>> show(markup) 

Returns new markup.

static Markup.null(direction=None)

LilyPond \null markup command.

>>> markup = Markup.null()
>>> f(markup)
\markup {
    \null
    }
>>> show(markup) 

Returns new markup.

static Markup.overlay(markup_list, direction=None)

LilyPond \overlay markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = Markup.overlay([city, date], direction=Up)
>>> f(markup)
^ \markup {
    \overlay
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

static Markup.postscript(postscript, direction=None)

LilyPond \postscript markup command.

>>> postscript = markuptools.Postscript()
>>> postscript = postscript.moveto(1, 1)
>>> postscript = postscript.setlinewidth(2.5)
>>> postscript = postscript.setdash((2, 1))
>>> postscript = postscript.lineto(3, -4)
>>> postscript = postscript.stroke()
>>> markup = markuptools.Markup.postscript(postscript, direction=Up)
>>> f(markup)
^ \markup {
    \postscript
        #"
        1 1 moveto
        2.5 setlinewidth
        [ 2 1 ] 0 setdash
        3 -4 lineto
        stroke
        "
    }
>>> show(markup) 

Returns new markup.

static Markup.right_column(markup_list, direction=None)

LilyPond \right-column markup command.

>>> city = Markup('Los Angeles')
>>> date = Markup('May - August 2014')
>>> markup = Markup.right_column([city, date], direction=Up)
>>> f(markup)
^ \markup {
    \right-column
        {
            "Los Angeles"
            "May - August 2014"
        }
    }
>>> show(markup) 

Returns new markup.

static Markup.sharp(direction=None)

LilyPond \sharp markup command.

>>> markup = Markup.sharp(direction=Up)
>>> f(markup)
^ \markup {
    \sharp
    }
>>> show(markup) 

Returns new markup.

static Markup.triangle(direction=None, is_filled=True)

LilyPond \triangle markup command.

>>> markup = Markup.triangle(direction=Up)
>>> f(markup)
^ \markup {
    \triangle
        ##t
    }
>>> show(markup) 

Returns new markup

static Markup.vspace(amount, direction=None)

LilyPond \vspace markup command.

>>> markup = Markup.vspace(0.75, direction=Up)
>>> f(markup)
^ \markup {
    \vspace
        #0.75
    }
>>> show(markup) 

Returns new markup.

Special methods

Markup.__add__(argument)

Adds markup to argument.

Adds markup to markup:

>>> markup = Markup('Allegro') + Markup('assai')
>>> f(markup)
\markup {
    Allegro
    assai
    }
>>> show(markup) 
>>> expression = expressiontools.Expression()
>>> expression = expression.markup()
>>> expression = expression + Markup('assai')
>>> markup = expression('Allegro')
>>> f(markup)
\markup {
    Allegro
    assai
    }
>>> show(markup) 

Adds markup command to markup:

>>> markup = Markup('Allegro') + Markup.hspace(0.75)
>>> markup = markup + Markup('assai')
>>> f(markup)
\markup {
    Allegro
    \hspace
        #0.75
    assai
    }
>>> show(markup) 
>>> expression = expressiontools.Expression()
>>> expression = expression.markup()
>>> expression = expression + Markup.hspace(0.75)
>>> expression = expression + Markup('assai')
>>> markup = expression('Allegro')
>>> f(markup)
\markup {
    Allegro
    \hspace
        #0.75
    assai
    }
>>> show(markup) 

Returns new markup.

Markup.__copy__(*arguments)

Copies markup.

>>> import copy
>>> markup_1 = Markup('Allegro assai', direction=Up)
>>> markup_2 = copy.copy(markup_1)
>>> markup_1
Markup(contents=['Allegro assai'], direction=Up)
>>> markup_2
Markup(contents=['Allegro assai'], direction=Up)
>>> markup_1 == markup_2
True
>>> markup_1 is markup_2
False

Returns new markup.

Markup.__eq__(argument)

Is true markup equals argument.

Without keywords:

>>> markup_1 = Markup('Allegro')
>>> markup_2 = Markup('Allegro')
>>> markup_3 = Markup('Allegro assai')
>>> markup_1 == markup_1
True
>>> markup_1 == markup_2
True
>>> markup_1 == markup_3
False
>>> markup_2 == markup_1
True
>>> markup_2 == markup_2
True
>>> markup_2 == markup_3
False
>>> markup_3 == markup_1
False
>>> markup_3 == markup_2
False
>>> markup_3 == markup_3
True

With keywords:

>>> markup_1 = Markup('Allegro')
>>> markup_2 = Markup('Allegro', direction=Up)
>>> markup_1 == markup_1
True
>>> markup_1 == markup_2
False
>>> markup_2 == markup_1
False
>>> markup_2 == markup_2
True

Returns new markup.

Markup.__format__(format_specification='')

Formats markup.

Formats markup:

>>> string = r'\italic { Allegro assai }'
>>> markup = Markup(string)
>>> f(markup)
\markup {
    \italic
        {
            Allegro
            assai
        }
    }

Formats markup expression:

>>> expression = Expression().markup()
>>> f(expression)
expressiontools.Expression(
    callbacks=[
        expressiontools.Expression(
            evaluation_template='abjad.markuptools.Markup',
            is_initializer=True,
            ),
        ],
    proxy_class=markuptools.Markup,
    )

Returns string.

Markup.__hash__()

Hashes markup.

Without keywords:

>>> hash_1 = hash(Markup('Allegro'))
>>> hash_2 = hash(Markup('Allegro'))
>>> hash_3 = hash(Markup('Allegro assai'))
>>> hash_1 == hash_1
True
>>> hash_1 == hash_2
True
>>> hash_1 == hash_3
False
>>> hash_2 == hash_1
True
>>> hash_2 == hash_2
True
>>> hash_2 == hash_3
False
>>> hash_3 == hash_1
False
>>> hash_3 == hash_2
False
>>> hash_3 == hash_3
True

With keywords:

>>> hash_1 = hash(Markup('Allegro'))
>>> hash_2 = hash(Markup('Allegro', direction=Up))
>>> hash_1 == hash_1
True
>>> hash_1 == hash_2
False
>>> hash_2 == hash_1
False
>>> hash_2 == hash_2
True
Markup.__illustrate__()

Illustrates markup.

>>> string = r'\italic { Allegro assai }'
>>> markup = Markup(string)
>>> f(markup)
\markup {
    \italic
        {
            Allegro
            assai
        }
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> string = r'\italic { Allegro assai }'
>>> markup = expression(string)
>>> f(markup)
\markup {
    \italic
        {
            Allegro
            assai
        }
    }
>>> show(markup) 

Returns LilyPond file.

Markup.__lt__(argument)

Is true when markup contents compare less than argument contents.

>>> markup_1 = Markup('Allegro')
>>> markup_2 = Markup('assai')
>>> markup_1 < markup_2
True
>>> markup_2 < markup_1
False

Raises type error when argument is not markup.

Returns true or false.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.

Markup.__str__()

Gets string representation of markup.

>>> string = r'\italic { Allegro assai }'
>>> markup = Markup(string)
>>> print(str(markup))
\markup {
    \italic
        {
            Allegro
            assai
        }
    }
>>> show(markup) 
>>> expression = Expression().markup()
>>> string = r'\italic { Allegro assai }'
>>> markup = expression(string)
>>> print(str(markup))
\markup {
    \italic
        {
            Allegro
            assai
        }
    }
>>> show(markup) 

Returns string.