LilyPondLiteral

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.indicators" { graph [label="abjad.indicators"]; node [color=1]; "abjad.indicators.LilyPondLiteral.LilyPondLiteral" [URL="../api/abjad/indicators/LilyPondLiteral.html#abjad.indicators.LilyPondLiteral.LilyPondLiteral", color=black, fontcolor=white, label="Lily\nPond\nLiteral", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/indicators/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/indicators/../system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.indicators.LilyPondLiteral.LilyPondLiteral"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.indicators.LilyPondLiteral.LilyPondLiteral(argument='', format_slot='opening', *, directed=None, tweaks=None)

LilyPond literal.

Dotted slur:

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> slur = abjad.Slur()
>>> abjad.attach(slur, staff[:])
>>> literal = abjad.LilyPondLiteral(r'\slurDotted')
>>> abjad.attach(literal, staff[0])
>>> abjad.show(staff) 

Use the absolute before and absolute after format slots like this:

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> abjad.attach(abjad.Slur(), staff[:])
>>> literal = abjad.LilyPondLiteral(r'\slurDotted')
>>> abjad.attach(literal, staff[0])
>>> literal = abjad.LilyPondLiteral('', format_slot='absolute_before')
>>> abjad.attach(literal, staff[0])
>>> literal = abjad.LilyPondLiteral(
...     '% before all formatting',
...     format_slot='absolute_before',
...     )
>>> abjad.attach(literal, staff[0])
>>> literal = abjad.LilyPondLiteral('', format_slot='absolute_after')
>>> abjad.attach(literal, staff[-1])
>>> abjad.show(staff) 

LilyPond literals can be tagged:

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> abjad.attach(abjad.Slur(), staff[:])
>>> literal = abjad.LilyPondLiteral(r'\slurDotted')
>>> abjad.attach(literal, staff[0], tag='RED')
>>> abjad.show(staff) 
>>> abjad.f(staff)
\new Staff
{
    \slurDotted %! RED
    c'8
    (
    d'8
    e'8
    f'8
    )
}

Multiline input is allowed:

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> abjad.attach(abjad.Slur(), staff[:])
>>> lines = [
...     r'\stopStaff',
...     r'\startStaff',
...     r'\once \override Staff.StaffSymbol.color = #red',
...     ]
>>> literal = abjad.LilyPondLiteral(lines)
>>> abjad.attach(literal, staff[2], tag='RED')
>>> abjad.show(staff) 
>>> abjad.f(staff)
\new Staff
{
    c'8
    (
    d'8
    \stopStaff                                     %! RED
    \startStaff                                    %! RED
    \once \override Staff.StaffSymbol.color = #red %! RED
    e'8
    f'8
    )
}

Attributes Summary

__format__ Formats LilyPond literal.
argument Gets argument of LilyPond literal.
directed Is true when literal is directed.
format_slot Gets format slot of LilyPond literal.
list_allowable_format_slots Lists allowable format slots.
tweaks Gets tweaks.

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Returns true or false.

__format__(format_specification='')

Formats LilyPond literal.

Return type:str
(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Class & static methods

static list_allowable_format_slots()

Lists allowable format slots.

>>> for slot in abjad.LilyPondLiteral.list_allowable_format_slots():
...     slot
... 
'absolute_after'
'absolute_before'
'after'
'before'
'closing'
'opening'
Return type:Tuple[str, …]

Read-only properties

argument

Gets argument of LilyPond literal.

>>> literal = abjad.LilyPondLiteral(r'\slurDotted')
>>> literal.argument
'\\slurDotted'
Return type:Union[str, List[str]]
directed

Is true when literal is directed.

Directed literal:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> literal = abjad.LilyPondLiteral(r'\f', 'after', directed=True)
>>> abjad.tweak(literal).color = 'blue'
>>> abjad.tweak(literal).dynamic_line_spanner.staff_padding = 5
>>> abjad.attach(literal, staff[0])
>>> abjad.show(staff) 

Nondirected literal:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> literal = abjad.LilyPondLiteral(
...     r'\breathe',
...     'after',
...     directed=False,
...     )
>>> abjad.tweak(literal).color = 'blue'
>>> abjad.attach(literal, staff[0])
>>> abjad.show(staff) 

Proper use of the directed property entails searching the LilyPond docs to understand whether LilyPond treats any particular command as directed or not. Most LilyPond commands are directed. LilyPond insists that a few commands (include \breathe, \key, \mark) must not be directed.

Return type:Optional[bool]
format_slot

Gets format slot of LilyPond literal.

>>> literal = abjad.LilyPondLiteral(r'\slurDotted')
>>> literal.format_slot
'opening'
Return type:str
tweaks

Gets tweaks.

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> literal = abjad.LilyPondLiteral(
...     r'\f',
...     'after',
...     directed=True,
...     tweaks=[('color', 'blue')],
...     )
>>> abjad.attach(literal, staff[0])
>>> abjad.show(staff) 
Return type:Optional[LilyPondTweakManager]