Skip to main content

microcad_lang_markdown/
paragraph.rs

1// Copyright © 2026 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4use crate::code_block::CodeBlock;
5
6/// A paragraph. Each parameter ends with a new line.
7#[derive(Debug, Clone, PartialEq)]
8pub enum Paragraph {
9    /// A paragraph with text.
10    Text(String),
11
12    /// A µcad code block starting with ```µcad or with `[![test](...)` banner.
13    CodeBlock(CodeBlock),
14
15    /// A table. Each line starts with `|`.
16    Table(String),
17}
18
19impl std::fmt::Display for Paragraph {
20    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21        match &self {
22            Paragraph::Text(text) => writeln!(f, "{text}"),
23            Paragraph::CodeBlock(code_block) => writeln!(f, "{code_block}"),
24            Paragraph::Table(table) => writeln!(f, "{table}"),
25        }
26    }
27}