activate

abjad.top.activate.activate(text, tag, skipped=False)

Activates tag in text.

Writes (deactivated) tag with '%@%' prefix into LilyPond input:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> markup = abjad.Markup('Allegro').with_color('red')
>>> abjad.attach(
...     markup,
...     staff[0],
...     deactivate=True,
...     tag='RED_MARKUP',
...     )
>>> text = format(staff, 'lilypond')
>>> text = abjad.LilyPondFormatManager.left_shift_tags(text)
>>> print(text)
\new Staff
{
    c'4
%@% - \markup {         %! RED_MARKUP
%@%     \with-color     %! RED_MARKUP
%@%         #red        %! RED_MARKUP
%@%         Allegro     %! RED_MARKUP
%@%     }               %! RED_MARKUP
    d'4
    e'4
    f'4
}
>>> abjad.show(staff) 

Activates tag:

>>> text, count = abjad.activate(text, 'RED_MARKUP')
>>> print(text)
\new Staff
{
    c'4
    - \markup {         %! RED_MARKUP %@%
        \with-color     %! RED_MARKUP %@%
            #red        %! RED_MARKUP %@%
            Allegro     %! RED_MARKUP %@%
        }               %! RED_MARKUP %@%
    d'4
    e'4
    f'4
}
>>> lines = [_.strip('\n') for _ in text.split('\n')]
>>> lilypond_file = abjad.LilyPondFile.new(lines)
>>> abjad.show(lilypond_file) 

Deactivates tag again:

>>> text, count = abjad.deactivate(text, 'RED_MARKUP')
>>> print(text)
\new Staff
{
    c'4
%@% - \markup {         %! RED_MARKUP
%@%     \with-color     %! RED_MARKUP
%@%         #red        %! RED_MARKUP
%@%         Allegro     %! RED_MARKUP
%@%     }               %! RED_MARKUP
    d'4
    e'4
    f'4
}
>>> lines = [_.strip('\n') for _ in text.split('\n')]
>>> lilypond_file = abjad.LilyPondFile.new(lines)
>>> abjad.show(lilypond_file) 

Activates tag again:

>>> text, count = abjad.activate(text, 'RED_MARKUP')
>>> print(text)
\new Staff
{
    c'4
    - \markup {         %! RED_MARKUP %@%
        \with-color     %! RED_MARKUP %@%
            #red        %! RED_MARKUP %@%
            Allegro     %! RED_MARKUP %@%
        }               %! RED_MARKUP %@%
    d'4
    e'4
    f'4
}
>>> lines = [_.strip('\n') for _ in text.split('\n')]
>>> lilypond_file = abjad.LilyPondFile.new(lines)
>>> abjad.show(lilypond_file) 

Tags can toggle indefinitely.

Returns text, count pair.

Count gives number of activated tags.