classDiagram
    %% Интерфейсы
    class Markdown {
        <<interface>>
        +toMarkdown(StringBuilder)
    }
    
    class Html {
        <<interface>>
        +toHtml(StringBuilder)
    }
    
    class Markup {
        <<interface>>
        +toMarkdown(StringBuilder)
        +toHtml(StringBuilder)
    }
    
    class PartOfParagraph {
        <<interface>>
        +toMarkdown(StringBuilder)
        +toHtml(StringBuilder)
    }
    
    class ContainsInListItem {
        <<interface>>
        +toMarkdown(StringBuilder)
        +toHtml(StringBuilder)
    }
    
    class PrimePart {
        <<interface>>
        +toMarkdown(StringBuilder)
        +toHtml(StringBuilder)
    }
    
    %% Наследование интерфейсов
    Markup --|> Markdown
    Markup --|> Html
    PartOfParagraph --|> Markup
    ContainsInListItem --|> Markup
    PrimePart --|> Markup
    
    %% Абстрактные классы
    class AbstractMarkup {
        <<abstract>>
        #List~Markup~ items
        -String highlightMarkdown
        -String highlightHtml
        -String highlightTexOpen
        -String highlightTexClose
        +AbstractMarkup(List, String, String, String, String)
        +toMarkdown(StringBuilder)
        +toHtml(StringBuilder)
        +toTex(StringBuilder)
    }
    
    class AbstractList {
        <<abstract>>
        -List~ListItem~ items
        -String highlight
        -String texBegin
        -String texEnd
        +AbstractList(List, String, String, String)
        +toHtml(StringBuilder)
        +toMarkdown(StringBuilder)
        +toTex(StringBuilder)
    }
    
    %% Абстрактные классы реализуют интерфейсы
    AbstractMarkup ..|> Markdown
    AbstractMarkup ..|> Html
    AbstractList ..|> ContainsInListItem
    
    %% Inline элементы
    class Text {
        -String text
        +Text(String)
        +toMarkdown(StringBuilder)
        +toHtml(StringBuilder)
        +toTex(StringBuilder)
    }
    
    class Emphasis {
        +Emphasis(List~PartOfParagraph~)
    }
    
    class Strong {
        +Strong(List~PartOfParagraph~)
    }
    
    class Strikeout {
        +Strikeout(List~PartOfParagraph~)
    }
    
    %% Inline элементы наследуются и реализуют
    Text ..|> PartOfParagraph
    Emphasis --|> AbstractMarkup
    Emphasis ..|> PartOfParagraph
    Strong --|> AbstractMarkup
    Strong ..|> PartOfParagraph
    Strikeout --|> AbstractMarkup
    Strikeout ..|> PartOfParagraph
    
    %% Paragraph
    class Paragraph {
        +Paragraph(List~PartOfParagraph~)
    }
    
    Paragraph --|> AbstractMarkup
    Paragraph ..|> ContainsInListItem
    Paragraph ..|> PrimePart
    
    %% Списки
    class OrderedList {
        +OrderedList(List~ListItem~)
    }
    
    class UnorderedList {
        +UnorderedList(List~ListItem~)
    }
    
    class ListItem {
        +ListItem(List~ContainsInListItem~)
    }
    
    OrderedList --|> AbstractList
    UnorderedList --|> AbstractList
    ListItem --|> AbstractMarkup
    ListItem ..|> Markup
    
    %% Зависимости (что может содержать что)
    AbstractMarkup o-- Markup : contains
    AbstractList o-- ListItem : contains
    Emphasis o-- PartOfParagraph : contains
    Strong o-- PartOfParagraph : contains
    Strikeout o-- PartOfParagraph : contains
    Paragraph o-- PartOfParagraph : contains
    ListItem o-- ContainsInListItem : contains
    
    %% Стили
    style Markdown fill:#e1f5ff
    style Html fill:#e1f5ff
    style Markup fill:#e1f5ff
    style PartOfParagraph fill:#fff4e1
    style ContainsInListItem fill:#fff4e1
    style PrimePart fill:#fff4e1
    style AbstractMarkup fill:#ffe1f5
    style AbstractList fill:#ffe1f5
    style Text fill:#e1ffe1
    style Emphasis fill:#e1ffe1
    style Strong fill:#e1ffe1
    style Strikeout fill:#e1ffe1
    style Paragraph fill:#ffe1e1
    style OrderedList fill:#f5e1ff
    style UnorderedList fill:#f5e1ff
    style ListItem fill:#f5e1ff
