Repository: ManimCommunity/manim
File: manim/mobject/text/text_mobject.py (Python)

Code before:
    Parameters
    ----------
    mobject
        Any SVGMobject from which we want to remove unwanted invisible characters.

    Returns
    -------
    :class:`~.SVGMobject`
        The SVGMobject without unwanted invisible characters.
    """
    # TODO: Refactor needed
    iscode = False
    if isinstance(mobject, Text):
        mobject = mobject[:]
    elif isinstance(mobject, Code):
        iscode = True
        code = mobject
        mobject = mobject.code
    mobject_without_dots = VGroup()
    if isinstance(mobject[0], VGroup):
        for submob in mobject:
            mobject_without_dots.add(
                VGroup(k for k in submob if not isinstance(k, Dot))
            )
    else:
        mobject_without_dots.add(*(k for k in mobject if k.__class__ != Dot))
    if iscode:
        assert isinstance(code, Code)
        code.code = mobject_without_dots
        return code
    return mobject_without_dots


class Paragraph(VGroup):
    r"""Display a paragraph of text.

    For a given :class:`.Paragraph` ``par``, the attribute ``par.chars`` is a
    :class:`.VGroup` containing all the lines. In this context, every line is
    constructed as a :class:`.VGroup` of characters contained in the line.


    Parameters
    ----------
    line_spacing
        Represents the spacing between lines. Defaults to -1, which means auto.
    alignment
        Defines the alignment of paragraph. Defaults to None. Possible values are "left", "right" or "center".

    Examples
    --------
    Normal usage::

Review comment (suggestion):
Don't forget this one:
```suggestion
        mobject_without_dots.add(*(k for k in mobject if not isinstance(k, Dot)))
```

Code after:
    Parameters
    ----------
    mobject
        Any SVGMobject from which we want to remove unwanted invisible characters.

    Returns
    -------
    :class:`~.SVGMobject`
        The SVGMobject without unwanted invisible characters.
    """
    # TODO: Refactor needed
    iscode = False
    if isinstance(mobject, Text):
        mobject = mobject[:]
    elif isinstance(mobject, Code):
        iscode = True
        code = mobject
        mobject = mobject.code
    mobject_without_dots = VGroup()
    if isinstance(mobject[0], VGroup):
        for submob in mobject:
            mobject_without_dots.add(
                VGroup(k for k in submob if not isinstance(k, Dot))
            )
    else:
        mobject_without_dots.add(*(k for k in mobject if not isinstance(k, Dot)))
    if iscode:
        assert isinstance(code, Code)
        code.code = mobject_without_dots
        return code
    return mobject_without_dots


class Paragraph(VGroup):
    r"""Display a paragraph of text.

    For a given :class:`.Paragraph` ``par``, the attribute ``par.chars`` is a
    :class:`.VGroup` containing all the lines. In this context, every line is
    constructed as a :class:`.VGroup` of characters contained in the line.


    Parameters
    ----------
    line_spacing
        Represents the spacing between lines. Defaults to -1, which means auto.
    alignment
        Defines the alignment of paragraph. Defaults to None. Possible values are "left", "right" or "center".

    Examples
    --------
    Normal usage::