'Set the text-align property on the current block tag(s)'

def set_text_alignment(self, editor, value):

    editor.highlighter.join()
    block_tag_names = (BLOCK_TAG_NAMES - {u'body'})
    tags = []
    c = editor.textCursor()
    if c.hasSelection():
        (start, end) = (min(c.anchor(), c.position()), max(c.anchor(), c.position()))
        c.setPosition(start)
        block = c.block()
        while (block.isValid() and (block.position() < end)):
            ud = block.userData()
            if (ud is not None):
                for tb in ud.tags:
                    if (tb.is_start and (not tb.closing) and (tb.name.lower() in block_tag_names)):
                        (nblock, boundary) = next_tag_boundary(block, tb.offset)
                        if ((boundary is not None) and (not boundary.is_start) and (not boundary.self_closing)):
                            tags.append(Tag(block, tb, nblock, boundary))
            block = block.next()
    if (not tags):
        c = editor.textCursor()
        (block, offset) = (c.block(), c.positionInBlock())
        tag = find_closest_containing_block_tag(block, offset, block_tag_names)
        if (tag is None):
            return error_dialog(editor, _(u'Not    in    a    block    tag'), _(u'Cannot    change    text    alignment    as    the    cursor    is    not    inside    a    block    level    tag,    such    as    a    &lt;p&gt;    or    &lt;div&gt;    tag.'), show=True)
        tags = [tag]
    for tag in reversed(tags):
        set_style_property(tag, u'text-align', value, editor)
